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

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 31 10:58:06 PDT 2023


goldstein.w.n added a comment.

In D159198#4630801 <https://reviews.llvm.org/D159198#4630801>, @RKSimon wrote:

> rebase - limit to sext/add_nsw - added negative tests

Can you make the tests related?



================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:9931
+  // fold (shl (sext (add_nsw x, c1)), c2) -> (add (shl (sext x), c2), c1 << c2)
+  if (N0.getOpcode() == ISD::SIGN_EXTEND &&
+      N0.getOperand(0).getOpcode() == ISD::ADD &&
----------------
Add TODO for `zext` if `nuw` + `c1 << c2` stays imm32? (or more conservatively same int width class).


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