[PATCH] D37899: [SystemZ] Implement shouldCoalesce() to help regalloc to avoid running out of registers with GR128 regs
Jonas Paulsson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 19 00:08:12 PDT 2017
jonpa updated this revision to Diff 115794.
jonpa marked 3 inline comments as done.
jonpa added a comment.
Updated per review.
https://reviews.llvm.org/D37899
Files:
lib/Target/SystemZ/SystemZRegisterInfo.cpp
lib/Target/SystemZ/SystemZRegisterInfo.h
test/CodeGen/SystemZ/regalloc-GR128.ll
Index: test/CodeGen/SystemZ/regalloc-GR128.ll
===================================================================
--- /dev/null
+++ test/CodeGen/SystemZ/regalloc-GR128.ll
@@ -0,0 +1,9 @@
+; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -O3 -o /dev/null
+;
+; Test that regalloc does not run out of registers
+
+define void @test(i64 %dividend, i64 %divisor) {
+ %rem = urem i64 %dividend, %divisor
+ call void asm sideeffect "", "{r0},{r1},{r2},{r3},{r4},{r5},{r6},{r7},{r8},{r9},{r10},{r11},{r12},{r13},{r14}"(i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 %rem)
+ ret void
+}
Index: lib/Target/SystemZ/SystemZRegisterInfo.h
===================================================================
--- lib/Target/SystemZ/SystemZRegisterInfo.h
+++ lib/Target/SystemZ/SystemZRegisterInfo.h
@@ -59,6 +59,14 @@
void eliminateFrameIndex(MachineBasicBlock::iterator MI,
int SPAdj, unsigned FIOperandNum,
RegScavenger *RS) const override;
+ bool shouldCoalesce(MachineInstr *MI,
+ const TargetRegisterClass *SrcRC,
+ unsigned SubReg,
+ const TargetRegisterClass *DstRC,
+ unsigned DstSubReg,
+ const TargetRegisterClass *NewRC) const override;
+
+ /// \brief SrcRC and DstRC will be morphed into NewRC if this returns true.
unsigned getFrameRegister(const MachineFunction &MF) const override;
};
Index: lib/Target/SystemZ/SystemZRegisterInfo.cpp
===================================================================
--- lib/Target/SystemZ/SystemZRegisterInfo.cpp
+++ lib/Target/SystemZ/SystemZRegisterInfo.cpp
@@ -152,6 +152,21 @@
MI->getOperand(FIOperandNum + 1).ChangeToImmediate(Offset);
}
+bool SystemZRegisterInfo::shouldCoalesce(MachineInstr *MI,
+ const TargetRegisterClass *SrcRC,
+ unsigned SubReg,
+ const TargetRegisterClass *DstRC,
+ unsigned DstSubReg,
+ const TargetRegisterClass *NewRC) const {
+ // Avoid coalescing COPYs of subregs of a GR128 register to prevent
+ // regalloc running out of registers.
+ if (NewRC->hasSubClassEq(&SystemZ::GR128BitRegClass) &&
+ (getRegSizeInBits(*SrcRC) <= 64 || getRegSizeInBits(*DstRC) <= 64))
+ return false;
+
+ return true;
+}
+
unsigned
SystemZRegisterInfo::getFrameRegister(const MachineFunction &MF) const {
const SystemZFrameLowering *TFI = getFrameLowering(MF);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37899.115794.patch
Type: text/x-patch
Size: 2631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170919/159092af/attachment.bin>
More information about the llvm-commits
mailing list