[llvm] r261799 - add tests to show missing bitcasted logic transform

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 24 14:31:18 PST 2016


Author: spatel
Date: Wed Feb 24 16:31:18 2016
New Revision: 261799

URL: http://llvm.org/viewvc/llvm-project?rev=261799&view=rev
Log:
add tests to show missing bitcasted logic transform

Modified:
    llvm/trunk/test/Transforms/InstCombine/bitcast-bigendian.ll
    llvm/trunk/test/Transforms/InstCombine/bitcast.ll

Modified: llvm/trunk/test/Transforms/InstCombine/bitcast-bigendian.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/bitcast-bigendian.ll?rev=261799&r1=261798&r2=261799&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/bitcast-bigendian.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/bitcast-bigendian.ll Wed Feb 24 16:31:18 2016
@@ -89,3 +89,45 @@ define <2 x float> @test6(float %A){
 ; CHECK-NEXT: insertelement <2 x float> {{.*}}, float 4.200000e+01, i32 1
 ; CHECK: ret
 }
+
+; FIXME: Do the logic in the original type for the following 3 tests.
+
+; Verify that 'xor' of vector and constant is done as a vector bitwise op before the bitcast.
+
+define <2 x i32> @xor_bitcast_vec_to_vec(<1 x i64> %a) {
+  %t1 = bitcast <1 x i64> %a to <2 x i32>
+  %t2 = xor <2 x i32> <i32 1, i32 2>, %t1
+  ret <2 x i32> %t2
+
+; CHECK-LABEL: @xor_bitcast_vec_to_vec(
+; CHECK-NEXT:  %t1 = bitcast <1 x i64> %a to <2 x i32>
+; CHECK-NEXT:  %t2 = xor <2 x i32> %t1, <i32 1, i32 2>
+; CHECK-NEXT:  ret <2 x i32> %t2
+}
+
+; Verify that 'and' of integer and constant is done as a vector bitwise op before the bitcast.
+
+define i64 @and_bitcast_vec_to_int(<2 x i32> %a) {
+  %t1 = bitcast <2 x i32> %a to i64
+  %t2 = and i64 %t1, 3
+  ret i64 %t2
+
+; CHECK-LABEL: @and_bitcast_vec_to_int(
+; CHECK-NEXT:  %t1 = bitcast <2 x i32> %a to i64
+; CHECK-NEXT:  %t2 = and i64 %t1, 3
+; CHECK-NEXT:  ret i64 %t2
+}
+
+; Verify that 'or' of vector and constant is done as an integer bitwise op before the bitcast.
+
+define <2 x i32> @or_bitcast_int_to_vec(i64 %a) {
+  %t1 = bitcast i64 %a to <2 x i32>
+  %t2 = or <2 x i32> %t1, <i32 1, i32 2>
+  ret <2 x i32> %t2
+
+; CHECK-LABEL: @or_bitcast_int_to_vec(
+; CHECK-NEXT:  %t1 = bitcast i64 %a to <2 x i32>
+; CHECK-NEXT:  %t2 = or <2 x i32> %t1, <i32 1, i32 2>
+; CHECK-NEXT:  ret <2 x i32> %t2
+}
+

Modified: llvm/trunk/test/Transforms/InstCombine/bitcast.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/bitcast.ll?rev=261799&r1=261798&r2=261799&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/bitcast.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/bitcast.ll Wed Feb 24 16:31:18 2016
@@ -30,6 +30,47 @@ define <2 x i32> @xor_two_vector_bitcast
 ; CHECK-NEXT:  ret <2 x i32> %t3
 }
 
+; FIXME: Do the logic in the original type for the following 3 tests.
+
+; Verify that 'xor' of vector and constant is done as a vector bitwise op before the bitcast.
+
+define <2 x i32> @xor_bitcast_vec_to_vec(<1 x i64> %a) {
+  %t1 = bitcast <1 x i64> %a to <2 x i32>
+  %t2 = xor <2 x i32> <i32 1, i32 2>, %t1
+  ret <2 x i32> %t2
+
+; CHECK-LABEL: @xor_bitcast_vec_to_vec(
+; CHECK-NEXT:  %t1 = bitcast <1 x i64> %a to <2 x i32>
+; CHECK-NEXT:  %t2 = xor <2 x i32> %t1, <i32 1, i32 2>
+; CHECK-NEXT:  ret <2 x i32> %t2
+}
+
+; Verify that 'and' of integer and constant is done as a vector bitwise op before the bitcast.
+
+define i64 @and_bitcast_vec_to_int(<2 x i32> %a) {
+  %t1 = bitcast <2 x i32> %a to i64
+  %t2 = and i64 %t1, 3
+  ret i64 %t2
+
+; CHECK-LABEL: @and_bitcast_vec_to_int(
+; CHECK-NEXT:  %t1 = bitcast <2 x i32> %a to i64
+; CHECK-NEXT:  %t2 = and i64 %t1, 3
+; CHECK-NEXT:  ret i64 %t2
+}
+
+; Verify that 'or' of vector and constant is done as an integer bitwise op before the bitcast.
+
+define <2 x i32> @or_bitcast_int_to_vec(i64 %a) {
+  %t1 = bitcast i64 %a to <2 x i32>
+  %t2 = or <2 x i32> %t1, <i32 1, i32 2>
+  ret <2 x i32> %t2
+
+; CHECK-LABEL: @or_bitcast_int_to_vec(
+; CHECK-NEXT:  %t1 = bitcast i64 %a to <2 x i32>
+; CHECK-NEXT:  %t2 = or <2 x i32> %t1, <i32 1, i32 2>
+; CHECK-NEXT:  ret <2 x i32> %t2
+}
+
 ; Optimize bitcasts that are extracting low element of vector.  This happens
 ; because of SRoA.
 ; rdar://7892780




More information about the llvm-commits mailing list