[PATCH] D145002: [DAGCombiner] Make `(zext (sgt X, -1))` -> `(srl (not X), N-1)` work if typeof(zext)!=typeof(X)

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 28 13:43:48 PST 2023


RKSimon added reviewers: dmgreen, craig.topper, nemanjai.
RKSimon added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:2578
                                    Not.getOperand(0), ShAmt);
+    if (ShiftVT != VT)
+      NewShift = DAG.getZExtOrTrunc(NewShift, DL, VT);
----------------
Don't bother with the if() - getZExtOrTrunc checks this anyway


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:12724
+      SDValue R = DAG.getNode(ShiftOpcode, DL, XVT, NotX, ShiftAmount);
+      if (VT != XVT)
+        R = DAG.getZExtOrTrunc(R, DL, VT);
----------------
Don't bother with the if() - getZExtOrTrunc checks this anyway


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145002/new/

https://reviews.llvm.org/D145002



More information about the llvm-commits mailing list