Skip to content

Commit b7c0f79

Browse files
committed
[InstCombine] Replace isFreeToInvert + CreateNot with getFreelyInverted
This is nearly an NFC, the only change is potentially to order that values are created/names. Otherwise it is a slight speed boost/simplification to avoid having to go through the `getFreelyInverted` recursive logic twice to simplify the extra `not` op.
1 parent 3039691 commit b7c0f79

File tree

9 files changed

+90
-111
lines changed

9 files changed

+90
-111
lines changed

llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,8 +2229,10 @@ Instruction *InstCombinerImpl::visitSub(BinaryOperator &I) {
22292229
if (isFreeToInvert(Op0, Op0->hasOneUse(), ConsumesOp0) &&
22302230
isFreeToInvert(Op1, Op1->hasOneUse(), ConsumesOp1) &&
22312231
(ConsumesOp0 || ConsumesOp1)) {
2232-
Value *NotOp0 = Builder.CreateNot(Op0);
2233-
Value *NotOp1 = Builder.CreateNot(Op1);
2232+
Value *NotOp0 = getFreelyInverted(Op0, Op0->hasOneUse(), &Builder);
2233+
Value *NotOp1 = getFreelyInverted(Op1, Op1->hasOneUse(), &Builder);
2234+
assert(NotOp0 != nullptr && NotOp1 != nullptr &&
2235+
"isFreeToInvert desynced with getFreelyInverted");
22342236
return BinaryOperator::CreateSub(NotOp1, NotOp0);
22352237
}
22362238
}

llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,16 +2503,24 @@ Instruction *InstCombinerImpl::visitAnd(BinaryOperator &I) {
25032503
return BinaryOperator::CreateAnd(Op1, B);
25042504

25052505
// (A ^ B) & ((B ^ C) ^ A) -> (A ^ B) & ~C
2506-
if (match(Op0, m_Xor(m_Value(A), m_Value(B))))
2507-
if (match(Op1, m_Xor(m_Xor(m_Specific(B), m_Value(C)), m_Specific(A))))
2508-
if (Op1->hasOneUse() || isFreeToInvert(C, C->hasOneUse()))
2509-
return BinaryOperator::CreateAnd(Op0, Builder.CreateNot(C));
2506+
if (match(Op0, m_Xor(m_Value(A), m_Value(B))) &&
2507+
match(Op1, m_Xor(m_Xor(m_Specific(B), m_Value(C)), m_Specific(A)))) {
2508+
Value *NotC = Op1->hasOneUse()
2509+
? Builder.CreateNot(C)
2510+
: getFreelyInverted(C, C->hasOneUse(), &Builder);
2511+
if (NotC != nullptr)
2512+
return BinaryOperator::CreateAnd(Op0, NotC);
2513+
}
25102514

25112515
// ((A ^ C) ^ B) & (B ^ A) -> (B ^ A) & ~C
2512-
if (match(Op0, m_Xor(m_Xor(m_Value(A), m_Value(C)), m_Value(B))))
2513-
if (match(Op1, m_Xor(m_Specific(B), m_Specific(A))))
2514-
if (Op0->hasOneUse() || isFreeToInvert(C, C->hasOneUse()))
2515-
return BinaryOperator::CreateAnd(Op1, Builder.CreateNot(C));
2516+
if (match(Op0, m_Xor(m_Xor(m_Value(A), m_Value(C)), m_Value(B))) &&
2517+
match(Op1, m_Xor(m_Specific(B), m_Specific(A)))) {
2518+
Value *NotC = Op0->hasOneUse()
2519+
? Builder.CreateNot(C)
2520+
: getFreelyInverted(C, C->hasOneUse(), &Builder);
2521+
if (NotC != nullptr)
2522+
return BinaryOperator::CreateAnd(Op1, Builder.CreateNot(C));
2523+
}
25162524

25172525
// (A | B) & (~A ^ B) -> A & B
25182526
// (A | B) & (B ^ ~A) -> A & B
@@ -4047,26 +4055,6 @@ static Instruction *visitMaskedMerge(BinaryOperator &I,
40474055
return nullptr;
40484056
}
40494057

4050-
// Transform
4051-
// ~(x ^ y)
4052-
// into:
4053-
// (~x) ^ y
4054-
// or into
4055-
// x ^ (~y)
4056-
static Instruction *sinkNotIntoXor(BinaryOperator &I, Value *X, Value *Y,
4057-
InstCombiner::BuilderTy &Builder) {
4058-
// We only want to do the transform if it is free to do.
4059-
if (InstCombiner::isFreeToInvert(X, X->hasOneUse())) {
4060-
// Ok, good.
4061-
} else if (InstCombiner::isFreeToInvert(Y, Y->hasOneUse())) {
4062-
std::swap(X, Y);
4063-
} else
4064-
return nullptr;
4065-
4066-
Value *NotX = Builder.CreateNot(X, X->getName() + ".not");
4067-
return BinaryOperator::CreateXor(NotX, Y, I.getName() + ".demorgan");
4068-
}
4069-
40704058
static Instruction *foldNotXor(BinaryOperator &I,
40714059
InstCombiner::BuilderTy &Builder) {
40724060
Value *X, *Y;
@@ -4075,9 +4063,6 @@ static Instruction *foldNotXor(BinaryOperator &I,
40754063
if (!match(&I, m_Not(m_OneUse(m_Xor(m_Value(X), m_Value(Y))))))
40764064
return nullptr;
40774065

4078-
if (Instruction *NewXor = sinkNotIntoXor(I, X, Y, Builder))
4079-
return NewXor;
4080-
40814066
auto hasCommonOperand = [](Value *A, Value *B, Value *C, Value *D) {
40824067
return A == C || A == D || B == C || B == D;
40834068
};
@@ -4375,15 +4360,6 @@ Instruction *InstCombinerImpl::foldNot(BinaryOperator &I) {
43754360
// ~max(~X, Y) --> min(X, ~Y)
43764361
auto *II = dyn_cast<IntrinsicInst>(NotOp);
43774362
if (II && II->hasOneUse()) {
4378-
if (match(NotOp, m_MaxOrMin(m_Value(X), m_Value(Y))) &&
4379-
isFreeToInvert(X, X->hasOneUse()) &&
4380-
isFreeToInvert(Y, Y->hasOneUse())) {
4381-
Intrinsic::ID InvID = getInverseMinMaxIntrinsic(II->getIntrinsicID());
4382-
Value *NotX = Builder.CreateNot(X);
4383-
Value *NotY = Builder.CreateNot(Y);
4384-
Value *InvMaxMin = Builder.CreateBinaryIntrinsic(InvID, NotX, NotY);
4385-
return replaceInstUsesWith(I, InvMaxMin);
4386-
}
43874363
if (match(NotOp, m_c_MaxOrMin(m_Not(m_Value(X)), m_Value(Y)))) {
43884364
Intrinsic::ID InvID = getInverseMinMaxIntrinsic(II->getIntrinsicID());
43894365
Value *NotY = Builder.CreateNot(Y);

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,12 +1698,12 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
16981698
auto moveNotAfterMinMax = [&](Value *X, Value *Y) -> Instruction * {
16991699
Value *A;
17001700
if (match(X, m_OneUse(m_Not(m_Value(A)))) &&
1701-
!isFreeToInvert(A, A->hasOneUse()) &&
1702-
isFreeToInvert(Y, Y->hasOneUse())) {
1703-
Value *NotY = Builder.CreateNot(Y);
1704-
Intrinsic::ID InvID = getInverseMinMaxIntrinsic(IID);
1705-
Value *InvMaxMin = Builder.CreateBinaryIntrinsic(InvID, A, NotY);
1706-
return BinaryOperator::CreateNot(InvMaxMin);
1701+
!isFreeToInvert(A, A->hasOneUse())) {
1702+
if (Value *NotY = getFreelyInverted(Y, Y->hasOneUse(), &Builder)) {
1703+
Intrinsic::ID InvID = getInverseMinMaxIntrinsic(IID);
1704+
Value *InvMaxMin = Builder.CreateBinaryIntrinsic(InvID, A, NotY);
1705+
return BinaryOperator::CreateNot(InvMaxMin);
1706+
}
17071707
}
17081708
return nullptr;
17091709
};

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3281,10 +3281,12 @@ Instruction *InstCombinerImpl::foldICmpBitCast(ICmpInst &Cmp) {
32813281
// icmp eq/ne (bitcast (not X) to iN), -1 --> icmp eq/ne (bitcast X to iN), 0
32823282
// Example: are all elements equal? --> are zero elements not equal?
32833283
// TODO: Try harder to reduce compare of 2 freely invertible operands?
3284-
if (Cmp.isEquality() && C->isAllOnes() && Bitcast->hasOneUse() &&
3285-
isFreeToInvert(BCSrcOp, BCSrcOp->hasOneUse())) {
3286-
Value *Cast = Builder.CreateBitCast(Builder.CreateNot(BCSrcOp), DstType);
3287-
return new ICmpInst(Pred, Cast, ConstantInt::getNullValue(DstType));
3284+
if (Cmp.isEquality() && C->isAllOnes() && Bitcast->hasOneUse()) {
3285+
if (Value *NotBCSrcOp =
3286+
getFreelyInverted(BCSrcOp, BCSrcOp->hasOneUse(), &Builder)) {
3287+
Value *Cast = Builder.CreateBitCast(NotBCSrcOp, DstType);
3288+
return new ICmpInst(Pred, Cast, ConstantInt::getNullValue(DstType));
3289+
}
32883290
}
32893291

32903292
// If this is checking if all elements of an extended vector are clear or not,
@@ -4549,14 +4551,13 @@ static Instruction *foldICmpOrXX(ICmpInst &I, const SimplifyQuery &Q,
45494551

45504552
if (ICmpInst::isEquality(Pred) && Op0->hasOneUse()) {
45514553
// icmp (X | Y) eq/ne Y --> (X & ~Y) eq/ne 0 if Y is freely invertible
4552-
if (IC.isFreeToInvert(Op1, Op1->hasOneUse()))
4553-
return new ICmpInst(Pred,
4554-
IC.Builder.CreateAnd(A, IC.Builder.CreateNot(Op1)),
4554+
if (Value *NotOp1 =
4555+
IC.getFreelyInverted(Op1, Op1->hasOneUse(), &IC.Builder))
4556+
return new ICmpInst(Pred, IC.Builder.CreateAnd(A, NotOp1),
45554557
Constant::getNullValue(Op1->getType()));
45564558
// icmp (X | Y) eq/ne Y --> (~X | Y) eq/ne -1 if X is freely invertible.
4557-
if (IC.isFreeToInvert(A, A->hasOneUse()))
4558-
return new ICmpInst(Pred,
4559-
IC.Builder.CreateOr(Op1, IC.Builder.CreateNot(A)),
4559+
if (Value *NotA = IC.getFreelyInverted(A, A->hasOneUse(), &IC.Builder))
4560+
return new ICmpInst(Pred, IC.Builder.CreateOr(Op1, NotA),
45604561
Constant::getAllOnesValue(Op1->getType()));
45614562
}
45624563
return nullptr;

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3075,18 +3075,18 @@ Instruction *InstCombinerImpl::foldSelectOfBools(SelectInst &SI) {
30753075
return SelectInst::Create(TrueVal, OrV, Zero);
30763076
}
30773077
// select (c & b), a, b -> select b, (select ~c, true, a), false
3078-
if (match(CondVal, m_OneUse(m_c_And(m_Value(C), m_Specific(FalseVal)))) &&
3079-
isFreeToInvert(C, C->hasOneUse())) {
3080-
Value *NotC = Builder.CreateNot(C);
3081-
Value *OrV = Builder.CreateSelect(NotC, One, TrueVal);
3082-
return SelectInst::Create(FalseVal, OrV, Zero);
3078+
if (match(CondVal, m_OneUse(m_c_And(m_Value(C), m_Specific(FalseVal))))) {
3079+
if (Value *NotC = getFreelyInverted(C, C->hasOneUse(), &Builder)) {
3080+
Value *OrV = Builder.CreateSelect(NotC, One, TrueVal);
3081+
return SelectInst::Create(FalseVal, OrV, Zero);
3082+
}
30833083
}
30843084
// select (a | c), a, b -> select a, true, (select ~c, b, false)
3085-
if (match(CondVal, m_OneUse(m_c_Or(m_Specific(TrueVal), m_Value(C)))) &&
3086-
isFreeToInvert(C, C->hasOneUse())) {
3087-
Value *NotC = Builder.CreateNot(C);
3088-
Value *AndV = Builder.CreateSelect(NotC, FalseVal, Zero);
3089-
return SelectInst::Create(TrueVal, One, AndV);
3085+
if (match(CondVal, m_OneUse(m_c_Or(m_Specific(TrueVal), m_Value(C))))) {
3086+
if (Value *NotC = getFreelyInverted(C, C->hasOneUse(), &Builder)) {
3087+
Value *AndV = Builder.CreateSelect(NotC, FalseVal, Zero);
3088+
return SelectInst::Create(TrueVal, One, AndV);
3089+
}
30903090
}
30913091
// select (c & ~b), a, b -> select b, true, (select c, a, false)
30923092
if (match(CondVal,

llvm/test/Transforms/InstCombine/demorgan-sink-not-into-xor.ll

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --prefix-filecheck-ir-name V
22
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
33

44
; https://bugs.llvm.org/show_bug.cgi?id=38446
@@ -22,10 +22,10 @@ declare i1 @gen1()
2222

2323
define i1 @positive_easyinvert(i16 %x, i8 %y) {
2424
; CHECK-LABEL: @positive_easyinvert(
25-
; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i16 [[X:%.*]], 0
26-
; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i8 [[Y:%.*]], -1
27-
; CHECK-NEXT: [[TMP4:%.*]] = xor i1 [[TMP2]], [[TMP1]]
28-
; CHECK-NEXT: ret i1 [[TMP4]]
25+
; CHECK-NEXT: [[VTMP2:%.*]] = icmp slt i8 [[Y:%.*]], 0
26+
; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i16 [[X:%.*]], -1
27+
; CHECK-NEXT: [[VTMP4:%.*]] = xor i1 [[VTMP2]], [[TMP1]]
28+
; CHECK-NEXT: ret i1 [[VTMP4]]
2929
;
3030
%tmp1 = icmp slt i16 %x, 0
3131
%tmp2 = icmp slt i8 %y, 0
@@ -36,24 +36,24 @@ define i1 @positive_easyinvert(i16 %x, i8 %y) {
3636

3737
define i1 @positive_easyinvert0(i8 %y) {
3838
; CHECK-LABEL: @positive_easyinvert0(
39-
; CHECK-NEXT: [[TMP1:%.*]] = call i1 @gen1()
40-
; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i8 [[Y:%.*]], -1
41-
; CHECK-NEXT: [[TMP4:%.*]] = xor i1 [[TMP2]], [[TMP1]]
42-
; CHECK-NEXT: ret i1 [[TMP4]]
39+
; CHECK-NEXT: [[VTMP1:%.*]] = call i1 @gen1()
40+
; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i8 [[Y:%.*]], -1
41+
; CHECK-NEXT: [[VTMP4:%.*]] = xor i1 [[TMP1]], [[VTMP1]]
42+
; CHECK-NEXT: ret i1 [[VTMP4]]
4343
;
4444
%tmp1 = call i1 @gen1()
45-
%tmp2 = icmp slt i8 %y, 0
46-
%tmp3 = xor i1 %tmp2, %tmp1
45+
%cond = icmp slt i8 %y, 0
46+
%tmp3 = xor i1 %cond, %tmp1
4747
%tmp4 = xor i1 %tmp3, true
4848
ret i1 %tmp4
4949
}
5050

5151
define i1 @positive_easyinvert1(i8 %y) {
5252
; CHECK-LABEL: @positive_easyinvert1(
53-
; CHECK-NEXT: [[TMP1:%.*]] = call i1 @gen1()
54-
; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i8 [[Y:%.*]], -1
55-
; CHECK-NEXT: [[TMP4:%.*]] = xor i1 [[TMP2]], [[TMP1]]
56-
; CHECK-NEXT: ret i1 [[TMP4]]
53+
; CHECK-NEXT: [[VTMP1:%.*]] = call i1 @gen1()
54+
; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i8 [[Y:%.*]], -1
55+
; CHECK-NEXT: [[VTMP4:%.*]] = xor i1 [[VTMP1]], [[TMP1]]
56+
; CHECK-NEXT: ret i1 [[VTMP4]]
5757
;
5858
%tmp1 = call i1 @gen1()
5959
%tmp2 = icmp slt i8 %y, 0
@@ -70,12 +70,12 @@ declare void @use1(i1)
7070

7171
define i1 @oneuse_easyinvert_0(i8 %y) {
7272
; CHECK-LABEL: @oneuse_easyinvert_0(
73-
; CHECK-NEXT: [[TMP1:%.*]] = call i1 @gen1()
74-
; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i8 [[Y:%.*]], 0
75-
; CHECK-NEXT: call void @use1(i1 [[TMP2]])
76-
; CHECK-NEXT: [[TMP3:%.*]] = xor i1 [[TMP1]], [[TMP2]]
77-
; CHECK-NEXT: [[TMP4:%.*]] = xor i1 [[TMP3]], true
78-
; CHECK-NEXT: ret i1 [[TMP4]]
73+
; CHECK-NEXT: [[VTMP1:%.*]] = call i1 @gen1()
74+
; CHECK-NEXT: [[VTMP2:%.*]] = icmp slt i8 [[Y:%.*]], 0
75+
; CHECK-NEXT: call void @use1(i1 [[VTMP2]])
76+
; CHECK-NEXT: [[VTMP3:%.*]] = xor i1 [[VTMP1]], [[VTMP2]]
77+
; CHECK-NEXT: [[VTMP4:%.*]] = xor i1 [[VTMP3]], true
78+
; CHECK-NEXT: ret i1 [[VTMP4]]
7979
;
8080
%tmp1 = call i1 @gen1()
8181
%tmp2 = icmp slt i8 %y, 0
@@ -87,12 +87,12 @@ define i1 @oneuse_easyinvert_0(i8 %y) {
8787

8888
define i1 @oneuse_easyinvert_1(i8 %y) {
8989
; CHECK-LABEL: @oneuse_easyinvert_1(
90-
; CHECK-NEXT: [[TMP1:%.*]] = call i1 @gen1()
91-
; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i8 [[Y:%.*]], 0
92-
; CHECK-NEXT: [[TMP3:%.*]] = xor i1 [[TMP1]], [[TMP2]]
93-
; CHECK-NEXT: call void @use1(i1 [[TMP3]])
94-
; CHECK-NEXT: [[TMP4:%.*]] = xor i1 [[TMP3]], true
95-
; CHECK-NEXT: ret i1 [[TMP4]]
90+
; CHECK-NEXT: [[VTMP1:%.*]] = call i1 @gen1()
91+
; CHECK-NEXT: [[VTMP2:%.*]] = icmp slt i8 [[Y:%.*]], 0
92+
; CHECK-NEXT: [[VTMP3:%.*]] = xor i1 [[VTMP1]], [[VTMP2]]
93+
; CHECK-NEXT: call void @use1(i1 [[VTMP3]])
94+
; CHECK-NEXT: [[VTMP4:%.*]] = xor i1 [[VTMP3]], true
95+
; CHECK-NEXT: ret i1 [[VTMP4]]
9696
;
9797
%tmp1 = call i1 @gen1()
9898
%tmp2 = icmp slt i8 %y, 0
@@ -104,13 +104,13 @@ define i1 @oneuse_easyinvert_1(i8 %y) {
104104

105105
define i1 @oneuse_easyinvert_2(i8 %y) {
106106
; CHECK-LABEL: @oneuse_easyinvert_2(
107-
; CHECK-NEXT: [[TMP1:%.*]] = call i1 @gen1()
108-
; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i8 [[Y:%.*]], 0
109-
; CHECK-NEXT: call void @use1(i1 [[TMP2]])
110-
; CHECK-NEXT: [[TMP3:%.*]] = xor i1 [[TMP1]], [[TMP2]]
111-
; CHECK-NEXT: call void @use1(i1 [[TMP3]])
112-
; CHECK-NEXT: [[TMP4:%.*]] = xor i1 [[TMP3]], true
113-
; CHECK-NEXT: ret i1 [[TMP4]]
107+
; CHECK-NEXT: [[VTMP1:%.*]] = call i1 @gen1()
108+
; CHECK-NEXT: [[VTMP2:%.*]] = icmp slt i8 [[Y:%.*]], 0
109+
; CHECK-NEXT: call void @use1(i1 [[VTMP2]])
110+
; CHECK-NEXT: [[VTMP3:%.*]] = xor i1 [[VTMP1]], [[VTMP2]]
111+
; CHECK-NEXT: call void @use1(i1 [[VTMP3]])
112+
; CHECK-NEXT: [[VTMP4:%.*]] = xor i1 [[VTMP3]], true
113+
; CHECK-NEXT: ret i1 [[VTMP4]]
114114
;
115115
%tmp1 = call i1 @gen1()
116116
%tmp2 = icmp slt i8 %y, 0
@@ -128,9 +128,9 @@ define i1 @oneuse_easyinvert_2(i8 %y) {
128128
; Not easily invertible.
129129
define i32 @negative(i32 %x, i32 %y) {
130130
; CHECK-LABEL: @negative(
131-
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
132-
; CHECK-NEXT: [[TMP2:%.*]] = xor i32 [[TMP1]], -1
133-
; CHECK-NEXT: ret i32 [[TMP2]]
131+
; CHECK-NEXT: [[VTMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
132+
; CHECK-NEXT: [[VTMP2:%.*]] = xor i32 [[VTMP1]], -1
133+
; CHECK-NEXT: ret i32 [[VTMP2]]
134134
;
135135
%tmp1 = xor i32 %x, %y
136136
%tmp2 = xor i32 %tmp1, -1

llvm/test/Transforms/InstCombine/free-inversion.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ declare void @use.i8(i8)
1111
define i8 @xor_1(i8 %a, i1 %c, i8 %x, i8 %y) {
1212
; CHECK-LABEL: @xor_1(
1313
; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[Y:%.*]], -124
14-
; CHECK-NEXT: [[B_NOT:%.*]] = select i1 [[C:%.*]], i8 [[X:%.*]], i8 [[TMP1]]
15-
; CHECK-NEXT: [[NOT_BA:%.*]] = xor i8 [[B_NOT]], [[A:%.*]]
14+
; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[C:%.*]], i8 [[X:%.*]], i8 [[TMP1]]
15+
; CHECK-NEXT: [[NOT_BA:%.*]] = xor i8 [[TMP2]], [[A:%.*]]
1616
; CHECK-NEXT: ret i8 [[NOT_BA]]
1717
;
1818
%nx = xor i8 %x, -1
@@ -26,8 +26,8 @@ define i8 @xor_1(i8 %a, i1 %c, i8 %x, i8 %y) {
2626
define i8 @xor_2(i8 %a, i1 %c, i8 %x, i8 %y) {
2727
; CHECK-LABEL: @xor_2(
2828
; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[Y:%.*]], -124
29-
; CHECK-NEXT: [[B_NOT:%.*]] = select i1 [[C:%.*]], i8 [[X:%.*]], i8 [[TMP1]]
30-
; CHECK-NEXT: [[NOT_AB:%.*]] = xor i8 [[B_NOT]], [[A:%.*]]
29+
; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[C:%.*]], i8 [[X:%.*]], i8 [[TMP1]]
30+
; CHECK-NEXT: [[NOT_AB:%.*]] = xor i8 [[TMP2]], [[A:%.*]]
3131
; CHECK-NEXT: ret i8 [[NOT_AB]]
3232
;
3333
%nx = xor i8 %x, -1

llvm/test/Transforms/InstCombine/icmp-mul-zext.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ define i1 @PR46561(i1 %a, i1 %x, i1 %y, i8 %z) {
131131
; CHECK-NEXT: [[MULBOOL:%.*]] = and i1 [[X:%.*]], [[Y:%.*]]
132132
; CHECK-NEXT: [[TMP0:%.*]] = and i8 [[Z:%.*]], 1
133133
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[TMP0]], 0
134-
; CHECK-NEXT: [[TMP2:%.*]] = xor i1 [[TMP1]], [[MULBOOL]]
134+
; CHECK-NEXT: [[TMP2:%.*]] = xor i1 [[MULBOOL]], [[TMP1]]
135135
; CHECK-NEXT: br label [[END]]
136136
; CHECK: end:
137137
; CHECK-NEXT: [[P:%.*]] = phi i1 [ [[TMP2]], [[COND_TRUE]] ], [ false, [[ENTRY:%.*]] ]

llvm/test/Transforms/InstCombine/minmax-intrinsics.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ define i8 @freeToInvert(i8 %x, i8 %y, i8 %z) {
12631263
; CHECK-NEXT: call void @use(i8 [[NY]])
12641264
; CHECK-NEXT: call void @use(i8 [[NZ]])
12651265
; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.umin.i8(i8 [[X]], i8 [[Y]])
1266-
; CHECK-NEXT: [[NOT:%.*]] = call i8 @llvm.smax.i8(i8 [[TMP1]], i8 [[Z]])
1266+
; CHECK-NEXT: [[NOT:%.*]] = call i8 @llvm.smax.i8(i8 [[Z]], i8 [[TMP1]])
12671267
; CHECK-NEXT: ret i8 [[NOT]]
12681268
;
12691269
%nx = xor i8 %x, -1

0 commit comments

Comments
 (0)