[PATCH] D12863: [NaryReassociate] Add support for Mul instructions
Jingyue Wu via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 14 22:03:03 PDT 2015
jingyue requested changes to this revision.
jingyue added a comment.
This revision now requires changes to proceed.
LG in general. Some code can be made clearer with refactoring. Thanks for working on this! It has been on my TODO list for quite a long time :)
================
Comment at: lib/Transforms/Scalar/NaryReassociate.cpp:473-476
@@ +472,6 @@
+ unsigned Opcode = I->getOpcode();
+ bool Matched =
+ (Opcode == Instruction::Add &&
+ match(LHS, m_Add(m_Value(A), m_Value(B)))) ||
+ (Opcode == Instruction::Mul && match(LHS, m_Mul(m_Value(A), m_Value(B))));
+ // To be conservative, we reassociate I only when it is the only user of (A op
----------------
Extract these lines to a helper function, e.g., `matchTernaryOp` that returns the opcode and outputs `A` and `B` as parameters.
================
Comment at: lib/Transforms/Scalar/NaryReassociate.cpp:485-487
@@ -474,2 +484,5 @@
if (BExpr != RHSExpr) {
- if (auto *NewI = tryReassociatedAdd(SE->getAddExpr(AExpr, RHSExpr), B, I))
+ const SCEV *Expr = Opcode == Instruction::Add
+ ? SE->getAddExpr(AExpr, RHSExpr)
+ : SE->getMulExpr(AExpr, RHSExpr);
+ if (auto *NewI = tryReassociatedBinaryOp(Expr, B, I))
----------------
Extract these lines to a helper function, e.g., `getBinarySCEV`.
Repository:
rL LLVM
http://reviews.llvm.org/D12863
More information about the llvm-commits
mailing list