Skip to content

Commit a418be9

Browse files
committed
[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.
1 parent b6cce87 commit a418be9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49956,6 +49956,7 @@ static SDValue combineLoad(SDNode *N, SelectionDAG &DAG,
4995649956
};
4995749957
// See if we are loading a constant that matches in the lower
4995849958
// bits of a longer constant (but from a different constant pool ptr).
49959+
EVT UserVT = User->getValueType(0);
4995949960
SDValue UserPtr = cast<MemSDNode>(User)->getBasePtr();
4996049961
const Constant *LdC = getTargetConstantFromBasePtr(Ptr);
4996149962
const Constant *UserC = getTargetConstantFromBasePtr(UserPtr);
@@ -49965,9 +49966,12 @@ static SDValue combineLoad(SDNode *N, SelectionDAG &DAG,
4996549966
if (LdSize < UserSize || !ISD::isNormalLoad(User)) {
4996649967
APInt Undefs, UserUndefs;
4996749968
SmallVector<APInt> Bits, UserBits;
49968-
if (getTargetConstantBitsFromNode(SDValue(N, 0), 8, Undefs, Bits) &&
49969-
getTargetConstantBitsFromNode(SDValue(User, 0), 8, UserUndefs,
49970-
UserBits)) {
49969+
unsigned NumBits = std::min(RegVT.getScalarSizeInBits(),
49970+
UserVT.getScalarSizeInBits());
49971+
if (getTargetConstantBitsFromNode(SDValue(N, 0), NumBits, Undefs,
49972+
Bits) &&
49973+
getTargetConstantBitsFromNode(SDValue(User, 0), NumBits,
49974+
UserUndefs, UserBits)) {
4997149975
if (MatchingBits(Undefs, UserUndefs, Bits, UserBits)) {
4997249976
SDValue Extract = extractSubVector(
4997349977
SDValue(User, 0), 0, DAG, SDLoc(N), RegVT.getSizeInBits());

0 commit comments

Comments
 (0)