Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1307)

Unified Diff: test/Transforms/NaCl/combine-shuffle-vector.ll

Issue 282553003: PNaCl translator: combine insertelement / extractelement patterns generated by the toolchain into s… (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Add DCE, address dschuff's comments. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/Transforms/NaCl/ExpandShuffleVector.cpp ('k') | tools/opt/opt.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/Transforms/NaCl/combine-shuffle-vector.ll
diff --git a/test/Transforms/NaCl/combine-shuffle-vector.ll b/test/Transforms/NaCl/combine-shuffle-vector.ll
new file mode 100644
index 0000000000000000000000000000000000000000..fd508275e3eee6d0f84d3b103cfe76133c487b0d
--- /dev/null
+++ b/test/Transforms/NaCl/combine-shuffle-vector.ll
@@ -0,0 +1,58 @@
+; RUN: opt -expand-shufflevector %s -S | \
+; RUN: opt -combine-vector-instructions -S | FileCheck %s
+
+; Test that shufflevector is re-created after having been expanded to
+; insertelement / extractelement: shufflevector isn't part of the stable
+; PNaCl ABI but insertelement / extractelement are. Re-creating
+; shufflevector allows the backend to generate more efficient code.
+;
+; TODO(jfb) Narrow and widen aren't tested since the underlying types
+; are currently not supported by the PNaCl ABI.
+
+define <4 x i32> @test_splat_lo_4xi32(<4 x i32> %lhs, <4 x i32> %rhs) {
+ ; CHECK-LABEL: test_splat_lo_4xi32
+ ; CHECK-NEXT: %[[R:[0-9]+]] = shufflevector <4 x i32> %lhs, <4 x i32> undef, <4 x i32> zeroinitializer
+ %res = shufflevector <4 x i32> %lhs, <4 x i32> %rhs, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
+ ; CHECK-NEXT: ret <4 x i32> %[[R]]
+ ret <4 x i32> %res
+}
+
+define <4 x i32> @test_splat_hi_4xi32(<4 x i32> %lhs, <4 x i32> %rhs) {
+ ; CHECK-LABEL: test_splat_hi_4xi32
+ ; CHECK-NEXT: %[[R:[0-9]+]] = shufflevector <4 x i32> %rhs, <4 x i32> undef, <4 x i32> zeroinitializer
+ %res = shufflevector <4 x i32> %lhs, <4 x i32> %rhs, <4 x i32> <i32 4, i32 4, i32 4, i32 4>
+ ; CHECK-NEXT: ret <4 x i32> %[[R]]
+ ret <4 x i32> %res
+}
+
+define <4 x i32> @test_id_lo_4xi32(<4 x i32> %lhs, <4 x i32> %rhs) {
+ ; CHECK-LABEL: test_id_lo_4xi32
+ ; CHECK-NEXT: %[[R:[0-9]+]] = shufflevector <4 x i32> %lhs, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %res = shufflevector <4 x i32> %lhs, <4 x i32> %rhs, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ ; CHECK-NEXT: ret <4 x i32> %[[R]]
+ ret <4 x i32> %res
+}
+
+define <4 x i32> @test_id_hi_4xi32(<4 x i32> %lhs, <4 x i32> %rhs) {
+ ; CHECK-LABEL: test_id_hi_4xi32
+ ; CHECK-NEXT: %[[R:[0-9]+]] = shufflevector <4 x i32> %rhs, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %res = shufflevector <4 x i32> %lhs, <4 x i32> %rhs, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+ ; CHECK-NEXT: ret <4 x i32> %[[R]]
+ ret <4 x i32> %res
+}
+
+define <4 x i32> @test_interleave_lo_4xi32(<4 x i32> %lhs, <4 x i32> %rhs) {
+ ; CHECK-LABEL: test_interleave_lo_4xi32
+ ; CHECK-NEXT: %[[R:[0-9]+]] = shufflevector <4 x i32> %lhs, <4 x i32> %rhs, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
+ %res = shufflevector <4 x i32> %lhs, <4 x i32> %rhs, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
+ ; CHECK-NEXT: ret <4 x i32> %[[R]]
+ ret <4 x i32> %res
+}
+
+define <4 x i32> @test_interleave_hi_4xi32(<4 x i32> %lhs, <4 x i32> %rhs) {
+ ; CHECK-LABEL: test_interleave_hi_4xi32
+ ; CHECK-NEXT: %[[R:[0-9]+]] = shufflevector <4 x i32> %lhs, <4 x i32> %rhs, <4 x i32> <i32 1, i32 5, i32 3, i32 7>
+ %res = shufflevector <4 x i32> %lhs, <4 x i32> %rhs, <4 x i32> <i32 1, i32 5, i32 3, i32 7>
+ ; CHECK-NEXT: ret <4 x i32> %[[R]]
+ ret <4 x i32> %res
+}
« no previous file with comments | « lib/Transforms/NaCl/ExpandShuffleVector.cpp ('k') | tools/opt/opt.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698