[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
Wed Nov 5 00:26:46 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:
OK. I'll drop the line - we're replacing the old store with NewStore so that chain should be replaced automatically.
https://github.com/llvm/llvm-project/pull/166376
More information about the llvm-commits
mailing list