[PATCH] D131471: [RISCV] Fold (sub constant, (setcc x, y, eq/neq)) -> (add constant - 1, (setcc x, y, neq/eq))
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 9 09:14:19 PDT 2022
- Previous message: [PATCH] D131471: [RISCV] Fold (sub constant, (setcc x, y, eq/neq)) -> (add constant - 1, (setcc x, y, neq/eq))
- Next message: [PATCH] D131471: [RISCV] Fold (sub constant, (setcc x, y, eq/neq)) -> (add constant - 1, (setcc x, y, neq/eq))
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
craig.topper added inline comments.
================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:8275
+ // (add constant - 1, (setcc x, y, neq/eq))
+ if (isa<ConstantSDNode>(N0) && N1.getOpcode() == ISD::SETCC) {
+ auto *Nnz0 = cast<ConstantSDNode>(N0);
----------------
Do we need to check that this is the only user of the setcc?
================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:8279
+ ISD::CondCode CCVal = CC->get();
+ if (!Nnz0->isZero() && (CCVal == ISD::SETEQ || CCVal == ISD::SETNE)) {
+ EVT VT = N->getValueType(0);
----------------
Use `ISD::isIntEqualitySetCC(CCVal)`
================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:8287
+ N1->getOperand(1), CCInverse);
+ return DAG.getNode(ISD::ADD, SDLoc(N), VT, NewN0, NewN1);
+ }
----------------
Put these in canonical order with constant on the RHS.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131471/new/
https://reviews.llvm.org/D131471
- Previous message: [PATCH] D131471: [RISCV] Fold (sub constant, (setcc x, y, eq/neq)) -> (add constant - 1, (setcc x, y, neq/eq))
- Next message: [PATCH] D131471: [RISCV] Fold (sub constant, (setcc x, y, eq/neq)) -> (add constant - 1, (setcc x, y, neq/eq))
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the llvm-commits
mailing list