[llvm] 636412b - [AArch64ExpandPseudos] Preserve renamable state when expanding MOVi64 & co.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 12 03:29:30 PST 2019
Author: Florian Hahn
Date: 2019-11-12T11:29:04Z
New Revision: 636412bf31fc4285d63faeea67e4d71e44e3799c
URL: https://github.com/llvm/llvm-project/commit/636412bf31fc4285d63faeea67e4d71e44e3799c
DIFF: https://github.com/llvm/llvm-project/commit/636412bf31fc4285d63faeea67e4d71e44e3799c.diff
LOG: [AArch64ExpandPseudos] Preserve renamable state when expanding MOVi64 & co.
If the MOVi operand was renamable, the operands of the expanded
instructions are also renamable.
Reviewers: thegameg, samparker, zatrazz
Reviewed By: thegameg
Differential Revision: https://reviews.llvm.org/D70061
Added:
llvm/test/CodeGen/AArch64/expand-movi-renamable.mir
Modified:
llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp b/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
index 082e17e44d04..09a525d4b067 100644
--- a/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
@@ -110,6 +110,8 @@ bool AArch64ExpandPseudo::expandMOVImm(MachineBasicBlock &MBB,
unsigned BitSize) {
MachineInstr &MI = *MBBI;
Register DstReg = MI.getOperand(0).getReg();
+ uint64_t RenamableState =
+ MI.getOperand(0).isRenamable() ? RegState::Renamable : 0;
uint64_t Imm = MI.getOperand(1).getImm();
if (DstReg == AArch64::XZR || DstReg == AArch64::WZR) {
@@ -144,7 +146,8 @@ bool AArch64ExpandPseudo::expandMOVImm(MachineBasicBlock &MBB,
bool DstIsDead = MI.getOperand(0).isDead();
MIBS.push_back(BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(I->Opcode))
.addReg(DstReg, RegState::Define |
- getDeadRegState(DstIsDead && LastItem))
+ getDeadRegState(DstIsDead && LastItem) |
+ RenamableState)
.addImm(I->Op1)
.addImm(I->Op2));
} break;
@@ -155,7 +158,8 @@ bool AArch64ExpandPseudo::expandMOVImm(MachineBasicBlock &MBB,
MIBS.push_back(BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(I->Opcode))
.addReg(DstReg,
RegState::Define |
- getDeadRegState(DstIsDead && LastItem))
+ getDeadRegState(DstIsDead && LastItem) |
+ RenamableState)
.addReg(DstReg)
.addImm(I->Op1)
.addImm(I->Op2));
diff --git a/llvm/test/CodeGen/AArch64/expand-movi-renamable.mir b/llvm/test/CodeGen/AArch64/expand-movi-renamable.mir
new file mode 100644
index 000000000000..a9270d9d9e17
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/expand-movi-renamable.mir
@@ -0,0 +1,102 @@
+# RUN: llc -run-pass=aarch64-expand-pseudo -mtriple=arm64-apple-darwin -o - %s | FileCheck %s
+
+# Check that we preserve renamble when expanding MOVi32imm/MOVi64imm.
+#
+---
+# CHECK-LABEL: name: test_i32
+# CHECK-LABEL: bb.0:
+# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 32, 0
+# CHECK-NEXT: renamable $w8 = MOVZWi 4, 0
+# CHECK-NEXT: STRWui killed renamable $w8, $sp, 0
+# CHECK-NEXT: $w8 = MOVZWi 45926, 0
+# CHECK-NEXT: $w8 = MOVKWi $w8, 102, 16
+# CHECK-NEXT: STRWui killed renamable $w8, $sp, 1
+# CHECK-NEXT: renamable $w8 = MOVZWi 10319, 0
+# CHECK-NEXT: renamable $w8 = MOVKWi $w8, 2942, 16
+# CHECK-NEXT: STRWui killed renamable $w8, $sp, 2
+# CHECK-NEXT: renamable $w8 = MOVZWi 30600, 0
+# CHECK-NEXT: renamable $w8 = MOVKWi $w8, 21862, 16
+# CHECK-NEXT: STRWui killed renamable $w8, $sp, 3
+# CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 32, 0
+# CHECK-NEXT: RET undef $lr
+#
+name: test_i32
+alignment: 8
+tracksRegLiveness: true
+frameInfo:
+ stackSize: 32
+ maxAlignment: 4
+ maxCallFrameSize: 0
+ localFrameSize: 24
+stack:
+ - { id: 0, offset: -4, size: 4, alignment: 4, local-offset: -4 }
+ - { id: 1, offset: -8, size: 4, alignment: 4, local-offset: -8 }
+ - { id: 2, offset: -12, size: 4, alignment: 4, local-offset: -12 }
+ - { id: 3, offset: -16, size: 4, alignment: 4, local-offset: -16 }
+machineFunctionInfo: {}
+body: |
+ bb.0:
+ $sp = frame-setup SUBXri $sp, 32, 0
+ renamable $w8 = MOVi32imm 4
+ STRWui killed renamable $w8, $sp, 0
+ $w8 = MOVi32imm 6730598
+ STRWui killed renamable $w8, $sp, 1
+ renamable $w8 = MOVi32imm 192817231
+ STRWui killed renamable $w8, $sp, 2
+ renamable $w8 = MOVi32imm 1234605616436508552
+ STRWui killed renamable $w8, $sp, 3
+ $sp = frame-destroy ADDXri $sp, 32, 0
+ RET_ReallyLR
+
+...
+---
+# CHECK-LABEL: name: test_i64
+# CHECK-LABEL: bb.0:
+# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 32, 0
+# CHECK-NEXT: renamable $x8 = MOVZXi 4, 0
+# CHECK-NEXT: STRXui killed renamable $x8, $sp, 0
+# CHECK-NEXT: $x8 = MOVZXi 45926, 0
+# CHECK-NEXT: $x8 = MOVKXi $x8, 102, 16
+# CHECK-NEXT: STRXui killed renamable $x8, $sp, 1
+# CHECK-NEXT: renamable $x8 = MOVNXi 25166, 0
+# CHECK-NEXT: renamable $x8 = MOVKXi $x8, 55686, 16
+# CHECK-NEXT: renamable $x8 = MOVKXi $x8, 63160, 32
+# CHECK-NEXT: STRXui killed renamable $x8, $sp, 2
+# CHECK-NEXT: renamable $x8 = MOVZXi 30600, 0
+# CHECK-NEXT: renamable $x8 = MOVKXi $x8, 21862, 16
+# CHECK-NEXT: renamable $x8 = MOVKXi $x8, 13124, 32
+# CHECK-NEXT: renamable $x8 = MOVKXi $x8, 4386, 48
+# CHECK-NEXT: STRXui killed renamable $x8, $sp, 3
+# CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 32, 0
+# CHECK-NEXT: RET undef $lr
+#
+name: test_i64
+alignment: 8
+tracksRegLiveness: true
+frameInfo:
+ stackSize: 32
+ maxAlignment: 4
+ maxCallFrameSize: 0
+ localFrameSize: 32
+stack:
+ - { id: 0, offset: -8, size: 8, alignment: 4, local-offset: -8 }
+ - { id: 1, offset: -16, size: 8, alignment: 4, local-offset: -16 }
+ - { id: 2, offset: -24, size: 8, alignment: 4, local-offset: -24}
+ - { id: 3, offset: -32, size: 8, alignment: 4, local-offset: -32 }
+machineFunctionInfo: {}
+body: |
+ bb.0:
+ $sp = frame-setup SUBXri $sp, 32, 0
+ renamable $x8 = MOVi64imm 4
+ STRXui killed renamable $x8, $sp, 0
+ $x8 = MOVi64imm 6730598
+ STRXui killed renamable $x8, $sp, 1
+ renamable $x8 = MOVi64imm -10201192817231
+ STRXui killed renamable $x8, $sp, 2
+ renamable $x8 = MOVi64imm 1234605616436508552
+ STRXui killed renamable $x8, $sp, 3
+ $sp = frame-destroy ADDXri $sp, 32, 0
+ RET_ReallyLR
+
+...
+---
More information about the llvm-commits
mailing list