[llvm] [VectorCombine] Use InstSimplifyFolder to simplify instrs on creation. (PR #146350)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 1 02:32:29 PDT 2025
================
@@ -1459,10 +1461,12 @@ bool VectorCombine::foldBinopOfReductions(Instruction &I) {
LLVM_DEBUG(dbgs() << "Found two mergeable reductions: " << I
<< "\n OldCost: " << OldCost << " vs NewCost: " << NewCost
<< "\n");
- Value *VectorBO = Builder.CreateBinOp(BinOpOpc, V0, V1);
- if (auto *PDInst = dyn_cast<PossiblyDisjointInst>(&I))
- if (auto *PDVectorBO = dyn_cast<PossiblyDisjointInst>(VectorBO))
- PDVectorBO->setIsDisjoint(PDInst->isDisjoint());
+ Value *VectorBO;
+ if (BinOpOpc == Instruction::Or)
+ VectorBO = Builder.CreateOr(V0, V1, "",
+ cast<PossiblyDisjointInst>(I).isDisjoint());
+ else
+ VectorBO = Builder.CreateBinOp(BinOpOpc, V0, V1);
----------------
artagnon wrote:
```suggestion
VectorBO = isa<PossiblyDisjointInst>(I) ?
Builder.CreateDisjoint(BinOpOpc, V0, V1) :
Builder.CreateBinOp(BinOpOpc, V0, V1);
```
Better not to rely on just Or being PossiblyDisjoint.
https://github.com/llvm/llvm-project/pull/146350
More information about the llvm-commits
mailing list