[llvm] [X86] combineGatherScatter - ensure index / pointer sizes match when converting index shift to scale (PR #140110)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri May 16 01:59:19 PDT 2025
https://github.com/RKSimon updated https://github.com/llvm/llvm-project/pull/140110
>From 25eb1059cc26c47e2d3ca68c3e0c83cba43b5990 Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Thu, 15 May 2025 18:43:32 +0100
Subject: [PATCH] [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 #139703
---
llvm/lib/Target/X86/X86ISelLowering.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 9be3b39ce16fa..cc45067fbf300 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -56715,7 +56715,8 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
if (DCI.isBeforeLegalize()) {
// Attempt to move shifted index into the address scale, allows further
// index truncation below.
- if (Index.getOpcode() == ISD::SHL && isa<ConstantSDNode>(Scale)) {
+ if (Index.getOpcode() == ISD::SHL && IndexSVT == PtrVT &&
+ isa<ConstantSDNode>(Scale)) {
unsigned ScaleAmt = Scale->getAsZExtVal();
assert(isPowerOf2_32(ScaleAmt) && "Scale must be a power of 2");
unsigned Log2ScaleAmt = Log2_32(ScaleAmt);
More information about the llvm-commits
mailing list