[InstSimplify] add test for vector select with operand replacement; NFC
authorSanjay Patel <spatel@rotateright.com>
Mon, 5 Apr 2021 20:11:39 +0000 (16:11 -0400)
committerSanjay Patel <spatel@rotateright.com>
Mon, 5 Apr 2021 20:52:34 +0000 (16:52 -0400)
We need a sibling fix to c590a9880d7a
( https://llvm.org/PR49832 ) to avoid miscompiling.

llvm/test/Transforms/InstSimplify/select.ll

index f106b90..00cb5c1 100644 (file)
@@ -1017,18 +1017,26 @@ define i32 @select_neutral_sub_lhs(i32 %x, i32 %y) {
 
 define i32 @select_ctpop_zero(i32 %x) {
 ; CHECK-LABEL: @select_ctpop_zero(
-; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[TMP0:%.*]] = call i32 @llvm.ctpop.i32(i32 [[X:%.*]])
-; CHECK-NEXT:    ret i32 [[TMP0]]
-;
-entry:
-  %0 = icmp eq i32 %x, 0
-  %1 = call i32 @llvm.ctpop.i32(i32 %x)
-  %sel = select i1 %0, i32 0, i32 %1
+; CHECK-NEXT:    [[T1:%.*]] = call i32 @llvm.ctpop.i32(i32 [[X:%.*]])
+; CHECK-NEXT:    ret i32 [[T1]]
+;
+  %t0 = icmp eq i32 %x, 0
+  %t1 = call i32 @llvm.ctpop.i32(i32 %x)
+  %sel = select i1 %t0, i32 0, i32 %t1
   ret i32 %sel
 }
 declare i32 @llvm.ctpop.i32(i32)
 
+define <2 x i32> @vec_select_no_equivalence(<2 x i32> %x, <2 x i32> %y) {
+; CHECK-LABEL: @vec_select_no_equivalence(
+; CHECK-NEXT:    ret <2 x i32> zeroinitializer
+;
+  %x10 = shufflevector <2 x i32> %x, <2 x i32> undef, <2 x i32> <i32 1, i32 0>
+  %cond = icmp eq <2 x i32> %x, zeroinitializer
+  %s = select <2 x i1> %cond, <2 x i32> %x10, <2 x i32> zeroinitializer
+  ret <2 x i32> %s
+}
+
 ; TODO: these can be optimized more
 
 define i32 @poison(i32 %x, i32 %y) {