[PATCH] D145002: [DAGCombiner] Make `(zext (sgt X, -1))` -> `(srl (not X), N-1)` work if typeof(zext)!=typeof(X)
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 2 12:24:49 PST 2023
goldstein.w.n 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);
----------------
RKSimon wrote:
> RKSimon wrote:
> > Don't bother with the if() - getZExtOrTrunc checks this anyway
> For IsAdd don't we need getSExtOrTrunc? AFAICT we're after a 0/-1 value for Add and a 0/1 value for Sub?
> For IsAdd don't we need getSExtOrTrunc? AFAICT we're after a 0/-1 value for Add and a 0/1 value for Sub?
Good catch, also added tests for this case.
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