-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[RISCV] Correct alignment of one-active (de)interleave cases #150052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RISCV] Correct alignment of one-active (de)interleave cases #150052
Conversation
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.
|
@llvm/pr-subscribers-backend-risc-v Author: Philip Reames (preames) ChangesNoticed 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. Full diff: https://github.com/llvm/llvm-project/pull/150052.diff 1 Files Affected:
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;
}
|
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions cpp -- llvm/lib/Target/RISCV/RISCVInterleavedAccess.cppView the diff from clang-format here.diff --git a/llvm/lib/Target/RISCV/RISCVInterleavedAccess.cpp b/llvm/lib/Target/RISCV/RISCVInterleavedAccess.cpp
index 878401ef4..513dbf2ae 100644
--- a/llvm/lib/Target/RISCV/RISCVInterleavedAccess.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInterleavedAccess.cpp
@@ -304,9 +304,10 @@ 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(), Alignment));
+ Align Alignment =
+ commonAlignment(SI->getAlign(), Index * ScalarSizeInBytes);
+ CI->addParamAttr(1,
+ Attribute::getWithAlignment(CI->getContext(), Alignment));
return true;
}
|
topperc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/27351 Here is the relevant piece of the build log for the reference |
…0052) 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.
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.