Revert rL333106 / D46814: [InstCombine] Fold unfolded masked merge pattern with variable mask!

In post-commit review, Eric Christopher notes that many
new MSan warnings are being observed with this patch.

The probable reason is: if 'y' is undef here and we could
evaluate it twice and get different results.
We can't increase the number of uses of a value.

llvm-svn: 333631
This commit is contained in:
Roman Lebedev 2018-05-31 06:00:36 +00:00
parent a04841e104
commit 2fee5906e4
7 changed files with 175 additions and 168 deletions

View File

@ -748,9 +748,6 @@ static Value *foldLogOpOfMaskedICmps(ICmpInst *LHS, ICmpInst *RHS, bool IsAnd,
return nullptr;
}
static Instruction *foldMaskedMerge(BinaryOperator &I,
InstCombiner::BuilderTy &Builder);
/// Try to fold a signed range checked with lower bound 0 to an unsigned icmp.
/// Example: (icmp sge x, 0) & (icmp slt x, n) --> icmp ult x, n
/// If \p Inverted is true then the check is for the inverted range, e.g.
@ -1651,9 +1648,6 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
A->getType()->isIntOrIntVectorTy(1))
return SelectInst::Create(A, Op0, Constant::getNullValue(I.getType()));
if (Instruction *MM = foldMaskedMerge(I, Builder))
return MM;
return Changed ? &I : nullptr;
}
@ -2293,9 +2287,6 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
}
}
if (Instruction *MM = foldMaskedMerge(I, Builder))
return MM;
return Changed ? &I : nullptr;
}
@ -2431,33 +2422,6 @@ Value *InstCombiner::foldXorOfICmps(ICmpInst *LHS, ICmpInst *RHS) {
return nullptr;
}
/// Bitwise masked merge (bitwise select) is typically coded as:
/// (x & m) | (y & ~m)
/// Another variant is:
/// (x | ~m) & (y | m)
/// Canonicalize those to a form with one less IR instruction:
/// ((x ^ y) & m) ^ y
static Instruction *foldMaskedMerge(BinaryOperator &I,
InstCombiner::BuilderTy &Builder) {
Value *X, *Y;
Value *M;
if (match(&I, m_c_Or(m_OneUse(m_c_And(m_Value(Y), m_Not(m_Value(M)))),
m_OneUse(m_c_And(m_Value(X), m_Deferred(M))))) ||
match(&I, m_c_And(m_OneUse(m_c_Or(m_Value(X), m_Not(m_Value(M)))),
m_OneUse(m_c_Or(m_Value(Y), m_Deferred(M)))))) {
assert(!isa<Constant>(M) && "Shouldn't have matched a constant.");
Value *D = Builder.CreateXor(X, Y);
Value *A = Builder.CreateAnd(D, M);
return BinaryOperator::CreateXor(A, Y);
}
// FIXME: we still want to canonicalize the patterns with constants somewhat.
return nullptr;
}
/// If we have a masked merge, in the canonical form of:
/// (assuming that A only has one use.)
/// | A | |B|

View File

