[clang] [llvm] [InstCombine] Reassociate nested add/sub with constant (PR #191022)
Max Graey via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 9 11:53:27 PDT 2026
================
@@ -1523,6 +1523,34 @@ static Instruction *foldBoxMultiply(BinaryOperator &I) {
return nullptr;
}
+/// Canonicalize a nested add/sub with a constant on the inner RHS by
+/// sinking the constant to the outer RHS.
+/// (X +/- C) +/- Y -> (X +/- Y) +/- C
----------------
MaxGraey wrote:
Another idea is to try not to rearrange when `Inner->getParent() != I.getParent()` (very pessimistic) or somehow to utilize info of back edges (very optimistic)
https://github.com/llvm/llvm-project/pull/191022
More information about the cfe-commits
mailing list