Skip to content

Commit

Permalink
[InstCombine] add test for miscompile from select value equivalence; NFC
Browse files Browse the repository at this point in the history
The new test is reduced from:
https://llvm.org/PR49832
...but we already show a potential miscompile in the existing test too.

(cherry picked from commit c0b0da4)
  • Loading branch information
rotateright authored and tstellar committed May 7, 2021
1 parent 225b775 commit c89d500
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions llvm/test/Transforms/InstCombine/select-binop-cmp.ll
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@ define i32 @select_xor_icmp_bad_6(i32 %x, i32 %y, i32 %z) {
ret i32 %C
}

; FIXME: Value equivalence substitution is all-or-nothing, so needs a scalar compare.

define <2 x i8> @select_xor_icmp_vec_bad(<2 x i8> %x, <2 x i8> %y, <2 x i8> %z) {
; CHECK-LABEL: @select_xor_icmp_vec_bad(
; CHECK-NEXT: [[A:%.*]] = icmp eq <2 x i8> [[X:%.*]], <i8 5, i8 3>
Expand All @@ -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)
ret <2 x i8> %C
}

; FIXME: Value equivalence substitution is all-or-nothing, so needs a scalar compare.

define <2 x i32> @vec_select_no_equivalence(<2 x i32> %x) {
; CHECK-LABEL: @vec_select_no_equivalence(
; CHECK-NEXT: ret <2 x i32> [[X:%.*]]
;
%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> %x
ret <2 x i32> %s
}

; Folding this would only be legal if we sanitized undef to 0.
define <2 x i8> @select_xor_icmp_vec_undef(<2 x i8> %x, <2 x i8> %y, <2 x i8> %z) {
; CHECK-LABEL: @select_xor_icmp_vec_undef(
Expand Down

0 comments on commit c89d500

Please sign in to comment.