[llvm] a418be9 - [X86] combineLoad - extract target constants at the minimum scalar element width.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 17 05:44:55 PST 2023
Author: Simon Pilgrim
Date: 2023-12-17T13:44:17Z
New Revision: a418be96de7872f6058207c695ef4698cb1dbb93
URL: https://github.com/llvm/llvm-project/commit/a418be96de7872f6058207c695ef4698cb1dbb93
DIFF: https://github.com/llvm/llvm-project/commit/a418be96de7872f6058207c695ef4698cb1dbb93.diff
LOG: [X86] combineLoad - extract target constants at the minimum scalar element width.
No need to extract at the byte level, and will make it easier to reconstruct constants in a future patch.
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 13f69883ad6d52..b80c766c7ffa75 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -49956,6 +49956,7 @@ static SDValue combineLoad(SDNode *N, SelectionDAG &DAG,
};
// See if we are loading a constant that matches in the lower
// bits of a longer constant (but from a
diff erent constant pool ptr).
+ EVT UserVT = User->getValueType(0);
SDValue UserPtr = cast<MemSDNode>(User)->getBasePtr();
const Constant *LdC = getTargetConstantFromBasePtr(Ptr);
const Constant *UserC = getTargetConstantFromBasePtr(UserPtr);
@@ -49965,9 +49966,12 @@ static SDValue combineLoad(SDNode *N, SelectionDAG &DAG,
if (LdSize < UserSize || !ISD::isNormalLoad(User)) {
APInt Undefs, UserUndefs;
SmallVector<APInt> Bits, UserBits;
- if (getTargetConstantBitsFromNode(SDValue(N, 0), 8, Undefs, Bits) &&
- getTargetConstantBitsFromNode(SDValue(User, 0), 8, UserUndefs,
- UserBits)) {
+ unsigned NumBits = std::min(RegVT.getScalarSizeInBits(),
+ UserVT.getScalarSizeInBits());
+ if (getTargetConstantBitsFromNode(SDValue(N, 0), NumBits, Undefs,
+ Bits) &&
+ getTargetConstantBitsFromNode(SDValue(User, 0), NumBits,
+ UserUndefs, UserBits)) {
if (MatchingBits(Undefs, UserUndefs, Bits, UserBits)) {
SDValue Extract = extractSubVector(
SDValue(User, 0), 0, DAG, SDLoc(N), RegVT.getSizeInBits());
More information about the llvm-commits
mailing list