[PATCH] D159198: [DAG] Fold (shl (ext (add x, c1)), c2) -> (add (shl (ext x), c2), c1 << c2)

Phoebe Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 30 22:04:27 PDT 2023


pengfei 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 ||
----------------
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.


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