Skip to content

Commit a1cf4d9

Browse files
committed
[AArch64][GlobalISel] Enable the localizer for optimized builds.
Despite the fact that the localizer's original motivation was to fix horrendous constant spilling at -O0, shortening live ranges still has net benefits even with optimizations enabled. On an -Os build of CTMark, doing this improves code size by 0.5% geomean. There are a few regressions, bullet increasing in size by 0.5%. One example from bullet where code size increased slightly was due to GlobalISel actually now generating the same code as SelectionDAG. So we actually have an opportunity in future to implement better heuristics for localization and therefore be *better* than SDAG in some cases. In relation to other optimizations though that one is relatively minor. Differential Revision: https://reviews.llvm.org/D67303 llvm-svn: 371266
1 parent 7d677ad commit a1cf4d9

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

llvm/lib/Target/AArch64/AArch64TargetMachine.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,7 @@ bool AArch64PassConfig::addRegBankSelect() {
518518
}
519519

520520
void AArch64PassConfig::addPreGlobalInstructionSelect() {
521-
// Workaround the deficiency of the fast register allocator.
522-
if (TM->getOptLevel() == CodeGenOpt::None)
523-
addPass(new Localizer());
521+
addPass(new Localizer());
524522
}
525523

526524
bool AArch64PassConfig::addGlobalInstructionSelect() {

llvm/test/CodeGen/AArch64/GlobalISel/gisel-commandline-option.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
; VERIFY-NEXT: Verify generated machine code
5252
; ENABLED-NEXT: RegBankSelect
5353
; VERIFY-NEXT: Verify generated machine code
54-
; ENABLED-O0-NEXT: Localizer
54+
; ENABLED-NEXT: Localizer
5555
; VERIFY-O0-NEXT: Verify generated machine code
5656
; ENABLED-NEXT: Analysis for ComputingKnownBits
5757
; ENABLED-NEXT: InstructionSelect

llvm/test/CodeGen/AArch64/GlobalISel/localizer-in-O0-pipeline.mir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ registers:
6060

6161
# Second block will get the constant 1.0 when the localizer is enabled.
6262
# CHECK: bb.1.{{[a-zA-Z0-9]+}}:
63-
# OPT-NOT: G_FCONSTANT
63+
# OPT: [[FONE:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 1.000000e+00
6464
# OPTNONE: [[FONE:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 1.000000e+00
6565
# CHECK: G_BR %bb.3
6666

6767
# Thrid block will get the constant 2.0 when the localizer is enabled.
6868
# CHECK: bb.2.{{[a-zA-Z0-9]+}}:
69-
# OPT-NOT: G_FCONSTANT
69+
# OPT: [[FTWO:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 2.000000e+00
7070
# OPTNONE: [[FTWO:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 2.000000e+00
7171

7272
# CHECK: bb.3.end
7373
# OPTNONE: %2:fpr(s32) = PHI [[FONE]](s32), %bb.1, [[FTWO]](s32), %bb.2
74-
# OPT: %2:fpr(s32) = PHI %4(s32), %bb.1, %5(s32), %bb.2
74+
# OPT: %2:fpr(s32) = PHI [[FONE]](s32), %bb.1, [[FTWO]](s32), %bb.2
7575
# CHECK-NEXT: G_FADD %0, %2
7676
body: |
7777
bb.0 (%ir-block.0):

llvm/test/CodeGen/AArch64/GlobalISel/swifterror.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ handler:
9898
define float @foo_if(%swift_error** swifterror %error_ptr_ref, i32 %cc) {
9999
; CHECK-LABEL: foo_if:
100100
; CHECK: cbz w0
101-
; CHECK: mov [[ID:w[0-9]+]], #1
102101
; CHECK: mov w0, #16
103102
; CHECK: malloc
103+
; CHECK: mov [[ID:w[0-9]+]], #1
104104
; CHECK: strb [[ID]], [x0, #8]
105105
; CHECK: mov x21, x0
106106
; CHECK-NOT: x21

0 commit comments

Comments
 (0)