[llvm] [X86][SelectionDAG] Fix the Gather's base and index by modifying the Scale value (PR #137813)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon May 12 03:15:15 PDT 2025


================
@@ -56652,31 +56652,81 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
   const TargetLowering &TLI = DAG.getTargetLoweringInfo();
 
   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)) {
+      unsigned BitWidth = Index.getScalarValueSizeInBits();
----------------
RKSimon wrote:

Hoist the equivalent IndexWidth above this and remove BitWidth

https://github.com/llvm/llvm-project/pull/137813


More information about the llvm-commits mailing list