[PATCH] D159198: [DAG] Fold (shl (ext (add x, c1)), c2) -> (add (shl (ext x), c2), c1 << c2)
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 31 03:09:36 PDT 2023
goldstein.w.n added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:9930-9931
+ // fold (shl (sext (add_nsw x, c1)), c2) -> (add (shl (sext x), c2), c1 << c2)
+ // fold (shl (zext (add_nuw x, c1)), c2) -> (add (shl (zext x), c2), c1 << c2)
+ if ((N0.getOpcode() == ISD::SIGN_EXTEND ||
----------------
pengfei wrote:
> goldstein.w.n wrote:
> > pengfei wrote:
> > > Do we need to consider the possibility of overflow when `c1 << c2`?
> > Shouldnt need to, the proof stands even with
> I'm not sure about the `zext` one if we always put `c1 << c2` in the displacement. The displacement can only be signed int.
Oh that's a good point
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D159198/new/
https://reviews.llvm.org/D159198
More information about the llvm-commits
mailing list