[InstCombine] adjust/add tests for cmp-of-signbits; NFC
authorSanjay Patel <spatel@rotateright.com>
Tue, 24 Jan 2023 12:55:27 +0000 (07:55 -0500)
committerSanjay Patel <spatel@rotateright.com>
Tue, 24 Jan 2023 13:47:40 +0000 (08:47 -0500)
These were added with e76c95fb40b1081438 with the
right test names, but the predicates weren't updated
to match.

llvm/test/Transforms/InstCombine/icmp-shr.ll

index 340568b..2b775bd 100644 (file)
@@ -1337,13 +1337,13 @@ define <2 x i1> @same_signbit(<2 x i8> %x, <2 x i8> %y) {
 ; CHECK-NEXT:    [[XSIGN:%.*]] = lshr <2 x i8> [[X:%.*]], <i8 7, i8 7>
 ; CHECK-NEXT:    [[YPOS:%.*]] = icmp sgt <2 x i8> [[Y:%.*]], <i8 -1, i8 -1>
 ; CHECK-NEXT:    [[YPOSZ:%.*]] = zext <2 x i1> [[YPOS]] to <2 x i8>
-; CHECK-NEXT:    [[R:%.*]] = icmp eq <2 x i8> [[XSIGN]], [[YPOSZ]]
+; CHECK-NEXT:    [[R:%.*]] = icmp ne <2 x i8> [[XSIGN]], [[YPOSZ]]
 ; CHECK-NEXT:    ret <2 x i1> [[R]]
 ;
   %xsign = lshr <2 x i8> %x, <i8 7, i8 7>
   %ypos = icmp sgt <2 x i8> %y, <i8 -1, i8 -1>
   %yposz = zext <2 x i1> %ypos to <2 x i8>
-  %r = icmp eq <2 x i8> %xsign, %yposz
+  %r = icmp ne <2 x i8> %xsign, %yposz
   ret <2 x i1> %r
 }
 
@@ -1353,14 +1353,14 @@ define i1 @same_signbit_use2(i8 %x, i8 %y) {
 ; CHECK-NEXT:    [[YPOS:%.*]] = icmp sgt i8 [[Y:%.*]], -1
 ; CHECK-NEXT:    [[YPOSZ:%.*]] = zext i1 [[YPOS]] to i8
 ; CHECK-NEXT:    call void @use(i8 [[YPOSZ]])
-; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[XSIGN]], [[YPOSZ]]
+; CHECK-NEXT:    [[R:%.*]] = icmp ne i8 [[XSIGN]], [[YPOSZ]]
 ; CHECK-NEXT:    ret i1 [[R]]
 ;
   %xsign = lshr i8 %x, 7
   %ypos = icmp sgt i8 %y, -1
   %yposz = zext i1 %ypos to i8
   call void @use(i8 %yposz)
-  %r = icmp eq i8 %xsign, %yposz
+  %r = icmp ne i8 %xsign, %yposz
   ret i1 %r
 }
 
@@ -1371,7 +1371,7 @@ define i1 @same_signbit_use3(i8 %x, i8 %y) {
 ; CHECK-NEXT:    [[YPOS:%.*]] = icmp sgt i8 [[Y:%.*]], -1
 ; CHECK-NEXT:    [[YPOSZ:%.*]] = zext i1 [[YPOS]] to i8
 ; CHECK-NEXT:    call void @use(i8 [[YPOSZ]])
-; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[XSIGN]], [[YPOSZ]]
+; CHECK-NEXT:    [[R:%.*]] = icmp ne i8 [[XSIGN]], [[YPOSZ]]
 ; CHECK-NEXT:    ret i1 [[R]]
 ;
   %xsign = lshr i8 %x, 7
@@ -1379,10 +1379,39 @@ define i1 @same_signbit_use3(i8 %x, i8 %y) {
   %ypos = icmp sgt i8 %y, -1
   %yposz = zext i1 %ypos to i8
   call void @use(i8 %yposz)
-  %r = icmp eq i8 %xsign, %yposz
+  %r = icmp ne i8 %xsign, %yposz
   ret i1 %r
 }
 
+define <2 x i1> @same_signbit_poison_elts(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: @same_signbit_poison_elts(
+; CHECK-NEXT:    [[XSIGN:%.*]] = lshr <2 x i8> [[X:%.*]], <i8 7, i8 poison>
+; CHECK-NEXT:    [[YPOS:%.*]] = icmp sgt <2 x i8> [[Y:%.*]], <i8 -1, i8 poison>
+; CHECK-NEXT:    [[YPOSZ:%.*]] = zext <2 x i1> [[YPOS]] to <2 x i8>
+; CHECK-NEXT:    [[R:%.*]] = icmp ne <2 x i8> [[XSIGN]], [[YPOSZ]]
+; CHECK-NEXT:    ret <2 x i1> [[R]]
+;
+  %xsign = lshr <2 x i8> %x, <i8 7, i8 poison>
+  %ypos = icmp sgt <2 x i8> %y, <i8 -1, i8 poison>
+  %yposz = zext <2 x i1> %ypos to <2 x i8>
+  %r = icmp ne <2 x i8> %xsign, %yposz
+  ret <2 x i1> %r
+}
+
+define i1 @same_signbit_wrong_type(i8 %x, i32 %y) {
+; CHECK-LABEL: @same_signbit_wrong_type(
+; CHECK-NEXT:    [[XSIGN:%.*]] = lshr i8 [[X:%.*]], 7
+; CHECK-NEXT:    [[YPOS:%.*]] = icmp sgt i32 [[Y:%.*]], -1
+; CHECK-NEXT:    [[YPOSZ:%.*]] = zext i1 [[YPOS]] to i8
+; CHECK-NEXT:    [[R:%.*]] = icmp ne i8 [[XSIGN]], [[YPOSZ]]
+; CHECK-NEXT:    ret i1 [[R]]
+;
+  %xsign = lshr i8 %x, 7
+  %ypos = icmp sgt i32 %y, -1
+  %yposz = zext i1 %ypos to i8
+  %r = icmp ne i8 %xsign, %yposz
+  ret i1 %r
+}
 define i1 @exactly_one_set_signbit_wrong_shamt(i8 %x, i8 %y) {
 ; CHECK-LABEL: @exactly_one_set_signbit_wrong_shamt(
 ; CHECK-NEXT:    [[XSIGN:%.*]] = lshr i8 [[X:%.*]], 6