diff --git a/llvm/test/Transforms/InstCombine/icmp-shr.ll b/llvm/test/Transforms/InstCombine/icmp-shr.ll index 340568bafa8ef7..2b775bd3652705 100644 --- a/llvm/test/Transforms/InstCombine/icmp-shr.ll +++ b/llvm/test/Transforms/InstCombine/icmp-shr.ll @@ -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:%.*]], ; CHECK-NEXT: [[YPOS:%.*]] = icmp sgt <2 x i8> [[Y:%.*]], ; 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, %ypos = icmp sgt <2 x i8> %y, %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:%.*]], +; CHECK-NEXT: [[YPOS:%.*]] = icmp sgt <2 x i8> [[Y:%.*]], +; 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, + %ypos = icmp sgt <2 x i8> %y, + %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