-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[SelectionDAG] Remove pointer from MMO for VP strided load/store. #82667
Conversation
MachineIR alias analysis assumes that only bytes after the pointer will be accessed. This is incorrect if the stride is negative.
@llvm/pr-subscribers-llvm-selectiondag Author: Craig Topper (topperc) ChangesMachineIR alias analysis assumes that only bytes after the pointer will be accessed. This is incorrect if the stride is negative. This is causing miscompiles in our downstream after SLP started making strided loads. Full diff: https://github.com/llvm/llvm-project/pull/82667.diff 1 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index e893a5b616d33e..3e53f3318a374a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -8017,8 +8017,9 @@ void SelectionDAGBuilder::visitVPStridedLoad(
MemoryLocation ML = MemoryLocation::getAfter(PtrOperand, AAInfo);
bool AddToChain = !AA || !AA->pointsToConstantMemory(ML);
SDValue InChain = AddToChain ? DAG.getRoot() : DAG.getEntryNode();
+ unsigned AS = PtrOperand->getPointerAddressSpace();
MachineMemOperand *MMO = DAG.getMachineFunction().getMachineMemOperand(
- MachinePointerInfo(PtrOperand), MachineMemOperand::MOLoad,
+ MachinePointerInfo(AS), MachineMemOperand::MOLoad,
MemoryLocation::UnknownSize, *Alignment, AAInfo, Ranges);
SDValue LD = DAG.getStridedLoadVP(VT, DL, InChain, OpValues[0], OpValues[1],
@@ -8039,8 +8040,9 @@ void SelectionDAGBuilder::visitVPStridedStore(
if (!Alignment)
Alignment = DAG.getEVTAlign(VT.getScalarType());
AAMDNodes AAInfo = VPIntrin.getAAMetadata();
+ unsigned AS = PtrOperand->getPointerAddressSpace();
MachineMemOperand *MMO = DAG.getMachineFunction().getMachineMemOperand(
- MachinePointerInfo(PtrOperand), MachineMemOperand::MOStore,
+ MachinePointerInfo(AS), MachineMemOperand::MOStore,
MemoryLocation::UnknownSize, *Alignment, AAInfo);
SDValue ST = DAG.getStridedStoreVP(
|
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.
testcase?
@arsenm do you want a test case for the scheduling issue? Or just a test to show we don't put a pointer in the MMO? |
Either I guess. The MMO is more targeted but the scheduling is more interesting |
MachineIR alias analysis assumes that only bytes after the pointer will be accessed. This is incorrect if the stride is negative.
This is causing miscompiles in our downstream after SLP started making strided loads.
Fixes #82657