[llvm] 115f768 - [RISCV] Correct alignment of one-active (de)interleave cases (#150052)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 22 09:29:24 PDT 2025


Author: Philip Reames
Date: 2025-07-22T09:29:20-07:00
New Revision: 115f768b68d290995b3d9129f44e33cd7c8a11a6

URL: https://github.com/llvm/llvm-project/commit/115f768b68d290995b3d9129f44e33cd7c8a11a6
DIFF: https://github.com/llvm/llvm-project/commit/115f768b68d290995b3d9129f44e33cd7c8a11a6.diff

LOG: [RISCV] Correct alignment of one-active (de)interleave cases (#150052)

Noticed this while going to rewrite the load case as a DAG combine. I
don't have a test case which demonstrates this leading to a miscompile,
but it seems like it could be possible.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVInterleavedAccess.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVInterleavedAccess.cpp b/llvm/lib/Target/RISCV/RISCVInterleavedAccess.cpp
index 25817b6d2707f..878401ef4063f 100644
--- a/llvm/lib/Target/RISCV/RISCVInterleavedAccess.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInterleavedAccess.cpp
@@ -232,6 +232,7 @@ bool RISCVTargetLowering::lowerInterleavedLoad(
         Builder.CreateIntrinsic(Intrinsic::experimental_vp_strided_load,
                                 {VTy, BasePtr->getType(), Stride->getType()},
                                 {BasePtr, Stride, Mask, VL});
+    Alignment = commonAlignment(Alignment, Indices[0] * ScalarSizeInBytes);
     CI->addParamAttr(0,
                      Attribute::getWithAlignment(CI->getContext(), Alignment));
     Shuffles[0]->replaceAllUsesWith(CI);
@@ -303,8 +304,9 @@ bool RISCVTargetLowering::lowerInterleavedStore(StoreInst *SI,
         Intrinsic::experimental_vp_strided_store,
         {Data->getType(), BasePtr->getType(), Stride->getType()},
         {Data, BasePtr, Stride, Mask, VL});
+    Align Alignment = commonAlignment(SI->getAlign(), Index * ScalarSizeInBytes);
     CI->addParamAttr(
-        1, Attribute::getWithAlignment(CI->getContext(), SI->getAlign()));
+        1, Attribute::getWithAlignment(CI->getContext(), Alignment));
 
     return true;
   }


        


More information about the llvm-commits mailing list