Skip to content

Commit c0b0da4

Browse files
committed
[InstCombine] add test for miscompile from select value equivalence; NFC
The new test is reduced from: https://llvm.org/PR49832 ...but we already show a potential miscompile in the existing test too.
1 parent 62a94b7 commit c0b0da4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

llvm/test/Transforms/InstCombine/select-binop-cmp.ll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ define i32 @select_xor_icmp_bad_6(i32 %x, i32 %y, i32 %z) {
551551
ret i32 %C
552552
}
553553

554+
; FIXME: Value equivalence substitution is all-or-nothing, so needs a scalar compare.
555+
554556
define <2 x i8> @select_xor_icmp_vec_bad(<2 x i8> %x, <2 x i8> %y, <2 x i8> %z) {
555557
; CHECK-LABEL: @select_xor_icmp_vec_bad(
556558
; CHECK-NEXT: [[A:%.*]] = icmp eq <2 x i8> [[X:%.*]], <i8 5, i8 3>
@@ -564,6 +566,18 @@ define <2 x i8> @select_xor_icmp_vec_bad(<2 x i8> %x, <2 x i8> %y, <2 x i8> %z)
564566
ret <2 x i8> %C
565567
}
566568

569+
; FIXME: Value equivalence substitution is all-or-nothing, so needs a scalar compare.
570+
571+
define <2 x i32> @vec_select_no_equivalence(<2 x i32> %x) {
572+
; CHECK-LABEL: @vec_select_no_equivalence(
573+
; CHECK-NEXT: ret <2 x i32> [[X:%.*]]
574+
;
575+
%x10 = shufflevector <2 x i32> %x, <2 x i32> undef, <2 x i32> <i32 1, i32 0>
576+
%cond = icmp eq <2 x i32> %x, zeroinitializer
577+
%s = select <2 x i1> %cond, <2 x i32> %x10, <2 x i32> %x
578+
ret <2 x i32> %s
579+
}
580+
567581
; Folding this would only be legal if we sanitized undef to 0.
568582
define <2 x i8> @select_xor_icmp_vec_undef(<2 x i8> %x, <2 x i8> %y, <2 x i8> %z) {
569583
; CHECK-LABEL: @select_xor_icmp_vec_undef(

0 commit comments

Comments
 (0)