@ -502,10 +502,11 @@ define i32 @xor_to_xor12(float %fa, float %fb) {
define i64 @PR32830(i64 %a, i64 %b, i64 %c) {
; CHECK-LABEL: @PR32830(
; CHECK-NEXT: [[NOTA:%.*]] = xor i64 [[A:%.*]], -1
; CHECK-NEXT: [[NOTB:%.*]] = xor i64 [[B:%.*]], -1
; CHECK-NEXT: [[TMP1:%.*]] = xor i64 [[NOTB]], [[C:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i64 [[TMP1]], [[A:%.*]]
; CHECK-NEXT: [[AND:%.*]] = xor i64 [[TMP2]], [[NOTB]]
; CHECK-NEXT: [[OR1:%.*]] = or i64 [[NOTB]], [[A]]
; CHECK-NEXT: [[OR2:%.*]] = or i64 [[NOTA]], [[C:%.*]]
; CHECK-NEXT: [[AND:%.*]] = and i64 [[OR1]], [[OR2]]
; CHECK-NEXT: ret i64 [[AND]]
;
%nota = xor i64 %a, -1

View File

@ -18,9 +18,10 @@
define i32 @p(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND]], [[AND1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%and = and i32 %x, %m
@ -32,9 +33,10 @@ define i32 @p(i32 %x, i32 %y, i32 %m) {
define <2 x i32> @p_splatvec(<2 x i32> %x, <2 x i32> %y, <2 x i32> %m) {
; CHECK-LABEL: @p_splatvec(
; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i32> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and <2 x i32> [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor <2 x i32> [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor <2 x i32> [[M]], <i32 -1, i32 -1>
; CHECK-NEXT: [[AND1:%.*]] = and <2 x i32> [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or <2 x i32> [[AND]], [[AND1]]
; CHECK-NEXT: ret <2 x i32> [[RET]]
;
%and = and <2 x i32> %x, %m
@ -46,9 +48,10 @@ define <2 x i32> @p_splatvec(<2 x i32> %x, <2 x i32> %y, <2 x i32> %m) {
define <3 x i32> @p_vec_undef(<3 x i32> %x, <3 x i32> %y, <3 x i32> %m) {
; CHECK-LABEL: @p_vec_undef(
; CHECK-NEXT: [[TMP1:%.*]] = xor <3 x i32> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and <3 x i32> [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor <3 x i32> [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and <3 x i32> [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor <3 x i32> [[M]], <i32 -1, i32 undef, i32 -1>
; CHECK-NEXT: [[AND1:%.*]] = and <3 x i32> [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or <3 x i32> [[AND]], [[AND1]]
; CHECK-NEXT: ret <3 x i32> [[RET]]
;
%and = and <3 x i32> %x, %m
@ -179,9 +182,10 @@ declare i32 @gen32()
define i32 @p_commutative0(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p_commutative0(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND]], [[AND1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%and = and i32 %m, %x ; swapped order
@ -194,9 +198,10 @@ define i32 @p_commutative0(i32 %x, i32 %y, i32 %m) {
define i32 @p_commutative1(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative1(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y]], [[NEG]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND]], [[AND1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()
@ -209,9 +214,10 @@ define i32 @p_commutative1(i32 %x, i32 %m) {
define i32 @p_commutative2(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p_commutative2(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND1]], [[AND]]
; CHECK-NEXT: ret i32 [[RET]]
;
%and = and i32 %x, %m
@ -224,9 +230,10 @@ define i32 @p_commutative2(i32 %x, i32 %y, i32 %m) {
define i32 @p_commutative3(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative3(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y]], [[NEG]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND]], [[AND1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()
@ -239,9 +246,10 @@ define i32 @p_commutative3(i32 %x, i32 %m) {
define i32 @p_commutative4(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p_commutative4(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND1]], [[AND]]
; CHECK-NEXT: ret i32 [[RET]]
;
%and = and i32 %m, %x ; swapped order
@ -254,9 +262,10 @@ define i32 @p_commutative4(i32 %x, i32 %y, i32 %m) {
define i32 @p_commutative5(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative5(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y]], [[NEG]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND1]], [[AND]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()
@ -270,9 +279,10 @@ define i32 @p_commutative5(i32 %x, i32 %m) {
define i32 @p_commutative6(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative6(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y]], [[NEG]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND1]], [[AND]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()

View File

@ -16,9 +16,10 @@
define i32 @p(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M:%.*]], -1
; CHECK-NEXT: [[OR:%.*]] = or i32 [[NEG]], [[X:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[Y:%.*]], [[M]]
; CHECK-NEXT: [[RET:%.*]] = and i32 [[OR]], [[OR1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%neg = xor i32 %m, -1
@ -30,9 +31,10 @@ define i32 @p(i32 %x, i32 %y, i32 %m) {
define <2 x i32> @p_splatvec(<2 x i32> %x, <2 x i32> %y, <2 x i32> %m) {
; CHECK-LABEL: @p_splatvec(
; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i32> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and <2 x i32> [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor <2 x i32> [[TMP2]], [[Y]]
; CHECK-NEXT: [[NEG:%.*]] = xor <2 x i32> [[M:%.*]], <i32 -1, i32 -1>
; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[NEG]], [[X:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or <2 x i32> [[Y:%.*]], [[M]]
; CHECK-NEXT: [[RET:%.*]] = and <2 x i32> [[OR]], [[OR1]]
; CHECK-NEXT: ret <2 x i32> [[RET]]
;
%neg = xor <2 x i32> %m, <i32 -1, i32 -1>
@ -44,9 +46,10 @@ define <2 x i32> @p_splatvec(<2 x i32> %x, <2 x i32> %y, <2 x i32> %m) {
define <3 x i32> @p_vec_undef(<3 x i32> %x, <3 x i32> %y, <3 x i32> %m) {
; CHECK-LABEL: @p_vec_undef(
; CHECK-NEXT: [[TMP1:%.*]] = xor <3 x i32> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and <3 x i32> [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor <3 x i32> [[TMP2]], [[Y]]
; CHECK-NEXT: [[NEG:%.*]] = xor <3 x i32> [[M:%.*]], <i32 -1, i32 undef, i32 -1>
; CHECK-NEXT: [[OR:%.*]] = or <3 x i32> [[NEG]], [[X:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or <3 x i32> [[Y:%.*]], [[M]]
; CHECK-NEXT: [[RET:%.*]] = and <3 x i32> [[OR]], [[OR1]]
; CHECK-NEXT: ret <3 x i32> [[RET]]
;
%neg = xor <3 x i32> %m, <i32 -1, i32 undef, i32 -1>
@ -121,9 +124,10 @@ declare i32 @gen32()
define i32 @p_commutative0(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p_commutative0(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M:%.*]], -1
; CHECK-NEXT: [[OR:%.*]] = or i32 [[NEG]], [[X:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[Y:%.*]], [[M]]
; CHECK-NEXT: [[RET:%.*]] = and i32 [[OR]], [[OR1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%neg = xor i32 %m, -1
@ -136,9 +140,10 @@ define i32 @p_commutative0(i32 %x, i32 %y, i32 %m) {
define i32 @p_commutative1(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative1(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M:%.*]], -1
; CHECK-NEXT: [[OR:%.*]] = or i32 [[NEG]], [[X:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[Y]], [[M]]
; CHECK-NEXT: [[RET:%.*]] = and i32 [[OR]], [[OR1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()
@ -151,9 +156,10 @@ define i32 @p_commutative1(i32 %x, i32 %m) {
define i32 @p_commutative2(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p_commutative2(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M:%.*]], -1
; CHECK-NEXT: [[OR:%.*]] = or i32 [[NEG]], [[X:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[Y:%.*]], [[M]]
; CHECK-NEXT: [[RET:%.*]] = and i32 [[OR1]], [[OR]]
; CHECK-NEXT: ret i32 [[RET]]
;
%neg = xor i32 %m, -1
@ -166,9 +172,10 @@ define i32 @p_commutative2(i32 %x, i32 %y, i32 %m) {
define i32 @p_commutative3(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative3(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M:%.*]], -1
; CHECK-NEXT: [[OR:%.*]] = or i32 [[NEG]], [[X:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[Y]], [[M]]
; CHECK-NEXT: [[RET:%.*]] = and i32 [[OR]], [[OR1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()
@ -181,9 +188,10 @@ define i32 @p_commutative3(i32 %x, i32 %m) {
define i32 @p_commutative4(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p_commutative4(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M:%.*]], -1
; CHECK-NEXT: [[OR:%.*]] = or i32 [[NEG]], [[X:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[Y:%.*]], [[M]]
; CHECK-NEXT: [[RET:%.*]] = and i32 [[OR1]], [[OR]]
; CHECK-NEXT: ret i32 [[RET]]
;
%neg = xor i32 %m, -1
@ -196,9 +204,10 @@ define i32 @p_commutative4(i32 %x, i32 %y, i32 %m) {
define i32 @p_commutative5(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative5(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M:%.*]], -1
; CHECK-NEXT: [[OR:%.*]] = or i32 [[NEG]], [[X:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[Y]], [[M]]
; CHECK-NEXT: [[RET:%.*]] = and i32 [[OR1]], [[OR]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()
@ -212,9 +221,10 @@ define i32 @p_commutative5(i32 %x, i32 %m) {
define i32 @p_commutative6(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative6(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M:%.*]], -1
; CHECK-NEXT: [[OR:%.*]] = or i32 [[NEG]], [[X:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[Y]], [[M]]
; CHECK-NEXT: [[RET:%.*]] = and i32 [[OR1]], [[OR]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()
@ -249,9 +259,9 @@ declare void @use32(i32)
define i32 @n0_oneuse_of_neg_is_ok_0(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @n0_oneuse_of_neg_is_ok_0(
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M:%.*]], -1
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[OR:%.*]] = or i32 [[NEG]], [[X:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[Y:%.*]], [[M]]
; CHECK-NEXT: [[RET:%.*]] = and i32 [[OR]], [[OR1]]
; CHECK-NEXT: call void @use32(i32 [[NEG]])
; CHECK-NEXT: ret i32 [[RET]]
;

View File

@ -18,9 +18,10 @@
define i32 @p(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND]], [[AND1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%and = and i32 %x, %m
@ -32,9 +33,10 @@ define i32 @p(i32 %x, i32 %y, i32 %m) {
define <2 x i32> @p_splatvec(<2 x i32> %x, <2 x i32> %y, <2 x i32> %m) {
; CHECK-LABEL: @p_splatvec(
; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i32> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and <2 x i32> [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor <2 x i32> [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor <2 x i32> [[M]], <i32 -1, i32 -1>
; CHECK-NEXT: [[AND1:%.*]] = and <2 x i32> [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or <2 x i32> [[AND]], [[AND1]]
; CHECK-NEXT: ret <2 x i32> [[RET]]
;
%and = and <2 x i32> %x, %m
@ -46,9 +48,10 @@ define <2 x i32> @p_splatvec(<2 x i32> %x, <2 x i32> %y, <2 x i32> %m) {
define <3 x i32> @p_vec_undef(<3 x i32> %x, <3 x i32> %y, <3 x i32> %m) {
; CHECK-LABEL: @p_vec_undef(
; CHECK-NEXT: [[TMP1:%.*]] = xor <3 x i32> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and <3 x i32> [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor <3 x i32> [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and <3 x i32> [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor <3 x i32> [[M]], <i32 -1, i32 undef, i32 -1>
; CHECK-NEXT: [[AND1:%.*]] = and <3 x i32> [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or <3 x i32> [[AND]], [[AND1]]
; CHECK-NEXT: ret <3 x i32> [[RET]]
;
%and = and <3 x i32> %x, %m
@ -179,9 +182,10 @@ declare i32 @gen32()
define i32 @p_commutative0(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p_commutative0(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND]], [[AND1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%and = and i32 %m, %x ; swapped order
@ -194,9 +198,10 @@ define i32 @p_commutative0(i32 %x, i32 %y, i32 %m) {
define i32 @p_commutative1(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative1(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y]], [[NEG]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND]], [[AND1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()
@ -209,9 +214,10 @@ define i32 @p_commutative1(i32 %x, i32 %m) {
define i32 @p_commutative2(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p_commutative2(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND1]], [[AND]]
; CHECK-NEXT: ret i32 [[RET]]
;
%and = and i32 %x, %m
@ -224,9 +230,10 @@ define i32 @p_commutative2(i32 %x, i32 %y, i32 %m) {
define i32 @p_commutative3(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative3(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y]], [[NEG]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND]], [[AND1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()
@ -239,9 +246,10 @@ define i32 @p_commutative3(i32 %x, i32 %m) {
define i32 @p_commutative4(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p_commutative4(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND1]], [[AND]]
; CHECK-NEXT: ret i32 [[RET]]
;
%and = and i32 %m, %x ; swapped order
@ -254,9 +262,10 @@ define i32 @p_commutative4(i32 %x, i32 %y, i32 %m) {
define i32 @p_commutative5(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative5(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y]], [[NEG]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND1]], [[AND]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()
@ -270,9 +279,10 @@ define i32 @p_commutative5(i32 %x, i32 %m) {
define i32 @p_commutative6(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative6(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y]], [[NEG]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND1]], [[AND]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()

View File

@ -18,9 +18,10 @@
define i32 @p(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND]], [[AND1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%and = and i32 %x, %m
@ -32,9 +33,10 @@ define i32 @p(i32 %x, i32 %y, i32 %m) {
define <2 x i32> @p_splatvec(<2 x i32> %x, <2 x i32> %y, <2 x i32> %m) {
; CHECK-LABEL: @p_splatvec(
; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i32> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and <2 x i32> [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor <2 x i32> [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor <2 x i32> [[M]], <i32 -1, i32 -1>
; CHECK-NEXT: [[AND1:%.*]] = and <2 x i32> [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or <2 x i32> [[AND]], [[AND1]]
; CHECK-NEXT: ret <2 x i32> [[RET]]
;
%and = and <2 x i32> %x, %m
@ -46,9 +48,10 @@ define <2 x i32> @p_splatvec(<2 x i32> %x, <2 x i32> %y, <2 x i32> %m) {
define <3 x i32> @p_vec_undef(<3 x i32> %x, <3 x i32> %y, <3 x i32> %m) {
; CHECK-LABEL: @p_vec_undef(
; CHECK-NEXT: [[TMP1:%.*]] = xor <3 x i32> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and <3 x i32> [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor <3 x i32> [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and <3 x i32> [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor <3 x i32> [[M]], <i32 -1, i32 undef, i32 -1>
; CHECK-NEXT: [[AND1:%.*]] = and <3 x i32> [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or <3 x i32> [[AND]], [[AND1]]
; CHECK-NEXT: ret <3 x i32> [[RET]]
;
%and = and <3 x i32> %x, %m
@ -179,9 +182,10 @@ declare i32 @gen32()
define i32 @p_commutative0(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p_commutative0(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND]], [[AND1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%and = and i32 %m, %x ; swapped order
@ -194,9 +198,10 @@ define i32 @p_commutative0(i32 %x, i32 %y, i32 %m) {
define i32 @p_commutative1(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative1(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y]], [[NEG]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND]], [[AND1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()
@ -209,9 +214,10 @@ define i32 @p_commutative1(i32 %x, i32 %m) {
define i32 @p_commutative2(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p_commutative2(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND1]], [[AND]]
; CHECK-NEXT: ret i32 [[RET]]
;
%and = and i32 %x, %m
@ -224,9 +230,10 @@ define i32 @p_commutative2(i32 %x, i32 %y, i32 %m) {
define i32 @p_commutative3(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative3(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y]], [[NEG]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND]], [[AND1]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()
@ -239,9 +246,10 @@ define i32 @p_commutative3(i32 %x, i32 %m) {
define i32 @p_commutative4(i32 %x, i32 %y, i32 %m) {
; CHECK-LABEL: @p_commutative4(
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG]], [[Y:%.*]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND1]], [[AND]]
; CHECK-NEXT: ret i32 [[RET]]
;
%and = and i32 %m, %x ; swapped order
@ -254,9 +262,10 @@ define i32 @p_commutative4(i32 %x, i32 %y, i32 %m) {
define i32 @p_commutative5(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative5(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y]], [[NEG]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND1]], [[AND]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()
@ -270,9 +279,10 @@ define i32 @p_commutative5(i32 %x, i32 %m) {
define i32 @p_commutative6(i32 %x, i32 %m) {
; CHECK-LABEL: @p_commutative6(
; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y]], [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[M:%.*]]
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[TMP2]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y]], [[NEG]]
; CHECK-NEXT: [[RET:%.*]] = or i32 [[AND1]], [[AND]]
; CHECK-NEXT: ret i32 [[RET]]
;
%y = call i32 @gen32()

View File

@ -5,9 +5,10 @@ define <4 x i32> @psignd_3(<4 x i32> %a, <4 x i32> %b) {
; CHECK-LABEL: @psignd_3(
; CHECK-NEXT: [[SUB:%.*]] = sub nsw <4 x i32> zeroinitializer, [[A:%.*]]
; CHECK-NEXT: [[B_LOBIT1:%.*]] = ashr <4 x i32> [[B:%.*]], <i32 31, i32 31, i32 31, i32 31>
; CHECK-NEXT: [[TMP1:%.*]] = xor <4 x i32> [[SUB]], [[A]]
; CHECK-NEXT: [[TMP2:%.*]] = and <4 x i32> [[TMP1]], [[B_LOBIT1]]
; CHECK-NEXT: [[COND:%.*]] = xor <4 x i32> [[TMP2]], [[A]]
; CHECK-NEXT: [[T1:%.*]] = xor <4 x i32> [[B_LOBIT1]], <i32 -1, i32 -1, i32 -1, i32 -1>
; CHECK-NEXT: [[T2:%.*]] = and <4 x i32> [[T1]], [[A]]
; CHECK-NEXT: [[T3:%.*]] = and <4 x i32> [[B_LOBIT1]], [[SUB]]
; CHECK-NEXT: [[COND:%.*]] = or <4 x i32> [[T2]], [[T3]]
; CHECK-NEXT: ret <4 x i32> [[COND]]
;
%cmp = icmp slt <4 x i32> %b, zeroinitializer
@ -26,9 +27,10 @@ define <4 x i32> @test1(<4 x i32> %a, <4 x i32> %b) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: [[SUB:%.*]] = sub nsw <4 x i32> zeroinitializer, [[A:%.*]]
; CHECK-NEXT: [[B_LOBIT1:%.*]] = ashr <4 x i32> [[B:%.*]], <i32 31, i32 31, i32 31, i32 31>
; CHECK-NEXT: [[TMP1:%.*]] = xor <4 x i32> [[SUB]], [[A]]
; CHECK-NEXT: [[TMP2:%.*]] = and <4 x i32> [[TMP1]], [[B_LOBIT1]]
; CHECK-NEXT: [[COND:%.*]] = xor <4 x i32> [[TMP2]], [[SUB]]
; CHECK-NEXT: [[B_LOBIT1_NOT:%.*]] = xor <4 x i32> [[B_LOBIT1]], <i32 -1, i32 -1, i32 -1, i32 -1>
; CHECK-NEXT: [[T2:%.*]] = and <4 x i32> [[B_LOBIT1]], [[A]]
; CHECK-NEXT: [[T3:%.*]] = and <4 x i32> [[B_LOBIT1_NOT]], [[SUB]]
; CHECK-NEXT: [[COND:%.*]] = or <4 x i32> [[T2]], [[T3]]
; CHECK-NEXT: ret <4 x i32> [[COND]]
;
%cmp = icmp sgt <4 x i32> %b, <i32 -1, i32 -1, i32 -1, i32 -1>