[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
Thu Aug 11 09:01:37 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:8276
+ if (isa<ConstantSDNode>(N0) && N1.getOpcode() == ISD::SETCC &&
+ N->isOnlyUserOf(N1.getNode())) {
+ auto *Nnz0 = cast<ConstantSDNode>(N0);
----------------
You can use `N1.hasOneUse()` which should be cheaper. `isOnlyUser` is more useful if N had multiple operands that could each be N1. We know one operand of N is a constant so N1 can only be used by one operand.
================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:8282
+ EVT VT = N->getValueType(0);
+ int64_t ImmVal = cast<ConstantSDNode>(N0)->getSExtValue() - 1;
+ SDValue CCInverse =
----------------
This line has undefined behavior if N0 happens to be 0x8000000000000000.
It's also incorrect if N is type i65 or larger. Probably best to use APInt which will fix both issues.
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