Skip to content

Commit 266c82f

Browse files
rotaterighttstellar
authored andcommitted
[InstSimplify] add test for vector select with operand replacement; NFC
We need a sibling fix to c590a98 ( https://llvm.org/PR49832 ) to avoid miscompiling. (cherry picked from commit 78e5cf6)
1 parent 4a12f51 commit 266c82f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

llvm/test/Transforms/InstSimplify/select.ll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,28 @@ define <vscale x 2 x i1> @ignore_scalable_undef(<vscale x 2 x i1> %cond) {
969969
ret <vscale x 2 x i1> %s
970970
}
971971

972+
define i32 @select_ctpop_zero(i32 %x) {
973+
; CHECK-LABEL: @select_ctpop_zero(
974+
; CHECK-NEXT: [[T1:%.*]] = call i32 @llvm.ctpop.i32(i32 [[X:%.*]])
975+
; CHECK-NEXT: ret i32 [[T1]]
976+
;
977+
%t0 = icmp eq i32 %x, 0
978+
%t1 = call i32 @llvm.ctpop.i32(i32 %x)
979+
%sel = select i1 %t0, i32 0, i32 %t1
980+
ret i32 %sel
981+
}
982+
declare i32 @llvm.ctpop.i32(i32)
983+
984+
define <2 x i32> @vec_select_no_equivalence(<2 x i32> %x, <2 x i32> %y) {
985+
; CHECK-LABEL: @vec_select_no_equivalence(
986+
; CHECK-NEXT: ret <2 x i32> zeroinitializer
987+
;
988+
%x10 = shufflevector <2 x i32> %x, <2 x i32> undef, <2 x i32> <i32 1, i32 0>
989+
%cond = icmp eq <2 x i32> %x, zeroinitializer
990+
%s = select <2 x i1> %cond, <2 x i32> %x10, <2 x i32> zeroinitializer
991+
ret <2 x i32> %s
992+
}
993+
972994
; TODO: these can be optimized more
973995

974996
define i32 @poison(i32 %x, i32 %y) {

0 commit comments

Comments
 (0)