Skip to content
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

[PowerPC][CodeGen] Exploit STMW and LMW in 32-bit big-endian mode. #74415

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

EsmeYi
Copy link
Contributor

@EsmeYi EsmeYi commented Dec 5, 2023

This patch exploits the stmw and lmw instructions. Max to r13~r31 continuous store/load instructions can be merged to stmw/lmw, which saves code size.

Copy link

github-actions bot commented Dec 5, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

llvm/lib/Target/PowerPC/PPCFrameLowering.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/PowerPC/PPCFrameLowering.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Outdated Show resolved Hide resolved
llvm/test/CodeGen/PowerPC/stm-lm-merge.ll Outdated Show resolved Hide resolved
llvm/lib/Target/PowerPC/PPCFrameLowering.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/PowerPC/PPCFrameLowering.cpp Outdated Show resolved Hide resolved

// Record the first reg that STMW/LMW are going to merge since STMW/LMW save
// from rN to r31.
MergeFrom = CSI[BeginI].getReg();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary complicating. LMW/STMW only applies for AIX 32-bit. For AIX, we just need to find the first GPR(assume the CSI is sorted on ascending ordering), that would be the MergeFrom. On AIX, CSRs always contain the lowest GPR till R31.

; CHECK-NEXT: mtlr 0
; CHECK-NEXT: bl

@a = external local_unnamed_addr global i32, align 4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case is too complicated. Please use below one

define dso_local void @test_simple() #0 {
entry:
  call void asm sideeffect "nop", "~{r16}"()
  ret void
}

static cl::opt<bool>
EnableLoadStoreMultiple("ppc-enable-load-store-multiple",
cl::desc("Enable load/store multiple (only "
"support in 32-bit big-endian mode)."),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of 32-bit big-endian, maybe it is better to limit this under AIX-32 bit.

@EsmeYi EsmeYi force-pushed the esme/StmLm branch 2 times, most recently from deb9ba4 to 6243b1b Compare December 12, 2023 06:18
@EsmeYi EsmeYi marked this pull request as ready for review December 21, 2023 07:37
@EsmeYi EsmeYi force-pushed the esme/StmLm branch 2 times, most recently from 89e7085 to c46a2f6 Compare December 28, 2023 05:09
@@ -2399,6 +2405,43 @@ bool PPCFrameLowering::assignCalleeSavedSpillSlots(
return AllSpilledToReg;
}

static void findContinuousLoadStore(const MachineFunction *MF,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static void findContinuousLoadStore(const MachineFunction *MF,
static bool findConsecutiveLoadStore(const MachineFunction *MF,

Return true if consecutive ld/std found.

ArrayRef<CalleeSavedInfo> CSI,
Register &MergeFrom) {
const MachineFrameInfo &MFI = MF->getFrameInfo();
int64_t Offset = MFI.estimateStackSize(*MF);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use PPCFrameLowering::determineFrameLayout() to determine the stack size on PPC?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants