Skip to content

Commit 78e5cf6

Browse files
committed
[InstSimplify] add test for vector select with operand replacement; NFC
We need a sibling fix to c590a98 ( https://llvm.org/PR49832 ) to avoid miscompiling.
1 parent 828ec9e commit 78e5cf6

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

llvm/test/Transforms/InstSimplify/select.ll

+16-8
Original file line numberDiff line numberDiff line change
@@ -1017,18 +1017,26 @@ define i32 @select_neutral_sub_lhs(i32 %x, i32 %y) {
10171017

10181018
define i32 @select_ctpop_zero(i32 %x) {
10191019
; CHECK-LABEL: @select_ctpop_zero(
1020-
; CHECK-NEXT: entry:
1021-
; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.ctpop.i32(i32 [[X:%.*]])
1022-
; CHECK-NEXT: ret i32 [[TMP0]]
1023-
;
1024-
entry:
1025-
%0 = icmp eq i32 %x, 0
1026-
%1 = call i32 @llvm.ctpop.i32(i32 %x)
1027-
%sel = select i1 %0, i32 0, i32 %1
1020+
; CHECK-NEXT: [[T1:%.*]] = call i32 @llvm.ctpop.i32(i32 [[X:%.*]])
1021+
; CHECK-NEXT: ret i32 [[T1]]
1022+
;
1023+
%t0 = icmp eq i32 %x, 0
1024+
%t1 = call i32 @llvm.ctpop.i32(i32 %x)
1025+
%sel = select i1 %t0, i32 0, i32 %t1
10281026
ret i32 %sel
10291027
}
10301028
declare i32 @llvm.ctpop.i32(i32)
10311029

1030+
define <2 x i32> @vec_select_no_equivalence(<2 x i32> %x, <2 x i32> %y) {
1031+
; CHECK-LABEL: @vec_select_no_equivalence(
1032+
; CHECK-NEXT: ret <2 x i32> zeroinitializer
1033+
;
1034+
%x10 = shufflevector <2 x i32> %x, <2 x i32> undef, <2 x i32> <i32 1, i32 0>
1035+
%cond = icmp eq <2 x i32> %x, zeroinitializer
1036+
%s = select <2 x i1> %cond, <2 x i32> %x10, <2 x i32> zeroinitializer
1037+
ret <2 x i32> %s
1038+
}
1039+
10321040
; TODO: these can be optimized more
10331041

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

0 commit comments

Comments
 (0)