Skip to content

Commit cdc57db

Browse files
committed
!fixup use IRBuilderBase, create disjoint OR via builder
1 parent 8384be3 commit cdc57db

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

llvm/include/llvm/IR/IRBuilder.h

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

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

15841588
Value *CreateOr(Value *LHS, const APInt &RHS, const Twine &Name = "") {

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,7 @@ bool VectorCombine::isExtractExtractCheap(ExtractElementInst *Ext0,
531531
/// Create a shuffle that translates (shifts) 1 element from the input vector
532532
/// to a new element location.
533533
static Value *createShiftShuffle(Value *Vec, unsigned OldIndex,
534-
unsigned NewIndex,
535-
IRBuilder<InstSimplifyFolder> &Builder) {
534+
unsigned NewIndex, IRBuilderBase &Builder) {
536535
// The shuffle mask is poison except for 1 lane that is being translated
537536
// to the new element index. Example for OldIndex == 2 and NewIndex == 0:
538537
// ShufMask = { 2, poison, poison, poison }
@@ -546,9 +545,9 @@ static Value *createShiftShuffle(Value *Vec, unsigned OldIndex,
546545
/// the source vector (shift the scalar element) to a NewIndex for extraction.
547546
/// Return null if the input can be constant folded, so that we are not creating
548547
/// unnecessary instructions.
549-
static ExtractElementInst *
550-
translateExtract(ExtractElementInst *ExtElt, unsigned NewIndex,
551-
IRBuilder<InstSimplifyFolder> &Builder) {
548+
static ExtractElementInst *translateExtract(ExtractElementInst *ExtElt,
549+
unsigned NewIndex,
550+
IRBuilderBase &Builder) {
552551
// Shufflevectors can only be created for fixed-width vectors.
553552
Value *X = ExtElt->getVectorOperand();
554553
if (!isa<FixedVectorType>(X->getType()))
@@ -1462,10 +1461,12 @@ bool VectorCombine::foldBinopOfReductions(Instruction &I) {
14621461
LLVM_DEBUG(dbgs() << "Found two mergeable reductions: " << I
14631462
<< "\n OldCost: " << OldCost << " vs NewCost: " << NewCost
14641463
<< "\n");
1465-
Value *VectorBO = Builder.CreateBinOp(BinOpOpc, V0, V1);
1466-
if (auto *PDInst = dyn_cast<PossiblyDisjointInst>(&I))
1467-
if (auto *PDVectorBO = dyn_cast<PossiblyDisjointInst>(VectorBO))
1468-
PDVectorBO->setIsDisjoint(PDInst->isDisjoint());
1464+
Value *VectorBO;
1465+
if (BinOpOpc == Instruction::Or)
1466+
VectorBO = Builder.CreateOr(V0, V1, "",
1467+
cast<PossiblyDisjointInst>(I).isDisjoint());
1468+
else
1469+
VectorBO = Builder.CreateBinOp(BinOpOpc, V0, V1);
14691470

14701471
Instruction *Rdx = Builder.CreateIntrinsic(ReductionIID, {VTy}, {VectorBO});
14711472
replaceValue(I, *Rdx);
@@ -1522,7 +1523,7 @@ class ScalarizationResult {
15221523
}
15231524

15241525
/// Freeze the ToFreeze and update the use in \p User to use it.
1525-
void freeze(IRBuilder<InstSimplifyFolder> &Builder, Instruction &UserI) {
1526+
void freeze(IRBuilderBase &Builder, Instruction &UserI) {
15261527
assert(isSafeWithFreeze() &&
15271528
"should only be used when freezing is required");
15281529
assert(is_contained(ToFreeze->users(), &UserI) &&
@@ -2620,7 +2621,7 @@ static Value *generateNewInstTree(ArrayRef<InstLane> Item, FixedVectorType *Ty,
26202621
const SmallPtrSet<Use *, 4> &IdentityLeafs,
26212622
const SmallPtrSet<Use *, 4> &SplatLeafs,
26222623
const SmallPtrSet<Use *, 4> &ConcatLeafs,
2623-
IRBuilder<InstSimplifyFolder> &Builder,
2624+
IRBuilderBase &Builder,
26242625
const TargetTransformInfo *TTI) {
26252626
auto [FrontU, FrontLane] = Item.front();
26262627

0 commit comments

Comments
 (0)