[PATCH] D158673: [SDAG][RISCV] Avoid neg instructions when lowering atomic_load_sub with a constant rhs
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 25 12:29:32 PDT 2023
craig.topper added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:3143
+ if (RHS->getOpcode() == ISD::SIGN_EXTEND_INREG &&
+ RHS->getOperand(0).getValueType() == VT)
+ RHS = RHS->getOperand(0);
----------------
This is not the correct way to find out the sign_extend_inreg can be removed. Operand 0 of SIGN_EXTEND_INREG always matches the destination type which means it always matches VT if its present. So this will delete any SIGN_EXTEND_INREG no matter what.
The check you really need is
```
if (RHS->getOpcode() == ISD::SIGN_EXTEND_INREG &&
cast<VTSDNode>(RHS->getOperand(1))->getVT() == AN->getMemoryVT())
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158673/new/
https://reviews.llvm.org/D158673
More information about the llvm-commits
mailing list