[PATCH] D148341: [DAGCombiner] Fold add (mul x, C), x to mul x, C+1
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 14 12:17:35 PDT 2023
nikic added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:3061
+ // add (mul x, C), x -> mul x, C+1
+ if (N0.getOpcode() == ISD::MUL && N0.getOperand(0) == N1 &&
----------------
goldstein.w.n wrote:
> Does the equivilent ever come up for sub?
I don't think so. You'd need something like `gep(x, sub(0, mul(x, C)))` for that, and that would be canonicalized to `gep(x, mul(x, -C))` rather than becoming `sub(x, mul(x, C))` in the backend.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148341/new/
https://reviews.llvm.org/D148341
More information about the llvm-commits
mailing list