[InstCombine] add test for potentially missing vector icmp fold
authorSanjay Patel <spatel@rotateright.com>
Sun, 14 Aug 2016 22:30:07 +0000 (22:30 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sun, 14 Aug 2016 22:30:07 +0000 (22:30 +0000)
llvm-svn: 278636

llvm/test/Transforms/InstCombine/cast.ll

index 7b3c314..8a89bb2 100644 (file)
@@ -350,12 +350,27 @@ define i1 @test31(i64 %A) {
 ; CHECK-NEXT:    [[D:%.*]] = icmp eq i64 [[C]], 10
 ; CHECK-NEXT:    ret i1 [[D]]
 ;
-  %B = trunc i64 %A to i32                ; <i32> [#uses=1]
-  %C = and i32 %B, 42             ; <i32> [#uses=1]
-  %D = icmp eq i32 %C, 10         ; <i1> [#uses=1]
+  %B = trunc i64 %A to i32
+  %C = and i32 %B, 42
+  %D = icmp eq i32 %C, 10
   ret i1 %D
 }
 
+; FIXME: Vectors should fold too...or not? 
+; Does this depend on the whether the source/dest types of the trunc are legal in the data layout?
+define <2 x i1> @test31vec(<2 x i64> %A) {
+; CHECK-LABEL: @test31vec(
+; CHECK-NEXT:    [[B:%.*]] = trunc <2 x i64> %A to <2 x i32>
+; CHECK-NEXT:    [[C:%.*]] = and <2 x i32> [[B]], <i32 42, i32 42>
+; CHECK-NEXT:    [[D:%.*]] = icmp eq <2 x i32> [[C]], <i32 10, i32 10>
+; CHECK-NEXT:    ret <2 x i1> [[D]]
+;
+  %B = trunc <2 x i64> %A to <2 x i32>
+  %C = and <2 x i32> %B, <i32 42, i32 42>
+  %D = icmp eq <2 x i32> %C, <i32 10, i32 10>
+  ret <2 x i1> %D
+}
+
 define i32 @test33(i32 %c1) {
 ; CHECK-LABEL: @test33(
 ; CHECK-NEXT:    ret i32 %c1