[llvm] [X86] combineVectorSizedSetCCEquality - convert to mayFoldIntoVector helper (PR #172215)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 14 07:33:18 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Simon Pilgrim (RKSimon)
<details>
<summary>Changes</summary>
Add AssumeSingleUse (default = false) argument to mayFoldIntoVector to allow us to match combineVectorSizedSetCCEquality behaviour with AssumeSingleUse=true
Hopefully we can drop the AssumeSingleUse entirely soon, but there are a number of messy test regressions that need handling first
---
Full diff: https://github.com/llvm/llvm-project/pull/172215.diff
1 Files Affected:
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+6-8)
``````````diff
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index c28584cc14991..a85ed96e11158 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -2860,12 +2860,13 @@ bool X86::mayFoldIntoZeroExtend(SDValue Op) {
}
// Return true if its cheap to bitcast this to a vector type.
-static bool mayFoldIntoVector(SDValue Op, const X86Subtarget &Subtarget) {
+static bool mayFoldIntoVector(SDValue Op, const X86Subtarget &Subtarget,
+ bool AssumeSingleUse = false) {
if (peekThroughBitcasts(Op).getValueType().isVector())
return true;
if (isa<ConstantSDNode>(Op) || isa<ConstantFPSDNode>(Op))
return true;
- return X86::mayFoldLoad(Op, Subtarget, /*AssumeSingleUse=*/false,
+ return X86::mayFoldLoad(Op, Subtarget, AssumeSingleUse,
/*IgnoreAlignment=*/true);
}
@@ -23122,12 +23123,9 @@ static SDValue combineVectorSizedSetCCEquality(EVT VT, SDValue X, SDValue Y,
return SDValue();
// Don't perform this combine if constructing the vector will be expensive.
- auto IsVectorBitCastCheap = [](SDValue X) {
- X = peekThroughBitcasts(X);
- return isa<ConstantSDNode>(X) || X.getValueType().isVector() ||
- ISD::isNormalLoad(X.getNode());
- };
- if ((!IsVectorBitCastCheap(X) || !IsVectorBitCastCheap(Y)) &&
+ // TODO: Drop AssumeSingleUse = true override.
+ if ((!mayFoldIntoVector(X, Subtarget, /*AssumeSingleUse=*/true) ||
+ !mayFoldIntoVector(Y, Subtarget, /*AssumeSingleUse=*/true)) &&
!IsOrXorXorTreeCCZero)
return SDValue();
``````````
</details>
https://github.com/llvm/llvm-project/pull/172215
More information about the llvm-commits
mailing list