[llvm] [X86] narrowBitOpRMW - allow additional uses of the BTC/R/S result (PR #166376)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 4 07:48:57 PST 2025
================
@@ -53441,8 +53440,20 @@ static SDValue narrowBitOpRMW(StoreSDNode *St, const SDLoc &DL,
Res = DAG.getNode(StoredVal.getOpcode(), DL, MVT::i32, X, Mask);
}
- return DAG.getStore(St->getChain(), DL, Res, NewPtr, St->getPointerInfo(),
- Align(), St->getMemOperand()->getFlags());
+ SDValue NewStore =
+ DAG.getStore(St->getChain(), DL, Res, NewPtr, St->getPointerInfo(),
+ Align(), St->getMemOperand()->getFlags());
+
+ // If there are other uses of StoredVal, replace with a new load of the
+ // whole (updated) value and ensure that any chained dependencies on the
+ // original store are updated to come AFTER the new load.
+ if (!StoredVal.hasOneUse()) {
+ SDValue NewLoad =
+ DAG.getLoad(VT, DL, NewStore, Ld->getBasePtr(), Ld->getMemOperand());
+ DAG.ReplaceAllUsesWith(StoredVal, NewLoad);
+ DAG.ReplaceAllUsesWith(SDValue(St, 0), NewLoad.getValue(1));
----------------
RKSimon wrote:
I've gotten burnt with previous attempts at this code so I might be being over cautious, but I'm wanting to ensure (1) that the reload occurs after the replacement store and (2) anything (load/store) that came after the old store now comes after the reload as well. WDYT?
https://github.com/llvm/llvm-project/pull/166376
More information about the llvm-commits
mailing list