[llvm] [X86] combineConstantPoolLoads - correctly merge constant pool loads by pointer and chain (PR #139575)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 12 09:21:22 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Simon Pilgrim (RKSimon)
<details>
<summary>Changes</summary>
We were merging with a larger constant pool load if it didn't have any chain dependencies (and implicitly assuming all uses were on the vector value), instead we should flip this, explicitly check for uses of the vector value and merge the memory chain dependencies with makeEquivalentMemoryOrdering.
As these are constant pool loads we shouldn't expect any changes here, but we should be consistent with how we merge/reuse loads - an upcoming patch for other loads will do the same as we will see changes there.
---
Full diff: https://github.com/llvm/llvm-project/pull/139575.diff
1 Files Affected:
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+2-1)
``````````diff
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index ee295fd83670d..d7105270f3520 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -52880,7 +52880,7 @@ static SDValue combineConstantPoolLoads(SDNode *N, const SDLoc &dl,
(User->getOpcode() == X86ISD::SUBV_BROADCAST_LOAD ||
User->getOpcode() == X86ISD::VBROADCAST_LOAD ||
ISD::isNormalLoad(User)) &&
- UserLd->getChain() == Chain && !User->hasAnyUseOfValue(1) &&
+ UserLd->getChain() == Chain && User->hasAnyUseOfValue(0) &&
User->getValueSizeInBits(0).getFixedValue() >
RegVT.getFixedSizeInBits()) {
EVT UserVT = User->getValueType(0);
@@ -52902,6 +52902,7 @@ static SDValue combineConstantPoolLoads(SDNode *N, const SDLoc &dl,
getTargetConstantBitsFromNode(SDValue(User, 0), NumBits,
UserUndefs, UserBits)) {
if (MatchingBits(Undefs, UserUndefs, Bits, UserBits)) {
+ DAG.makeEquivalentMemoryOrdering(SDValue(N, 1), SDValue(User, 1));
SDValue Extract = extractSubVector(SDValue(User, 0), 0, DAG, dl,
RegVT.getSizeInBits());
Extract = DAG.getBitcast(RegVT, Extract);
``````````
</details>
https://github.com/llvm/llvm-project/pull/139575
More information about the llvm-commits
mailing list