summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSteven Perron <stevenperron@google.com>2018-07-11 11:50:14 -0400
committerSteven Perron <stevenperron@google.com>2018-07-11 14:44:46 -0400
commite63551deacd746d263145a1b96d5ac23ff6211df (patch)
tree3f3c1c3cefceefb80f2d7130b4f0b4c0151f5811 /test
parent4470ff49acf47501857caefaba133d827baeabd5 (diff)
Add folding rule to merge a vector shuffle feeding another one.
Diffstat (limited to 'test')
-rw-r--r--test/opt/fold_test.cpp168
1 files changed, 168 insertions, 0 deletions
diff --git a/test/opt/fold_test.cpp b/test/opt/fold_test.cpp
index 662add1e..ff4a1b59 100644
--- a/test/opt/fold_test.cpp
+++ b/test/opt/fold_test.cpp
@@ -5650,6 +5650,174 @@ INSTANTIATE_TEST_CASE_P(StoreMatchingTest, MatchingInstructionWithNoResultFoldin
0 /* OpStore */, true)
));
+INSTANTIATE_TEST_CASE_P(VectorShuffleMatchingTest, MatchingInstructionWithNoResultFoldingTest,
+::testing::Values(
+ // Test case 0: Basic test 1
+ InstructionFoldingCase<bool>(
+ Header() +
+ "; CHECK: OpVectorShuffle\n" +
+ "; CHECK: OpVectorShuffle {{%\\w+}} %7 %5 2 3 6 7\n" +
+ "; CHECK: OpReturn\n" +
+ "%main = OpFunction %void None %void_func\n" +
+ "%main_lab = OpLabel\n" +
+ "%2 = OpVariable %_ptr_v4double Function\n" +
+ "%3 = OpVariable %_ptr_v4double Function\n" +
+ "%4 = OpVariable %_ptr_v4double Function\n" +
+ "%5 = OpLoad %v4double %2\n" +
+ "%6 = OpLoad %v4double %3\n" +
+ "%7 = OpLoad %v4double %4\n" +
+ "%8 = OpVectorShuffle %v4double %5 %6 2 3 4 5\n" +
+ "%9 = OpVectorShuffle %v4double %7 %8 2 3 4 5\n" +
+ "OpReturn\n" +
+ "OpFunctionEnd",
+ 9, true),
+ // Test case 1: Basic test 2
+ InstructionFoldingCase<bool>(
+ Header() +
+ "; CHECK: OpVectorShuffle\n" +
+ "; CHECK: OpVectorShuffle {{%\\w+}} %6 %7 0 1 4 5\n" +
+ "; CHECK: OpReturn\n" +
+ "%main = OpFunction %void None %void_func\n" +
+ "%main_lab = OpLabel\n" +
+ "%2 = OpVariable %_ptr_v4double Function\n" +
+ "%3 = OpVariable %_ptr_v4double Function\n" +
+ "%4 = OpVariable %_ptr_v4double Function\n" +
+ "%5 = OpLoad %v4double %2\n" +
+ "%6 = OpLoad %v4double %3\n" +
+ "%7 = OpLoad %v4double %4\n" +
+ "%8 = OpVectorShuffle %v4double %5 %6 2 3 4 5\n" +
+ "%9 = OpVectorShuffle %v4double %8 %7 2 3 4 5\n" +
+ "OpReturn\n" +
+ "OpFunctionEnd",
+ 9, true),
+ // Test case 2: Basic test 3
+ InstructionFoldingCase<bool>(
+ Header() +
+ "; CHECK: OpVectorShuffle\n" +
+ "; CHECK: OpVectorShuffle {{%\\w+}} %5 %7 3 2 4 5\n" +
+ "; CHECK: OpReturn\n" +
+ "%main = OpFunction %void None %void_func\n" +
+ "%main_lab = OpLabel\n" +
+ "%2 = OpVariable %_ptr_v4double Function\n" +
+ "%3 = OpVariable %_ptr_v4double Function\n" +
+ "%4 = OpVariable %_ptr_v4double Function\n" +
+ "%5 = OpLoad %v4double %2\n" +
+ "%6 = OpLoad %v4double %3\n" +
+ "%7 = OpLoad %v4double %4\n" +
+ "%8 = OpVectorShuffle %v4double %5 %6 2 3 4 5\n" +
+ "%9 = OpVectorShuffle %v4double %8 %7 1 0 4 5\n" +
+ "OpReturn\n" +
+ "OpFunctionEnd",
+ 9, true),
+ // Test case 3: Basic test 4
+ InstructionFoldingCase<bool>(
+ Header() +
+ "; CHECK: OpVectorShuffle\n" +
+ "; CHECK: OpVectorShuffle {{%\\w+}} %7 %6 2 3 5 4\n" +
+ "; CHECK: OpReturn\n" +
+ "%main = OpFunction %void None %void_func\n" +
+ "%main_lab = OpLabel\n" +
+ "%2 = OpVariable %_ptr_v4double Function\n" +
+ "%3 = OpVariable %_ptr_v4double Function\n" +
+ "%4 = OpVariable %_ptr_v4double Function\n" +
+ "%5 = OpLoad %v4double %2\n" +
+ "%6 = OpLoad %v4double %3\n" +
+ "%7 = OpLoad %v4double %4\n" +
+ "%8 = OpVectorShuffle %v4double %5 %6 2 3 4 5\n" +
+ "%9 = OpVectorShuffle %v4double %7 %8 2 3 7 6\n" +
+ "OpReturn\n" +
+ "OpFunctionEnd",
+ 9, true),
+ // Test case 4: Don't use feeder.
+ InstructionFoldingCase<bool>(
+ Header() +
+ "; CHECK: OpVectorShuffle\n" +
+ "; CHECK: OpVectorShuffle {{%\\w+}} %7 %7 2 3 0 1\n" +
+ "; CHECK: OpReturn\n" +
+ "%main = OpFunction %void None %void_func\n" +
+ "%main_lab = OpLabel\n" +
+ "%2 = OpVariable %_ptr_v4double Function\n" +
+ "%3 = OpVariable %_ptr_v4double Function\n" +
+ "%4 = OpVariable %_ptr_v4double Function\n" +
+ "%5 = OpLoad %v4double %2\n" +
+ "%6 = OpLoad %v4double %3\n" +
+ "%7 = OpLoad %v4double %4\n" +
+ "%8 = OpVectorShuffle %v4double %5 %6 2 3 4 5\n" +
+ "%9 = OpVectorShuffle %v4double %7 %8 2 3 0 1\n" +
+ "OpReturn\n" +
+ "OpFunctionEnd",
+ 9, true),
+ // Test case 5: Don't fold, need both operands of the feeder.
+ InstructionFoldingCase<bool>(
+ Header() +
+ "%main = OpFunction %void None %void_func\n" +
+ "%main_lab = OpLabel\n" +
+ "%2 = OpVariable %_ptr_v4double Function\n" +
+ "%3 = OpVariable %_ptr_v4double Function\n" +
+ "%4 = OpVariable %_ptr_v4double Function\n" +
+ "%5 = OpLoad %v4double %2\n" +
+ "%6 = OpLoad %v4double %3\n" +
+ "%7 = OpLoad %v4double %4\n" +
+ "%8 = OpVectorShuffle %v4double %5 %6 2 3 4 5\n" +
+ "%9 = OpVectorShuffle %v4double %7 %8 2 3 7 5\n" +
+ "OpReturn\n" +
+ "OpFunctionEnd",
+ 9, false),
+ // Test case 6: Don't fold, need both operands of the feeder.
+ InstructionFoldingCase<bool>(
+ Header() +
+ "%main = OpFunction %void None %void_func\n" +
+ "%main_lab = OpLabel\n" +
+ "%2 = OpVariable %_ptr_v4double Function\n" +
+ "%3 = OpVariable %_ptr_v4double Function\n" +
+ "%4 = OpVariable %_ptr_v4double Function\n" +
+ "%5 = OpLoad %v4double %2\n" +
+ "%6 = OpLoad %v4double %3\n" +
+ "%7 = OpLoad %v4double %4\n" +
+ "%8 = OpVectorShuffle %v4double %5 %6 2 3 4 5\n" +
+ "%9 = OpVectorShuffle %v4double %8 %7 2 0 7 5\n" +
+ "OpReturn\n" +
+ "OpFunctionEnd",
+ 9, false),
+ // Test case 7: Fold, need both operands of the feeder, but they are the same.
+ InstructionFoldingCase<bool>(
+ Header() +
+ "; CHECK: OpVectorShuffle\n" +
+ "; CHECK: OpVectorShuffle {{%\\w+}} %5 %7 0 2 7 5\n" +
+ "; CHECK: OpReturn\n" +
+ "%main = OpFunction %void None %void_func\n" +
+ "%main_lab = OpLabel\n" +
+ "%2 = OpVariable %_ptr_v4double Function\n" +
+ "%3 = OpVariable %_ptr_v4double Function\n" +
+ "%4 = OpVariable %_ptr_v4double Function\n" +
+ "%5 = OpLoad %v4double %2\n" +
+ "%6 = OpLoad %v4double %3\n" +
+ "%7 = OpLoad %v4double %4\n" +
+ "%8 = OpVectorShuffle %v4double %5 %5 2 3 4 5\n" +
+ "%9 = OpVectorShuffle %v4double %8 %7 2 0 7 5\n" +
+ "OpReturn\n" +
+ "OpFunctionEnd",
+ 9, true),
+ // Test case 8: Fold, need both operands of the feeder, but they are the same.
+ InstructionFoldingCase<bool>(
+ Header() +
+ "; CHECK: OpVectorShuffle\n" +
+ "; CHECK: OpVectorShuffle {{%\\w+}} %7 %5 2 0 5 7\n" +
+ "; CHECK: OpReturn\n" +
+ "%main = OpFunction %void None %void_func\n" +
+ "%main_lab = OpLabel\n" +
+ "%2 = OpVariable %_ptr_v4double Function\n" +
+ "%3 = OpVariable %_ptr_v4double Function\n" +
+ "%4 = OpVariable %_ptr_v4double Function\n" +
+ "%5 = OpLoad %v4double %2\n" +
+ "%6 = OpLoad %v4double %3\n" +
+ "%7 = OpLoad %v4double %4\n" +
+ "%8 = OpVectorShuffle %v4double %5 %5 2 3 4 5\n" +
+ "%9 = OpVectorShuffle %v4double %7 %8 2 0 7 5\n" +
+ "OpReturn\n" +
+ "OpFunctionEnd",
+ 9, true)
+));
#endif
} // namespace