[llvm] [Reassociate] Distribute multiply over add to enable factorization (PR #178201)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 17 09:11:12 PDT 2026
================
@@ -2569,6 +2655,26 @@ PreservedAnalyses ReassociatePass::run(Function &F, FunctionAnalysisManager &) {
MadeChange = false;
+ // Pre-process: Distribute multiplications to enable reassociation
+ for (BasicBlock *BI : RPOT) {
+ for (BasicBlock::iterator II = BI->begin(), IE = BI->end(); II != IE;) {
+ Instruction *Inst = &*II;
+ ++II; // Advance before modification
+
+ if (auto *Mul = dyn_cast<BinaryOperator>(Inst)) {
+ if (Mul->getOpcode() == Instruction::Mul) {
----------------
hazarathayya wrote:
completed the follow-up
https://github.com/llvm/llvm-project/pull/178201
More information about the llvm-commits
mailing list