-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[NFC] [AArch64] Simplify offset scaling in ldst-opt #137044
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
Conversation
@llvm/pr-subscribers-backend-aarch64 Author: Guy David (guy-david) ChangesFull diff: https://github.com/llvm/llvm-project/pull/137044.diff 1 Files Affected:
diff --git a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
index 7c47492cf1a8e..0e26005f6e6be 100644
--- a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
+++ b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
@@ -892,11 +892,10 @@ AArch64LoadStoreOpt::mergeNarrowZeroStores(MachineBasicBlock::iterator I,
OffsetImm = IOffsetInBytes;
int NewOpcode = getMatchingWideOpcode(Opc);
- bool FinalIsScaled = !TII->hasUnscaledLdStOffset(NewOpcode);
-
- // Adjust final offset if the result opcode is a scaled store.
- if (FinalIsScaled) {
- int NewOffsetStride = FinalIsScaled ? TII->getMemScale(NewOpcode) : 1;
+ // Adjust final offset on scaled stores because the new instruction
+ // has a different scale.
+ if (!TII->hasUnscaledLdStOffset(NewOpcode)) {
+ int NewOffsetStride = TII->getMemScale(NewOpcode);
assert(((OffsetImm % NewOffsetStride) == 0) &&
"Offset should be a multiple of the store memory scale");
OffsetImm = OffsetImm / NewOffsetStride;
@@ -906,7 +905,7 @@ AArch64LoadStoreOpt::mergeNarrowZeroStores(MachineBasicBlock::iterator I,
DebugLoc DL = I->getDebugLoc();
MachineBasicBlock *MBB = I->getParent();
MachineInstrBuilder MIB;
- MIB = BuildMI(*MBB, InsertionPoint, DL, TII->get(getMatchingWideOpcode(Opc)))
+ MIB = BuildMI(*MBB, InsertionPoint, DL, TII->get(NewOpcode))
.addReg(isNarrowStore(Opc) ? AArch64::WZR : AArch64::XZR)
.add(BaseRegOp)
.addImm(OffsetImm)
|
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.
Thanks.
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, thanks
No description provided.