[PATCH] D152281: [Transforms][LICM] Add the ability to undo unprofitable reassociation

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 20 06:38:08 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LICM.cpp:2679
 
+/// Try to deassociate expressions like ((A1 * B1) + (A2 * B2) + ...) * C where
+/// A1, A2, ... and C are loop invariants into expressions like
----------------
deassociate -> reassociate


================
Comment at: llvm/lib/Transforms/Scalar/LICM.cpp:2691-2692
+
+  if (!(match(&I, m_FMul(m_Value(VariantOp), m_Value(InvariantOp))) &&
+        I.hasAllowReassoc()))
+    return false;
----------------
Here and elsewhere: Remove all unnecessary parentheses, apply de Morgan as needed.


================
Comment at: llvm/lib/Transforms/Scalar/LICM.cpp:2702
+  bool AnyAdds = false;
+  SmallVector<std::pair<BinaryOperator *, std::pair<Value *, int>>> Changes;
+  for (BinaryOperator *Op = nullptr, *OpNext = nullptr,
----------------
I think you just reinvented `Use`? That's how you reference a specific operand of an instruction.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152281/new/

https://reviews.llvm.org/D152281



More information about the llvm-commits mailing list