[llvm] [DAGCombiner] Remove unnecessary commonAlignment from CombineExtLoad. (PR #81705)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 21:06:18 PST 2024


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/81705

The getAlign function for a load returns the commonAlignment of the "base align" and the offset stored in the MachinePointerInfo.

We're splitting a load here, so we should take the base alignment from the original load without any offset that may already exist in the original load. The new load can then maintain its own alignment using just the base alignment and its own offset.

Noticed by inspection.

>From 23e7c629e79e95e15571bdd2691434ec011a63d4 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Tue, 13 Feb 2024 20:58:49 -0800
Subject: [PATCH] [DAGCombiner] Remove unnecessary commonAlignment from
 CombineExtLoad.

The getAlign function for a load returns the commonAlignment of
the "base align" and the offset stored in the MachinePointerInfo.

We're splitting a load here, so we should take the base alignment
from the original load without any offset that may already exist
in the original load. The new load can then maintain its own
alignment using just the base alignment and its own offset.

Noticed by inspection.
---
 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 52011e593f2e0a..f35466fb607360 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -12971,12 +12971,12 @@ SDValue DAGCombiner::CombineExtLoad(SDNode *N) {
   SDValue BasePtr = LN0->getBasePtr();
   for (unsigned Idx = 0; Idx < NumSplits; Idx++) {
     const unsigned Offset = Idx * Stride;
-    const Align Align = commonAlignment(LN0->getAlign(), Offset);
 
-    SDValue SplitLoad = DAG.getExtLoad(
-        ExtType, SDLoc(LN0), SplitDstVT, LN0->getChain(), BasePtr,
-        LN0->getPointerInfo().getWithOffset(Offset), SplitSrcVT, Align,
-        LN0->getMemOperand()->getFlags(), LN0->getAAInfo());
+    SDValue SplitLoad =
+        DAG.getExtLoad(ExtType, SDLoc(LN0), SplitDstVT, LN0->getChain(),
+                       BasePtr, LN0->getPointerInfo().getWithOffset(Offset),
+                       SplitSrcVT, LN0->getOriginalAlign(),
+                       LN0->getMemOperand()->getFlags(), LN0->getAAInfo());
 
     BasePtr = DAG.getMemBasePlusOffset(BasePtr, TypeSize::getFixed(Stride), DL);
 



More information about the llvm-commits mailing list