aboutsummaryrefslogtreecommitdiff
path: root/test/opt/insert_extract_elim_test.cpp
diff options
context:
space:
mode:
authorSteven Perron <stevenperron@google.com>2018-05-30 23:50:07 -0400
committerSteven Perron <stevenperron@google.com>2018-06-01 10:13:39 -0400
commitfe2fbee294a8ad4434f828a8b4d99eafe9aac88c (patch)
tree732a7278db7244380fc0caa6b053511b56afe781 /test/opt/insert_extract_elim_test.cpp
parent9a008835f47885fe76028fb08bfeefa4d6618f8f (diff)
downloadspirv-tools-fe2fbee294a8ad4434f828a8b4d99eafe9aac88c.tar.gz
Delete the insert-extract-elim pass.
Replaces anything that creates an insert-extract-elim pass and create a simplifiation pass instead. Then delete the implementation of the pass. Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1570.
Diffstat (limited to 'test/opt/insert_extract_elim_test.cpp')
-rw-r--r--test/opt/insert_extract_elim_test.cpp82
1 files changed, 58 insertions, 24 deletions
diff --git a/test/opt/insert_extract_elim_test.cpp b/test/opt/insert_extract_elim_test.cpp
index afb0036f..c099d966 100644
--- a/test/opt/insert_extract_elim_test.cpp
+++ b/test/opt/insert_extract_elim_test.cpp
@@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#include <opt/simplification_pass.h>
#include "pass_fixture.h"
#include "pass_utils.h"
@@ -99,8 +100,8 @@ OpReturn
OpFunctionEnd
)";
- SinglePassRunAndCheck<opt::InsertExtractElimPass>(
- predefs + before, predefs + after, true, true);
+ SinglePassRunAndCheck<opt::SimplificationPass>(predefs + before,
+ predefs + after, true, true);
}
TEST_F(InsertExtractElimTest, OptimizeAcrossNonConflictingInsert) {
@@ -184,8 +185,8 @@ OpReturn
OpFunctionEnd
)";
- SinglePassRunAndCheck<opt::InsertExtractElimPass>(
- predefs + before, predefs + after, true, true);
+ SinglePassRunAndCheck<opt::SimplificationPass>(predefs + before,
+ predefs + after, true, true);
}
TEST_F(InsertExtractElimTest, OptimizeOpaque) {
@@ -266,8 +267,8 @@ OpReturn
OpFunctionEnd
)";
- SinglePassRunAndCheck<opt::InsertExtractElimPass>(
- predefs + before, predefs + after, true, true);
+ SinglePassRunAndCheck<opt::SimplificationPass>(predefs + before,
+ predefs + after, true, true);
}
TEST_F(InsertExtractElimTest, OptimizeNestedStruct) {
@@ -395,8 +396,8 @@ OpReturn
OpFunctionEnd
)";
- SinglePassRunAndCheck<opt::InsertExtractElimPass>(
- predefs + before, predefs + after, true, true);
+ SinglePassRunAndCheck<opt::SimplificationPass>(predefs + before,
+ predefs + after, true, true);
}
TEST_F(InsertExtractElimTest, ConflictingInsertPreventsOptimization) {
@@ -463,8 +464,8 @@ OpReturn
OpFunctionEnd
)";
- SinglePassRunAndCheck<opt::InsertExtractElimPass>(assembly, assembly, true,
- true);
+ SinglePassRunAndCheck<opt::SimplificationPass>(assembly, assembly, true,
+ true);
}
TEST_F(InsertExtractElimTest, ConflictingInsertPreventsOptimization2) {
@@ -580,14 +581,14 @@ OpFunctionEnd
%24 = OpCompositeInsert %S_t %float_1 %23 1 1
%25 = OpLoad %v4float %BaseColor
%26 = OpCompositeInsert %S_t %25 %24 1
-%27 = OpCompositeExtract %float %26 1 1
+%27 = OpCompositeExtract %float %25 1
%28 = OpCompositeConstruct %v4float %27 %float_0 %float_0 %float_0
OpStore %gl_FragColor %28
OpReturn
OpFunctionEnd
)";
- SinglePassRunAndCheck<opt::InsertExtractElimPass>(
+ SinglePassRunAndCheck<opt::SimplificationPass>(
before_predefs + before, after_predefs + after, true, true);
}
@@ -689,8 +690,8 @@ OpReturn
OpFunctionEnd
)";
- SinglePassRunAndCheck<opt::InsertExtractElimPass>(
- predefs + before, predefs + after, true, true);
+ SinglePassRunAndCheck<opt::SimplificationPass>(predefs + before,
+ predefs + after, true, true);
}
TEST_F(InsertExtractElimTest, VectorShuffle1) {
@@ -713,7 +714,7 @@ TEST_F(InsertExtractElimTest, VectorShuffle1) {
// OutColor = vec4(v.y);
// }
- const std::string predefs =
+ const std::string predefs_before =
R"(OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
@@ -743,6 +744,10 @@ OpDecorate %OutColor Location 0
%_ptr_Function_float = OpTypePointer Function %float
)";
+ const std::string predefs_after = predefs_before +
+ "%24 = OpConstantComposite %v4float "
+ "%float_1 %float_1 %float_1 %float_1\n";
+
const std::string before =
R"(%main = OpFunction %void None %7
%17 = OpLabel
@@ -764,14 +769,13 @@ OpFunctionEnd
%19 = OpLoad %float %bc2
%20 = OpCompositeConstruct %v4float %18 %19 %float_0 %float_1
%21 = OpVectorShuffle %v4float %20 %20 2 3 0 1
-%23 = OpCompositeConstruct %v4float %float_1 %float_1 %float_1 %float_1
-OpStore %OutColor %23
+OpStore %OutColor %24
OpReturn
OpFunctionEnd
)";
- SinglePassRunAndCheck<opt::InsertExtractElimPass>(
- predefs + before, predefs + after, true, true);
+ SinglePassRunAndCheck<opt::SimplificationPass>(
+ predefs_before + before, predefs_after + after, true, true);
}
TEST_F(InsertExtractElimTest, VectorShuffle2) {
@@ -796,7 +800,7 @@ TEST_F(InsertExtractElimTest, VectorShuffle2) {
// OutColor = vec4(v.y);
// }
- const std::string predefs =
+ const std::string predefs_before =
R"(OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
@@ -826,6 +830,37 @@ OpDecorate %OutColor Location 0
%_ptr_Function_float = OpTypePointer Function %float
)";
+ const std::string predefs_after =
+ R"(OpCapability Shader
+%1 = OpExtInstImport "GLSL.std.450"
+OpMemoryModel Logical GLSL450
+OpEntryPoint Fragment %main "main" %bc %bc2 %OutColor
+OpExecutionMode %main OriginUpperLeft
+OpSource GLSL 450
+OpName %main "main"
+OpName %bc "bc"
+OpName %bc2 "bc2"
+OpName %OutColor "OutColor"
+OpDecorate %bc Location 0
+OpDecorate %bc2 Location 1
+OpDecorate %OutColor Location 0
+%void = OpTypeVoid
+%7 = OpTypeFunction %void
+%float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%_ptr_Input_float = OpTypePointer Input %float
+%bc = OpVariable %_ptr_Input_float Input
+%bc2 = OpVariable %_ptr_Input_float Input
+%float_0 = OpConstant %float 0
+%float_1 = OpConstant %float 1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+%OutColor = OpVariable %_ptr_Output_v4float Output
+%uint = OpTypeInt 32 0
+%_ptr_Function_float = OpTypePointer Function %float
+%24 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
+)";
+
const std::string before =
R"(%main = OpFunction %void None %7
%17 = OpLabel
@@ -847,14 +882,13 @@ OpFunctionEnd
%19 = OpLoad %float %bc2
%20 = OpCompositeConstruct %v4float %18 %19 %float_0 %float_1
%21 = OpVectorShuffle %v4float %20 %20 2 7 0 1
-%23 = OpCompositeConstruct %v4float %float_1 %float_1 %float_1 %float_1
-OpStore %OutColor %23
+OpStore %OutColor %24
OpReturn
OpFunctionEnd
)";
- SinglePassRunAndCheck<opt::InsertExtractElimPass>(
- predefs + before, predefs + after, true, true);
+ SinglePassRunAndCheck<opt::SimplificationPass>(
+ predefs_before + before, predefs_after + after, true, true);
}
// TODO(greg-lunarg): Add tests to verify handling of these cases: