[PATCH] D111117: [RISCV] Optimize (add (shl x, c0), c1)
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 13 10:13:57 PDT 2021
craig.topper added inline comments.
================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:6474
+ DAG.getNode(ISD::SHL, DL, VT, New0, DAG.getConstant(C0, DL, VT));
+ if (C1 - (C1 >> C0 << C0) == 0)
+ return New1;
----------------
I think you can drop this if, getNode will see the constant is 0 and not produce an ADD node.
================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:6482
const RISCVSubtarget &Subtarget) {
+ // Transform (add (shl x, c0), c1) ->
+ // (add (shl (add x, c1>>c0), c0), c1-(c1>>c0<<c0)),
----------------
This comment is already above transformAddImmShlImm, we don't need to repeat it.
================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:6491
+ return V;
// Transform (add (mul x, c0), c1) ->
// (add (mul (add x, c1/c0), c0), c1%c0).
----------------
Just drop this comment. It's already above transformAddImmMulImm.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111117/new/
https://reviews.llvm.org/D111117
More information about the llvm-commits
mailing list