[llvm] [RISCV][RFC] Prevent folding ADD_LO into load/store if we can't fold all uses. (PR #155935)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 3 16:50:20 PDT 2025
================
@@ -2951,6 +2951,61 @@ static bool isWorthFoldingAdd(SDValue Add) {
return true;
}
+bool isRegImmLoadOrStore(SDNode *User, SDValue Add) {
+ // If the user is a load or store, then the offset is 0.
+ if (User->getOpcode() != ISD::LOAD && User->getOpcode() != ISD::STORE &&
+ User->getOpcode() != RISCVISD::LD_RV32 &&
+ User->getOpcode() != RISCVISD::SD_RV32 &&
+ User->getOpcode() != ISD::ATOMIC_LOAD &&
+ User->getOpcode() != ISD::ATOMIC_STORE)
+ return false;
+
+ // Don't allow stores of the value. It must be used as the address.
+ if (User->getOpcode() == ISD::STORE &&
+ cast<StoreSDNode>(User)->getValue() == Add)
+ return false;
+ if (User->getOpcode() == RISCVISD::SD_RV32 &&
+ (User->getOperand(0) == Add || User->getOperand(1) == Add))
+ return false;
+ if (User->getOpcode() == ISD::ATOMIC_STORE &&
+ cast<AtomicSDNode>(User)->getVal() == Add)
----------------
preames wrote:
Same here, ignore.
https://github.com/llvm/llvm-project/pull/155935
More information about the llvm-commits
mailing list