Skip to content

Commit 4c30369

Browse files
committed
!fixup add and use CreateBinOpDisjoint.
1 parent b60022d commit 4c30369

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

llvm/include/llvm/IR/IRBuilder.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,14 +1575,10 @@ class IRBuilderBase {
15751575
return Accum;
15761576
}
15771577

1578-
Value *CreateOr(Value *LHS, Value *RHS, const Twine &Name = "",
1579-
bool IsDisjoint = false) {
1578+
Value *CreateOr(Value *LHS, Value *RHS, const Twine &Name = "") {
15801579
if (auto *V = Folder.FoldBinOp(Instruction::Or, LHS, RHS))
15811580
return V;
1582-
return Insert(
1583-
IsDisjoint ? BinaryOperator::CreateDisjoint(Instruction::Or, LHS, RHS)
1584-
: BinaryOperator::CreateOr(LHS, RHS),
1585-
Name);
1581+
return Insert(BinaryOperator::CreateOr(LHS, RHS), Name);
15861582
}
15871583

15881584
Value *CreateOr(Value *LHS, const APInt &RHS, const Twine &Name = "") {
@@ -1727,6 +1723,18 @@ class IRBuilderBase {
17271723
return Insert(BinOp, Name);
17281724
}
17291725

1726+
Value *CreateBinOpDisjoint(BinaryOperator::BinaryOps Opc, Value *LHS,
1727+
Value *RHS, bool IsDisjoint,
1728+
const Twine &Name = "") {
1729+
if (Value *V = Folder.FoldBinOp(Opc, LHS, RHS))
1730+
return V;
1731+
1732+
BinaryOperator *BO =
1733+
Insert(BinaryOperator::CreateDisjoint(Opc, LHS, RHS), Name);
1734+
cast<PossiblyDisjointInst>(BO)->setIsDisjoint(IsDisjoint);
1735+
return BO;
1736+
}
1737+
17301738
Value *CreateLogicalAnd(Value *Cond1, Value *Cond2, const Twine &Name = "") {
17311739
assert(Cond2->getType()->isIntOrIntVectorTy(1));
17321740
return CreateSelect(Cond1, Cond2,

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,9 +1462,9 @@ bool VectorCombine::foldBinopOfReductions(Instruction &I) {
14621462
<< "\n OldCost: " << OldCost << " vs NewCost: " << NewCost
14631463
<< "\n");
14641464
Value *VectorBO;
1465-
if (BinOpOpc == Instruction::Or)
1466-
VectorBO = Builder.CreateOr(V0, V1, "",
1467-
cast<PossiblyDisjointInst>(I).isDisjoint());
1465+
if (auto *PDInst = dyn_cast<PossiblyDisjointInst>(&I))
1466+
VectorBO =
1467+
Builder.CreateBinOpDisjoint(BinOpOpc, V0, V1, PDInst->isDisjoint(), "");
14681468
else
14691469
VectorBO = Builder.CreateBinOp(BinOpOpc, V0, V1);
14701470

0 commit comments

Comments
 (0)