Skip to content

Commit 25eb105

Browse files
committed
[X86] combineGatherScatter - ensure index / pointer sizes match when converting index shift to scale
The index value will sext/trunc to the pointer size before being scaled Noticed while reviewing llvm#139703
1 parent 2bc9f43 commit 25eb105

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56715,7 +56715,8 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5671556715
if (DCI.isBeforeLegalize()) {
5671656716
// Attempt to move shifted index into the address scale, allows further
5671756717
// index truncation below.
56718-
if (Index.getOpcode() == ISD::SHL && isa<ConstantSDNode>(Scale)) {
56718+
if (Index.getOpcode() == ISD::SHL && IndexSVT == PtrVT &&
56719+
isa<ConstantSDNode>(Scale)) {
5671956720
unsigned ScaleAmt = Scale->getAsZExtVal();
5672056721
assert(isPowerOf2_32(ScaleAmt) && "Scale must be a power of 2");
5672156722
unsigned Log2ScaleAmt = Log2_32(ScaleAmt);

0 commit comments

Comments
 (0)