From: Sanjay Patel Date: Mon, 5 Apr 2021 16:03:50 +0000 (-0400) Subject: [InstCombine] add test for miscompile from select value equivalence; NFC X-Git-Tag: llvmorg-14-init~10449 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c0b0da4684908b8e8143c0762fc766c1a2a5849f;p=platform%2Fupstream%2Fllvm.git [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. --- diff --git a/llvm/test/Transforms/InstCombine/select-binop-cmp.ll b/llvm/test/Transforms/InstCombine/select-binop-cmp.ll index bbf7456..beea286 100644 --- a/llvm/test/Transforms/InstCombine/select-binop-cmp.ll +++ b/llvm/test/Transforms/InstCombine/select-binop-cmp.ll @@ -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:%.*]], @@ -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> + %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(