Skip to content

Commit 8e3f59b

Browse files
committed
[AArch64] Add option to enable/disable load-store renaming.
This patch adds a new option to enable/disable register renaming in the load-store optimizer. Defaults to disabled, as there is a potential mis-compile caused by this.
1 parent 223a209 commit 8e3f59b

9 files changed

+28
-15
lines changed

llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ static cl::opt<unsigned> LdStLimit("aarch64-load-store-scan-limit",
6666
static cl::opt<unsigned> UpdateLimit("aarch64-update-scan-limit", cl::init(100),
6767
cl::Hidden);
6868

69+
// Enable register renaming to find additional store pairing opportunities.
70+
static cl::opt<bool> EnableRenaming("aarch64-load-store-renaming",
71+
cl::init(false), cl::Hidden);
72+
6973
#define AARCH64_LOAD_STORE_OPT_NAME "AArch64 load / store optimization pass"
7074

7175
namespace {
@@ -1446,6 +1450,9 @@ AArch64LoadStoreOpt::findMatchingInsn(MachineBasicBlock::iterator I,
14461450
bool IsPromotableZeroStore = isPromotableZeroStoreInst(FirstMI);
14471451

14481452
Optional<bool> MaybeCanRename = None;
1453+
if (!EnableRenaming)
1454+
MaybeCanRename = {false};
1455+
14491456
SmallPtrSet<const TargetRegisterClass *, 5> RequiredClasses;
14501457
LiveRegUnits UsedInBetween;
14511458
UsedInBetween.init(*TRI);

llvm/test/CodeGen/AArch64/arm64-abi-varargs.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc < %s -mtriple=arm64-apple-ios7.0.0 -mcpu=cyclone -enable-misched=false | FileCheck %s
2+
; RUN: llc -aarch64-load-store-renaming=true < %s -mtriple=arm64-apple-ios7.0.0 -mcpu=cyclone -enable-misched=false | FileCheck %s
33

44
; rdar://13625505
55
; Here we have 9 fixed integer arguments the 9th argument in on stack, the

llvm/test/CodeGen/AArch64/arm64-abi_align.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; RUN: llc -fast-isel-sink-local-values < %s -mtriple=arm64-apple-darwin -mcpu=cyclone -enable-misched=false -frame-pointer=all | FileCheck %s
2-
; RUN: llc -fast-isel-sink-local-values < %s -mtriple=arm64-apple-darwin -O0 -frame-pointer=all -fast-isel | FileCheck -check-prefix=FAST %s
1+
; RUN: llc -fast-isel-sink-local-values -aarch64-load-store-renaming=true < %s -mtriple=arm64-apple-darwin -mcpu=cyclone -enable-misched=false -frame-pointer=all | FileCheck %s
2+
; RUN: llc -fast-isel-sink-local-values -aarch64-load-store-renaming=true < %s -mtriple=arm64-apple-darwin -O0 -frame-pointer=all -fast-isel | FileCheck -check-prefix=FAST %s
33

44
; rdar://12648441
55
; Generated from arm64-arguments.c with -O2.

llvm/test/CodeGen/AArch64/arm64-variadic-aapcs.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -verify-machineinstrs -mtriple=arm64-linux-gnu -pre-RA-sched=linearize -enable-misched=false -disable-post-ra < %s | FileCheck %s
1+
; RUN: llc -aarch64-load-store-renaming=true -verify-machineinstrs -mtriple=arm64-linux-gnu -pre-RA-sched=linearize -enable-misched=false -disable-post-ra < %s | FileCheck %s
22

33
%va_list = type {i8*, i8*, i8*, i32, i32}
44

llvm/test/CodeGen/AArch64/machine-outliner-remarks.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
; CHECK-SAME: Bytes from outlining all occurrences (16) >=
55
; CHECK-SAME: Unoutlined instruction bytes (16)
66
; CHECK-SAME: (Also found at: <UNKNOWN LOCATION>)
7-
; CHECK: remark: <unknown>:0:0: Saved 36 bytes by outlining 11 instructions
7+
; CHECK: remark: <unknown>:0:0: Saved 48 bytes by outlining 14 instructions
88
; CHECK-SAME: from 2 locations. (Found at: <UNKNOWN LOCATION>,
99
; CHECK-SAME: <UNKNOWN LOCATION>)
1010
; RUN: llc %s -enable-machine-outliner -mtriple=aarch64-unknown-unknown -o /dev/null -pass-remarks-missed=machine-outliner -pass-remarks-output=%t.yaml
@@ -38,10 +38,10 @@
3838
; YAML-NEXT: Function: OUTLINED_FUNCTION_0
3939
; YAML-NEXT: Args:
4040
; YAML-NEXT: - String: 'Saved '
41-
; YAML-NEXT: - OutliningBenefit: '36'
41+
; YAML-NEXT: - OutliningBenefit: '48'
4242
; YAML-NEXT: - String: ' bytes by '
4343
; YAML-NEXT: - String: 'outlining '
44-
; YAML-NEXT: - Length: '11'
44+
; YAML-NEXT: - Length: '14'
4545
; YAML-NEXT: - String: ' instructions '
4646
; YAML-NEXT: - String: 'from '
4747
; YAML-NEXT: - NumOccurrences: '2'

llvm/test/CodeGen/AArch64/machine-outliner.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; RUN: llc -verify-machineinstrs -enable-machine-outliner -mtriple=aarch64-apple-darwin < %s | FileCheck %s
2-
; RUN: llc -verify-machineinstrs -enable-machine-outliner -mtriple=aarch64-apple-darwin -mcpu=cortex-a53 -enable-misched=false < %s | FileCheck %s
1+
; RUN: llc -verify-machineinstrs -enable-machine-outliner -aarch64-load-store-renaming=true -mtriple=aarch64-apple-darwin < %s | FileCheck %s
2+
; RUN: llc -verify-machineinstrs -enable-machine-outliner -aarch64-load-store-renaming=true -mtriple=aarch64-apple-darwin -mcpu=cortex-a53 -enable-misched=false < %s | FileCheck %s
33
; RUN: llc -verify-machineinstrs -enable-machine-outliner -enable-linkonceodr-outlining -mtriple=aarch64-apple-darwin < %s | FileCheck %s -check-prefix=ODR
44
; RUN: llc -verify-machineinstrs -enable-machine-outliner -mtriple=aarch64-apple-darwin -stop-after=machine-outliner < %s | FileCheck %s -check-prefix=TARGET_FEATURES
55

llvm/test/CodeGen/AArch64/stp-opt-with-renaming-debug.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RUN: llc -run-pass=aarch64-ldst-opt -mtriple=arm64-apple-iphoneos -verify-machineinstrs -o - %s | FileCheck %s
1+
# RUN: llc -run-pass=aarch64-ldst-opt -mtriple=arm64-apple-iphoneos -aarch64-load-store-renaming=true -verify-machineinstrs -o - %s | FileCheck %s
22
--- |
33
define void @test_dbg_value1() #0 { ret void }
44
define void @test_dbg_value2() #0 { ret void }

llvm/test/CodeGen/AArch64/stp-opt-with-renaming-reserved-regs.mir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# RUN: llc -run-pass=aarch64-ldst-opt -mattr=+reserve-x10 -mattr=+reserve-x11 \
2-
# RUN: -mattr=+reserve-x15 -mtriple=arm64-apple-iphoneos -verify-machineinstrs \
1+
# RUN: llc -run-pass=aarch64-ldst-opt -aarch64-load-store-renaming=true -mattr=+reserve-x10 \
2+
# RUN: -mattr=+reserve-x11 -mattr=+reserve-x15 -mtriple=arm64-apple-iphoneos -verify-machineinstrs \
33
# RUN: -o - %s | FileCheck --check-prefix=CHECK --check-prefix=PRESERVED %s
44

5-
# RUN: llc -run-pass=aarch64-ldst-opt -mtriple=arm64-apple-iphoneos -verify-machineinstrs \
6-
# RUN: -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOPRES %s
5+
# RUN: llc -run-pass=aarch64-ldst-opt -aarch64-load-store-renaming=true -mtriple=arm64-apple-iphoneos \
6+
# RUN: -verify-machineinstrs -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOPRES %s
77

88

99
# Make sure we do not pick reserved registers. For test1, we would pick x10,

llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
# RUN: llc -run-pass=aarch64-ldst-opt -mtriple=arm64-apple-iphoneos -verify-machineinstrs -o - %s | FileCheck %s
1+
# RUN: llc -run-pass=aarch64-ldst-opt -mtriple=arm64-apple-iphoneos -verify-machineinstrs -aarch64-load-store-renaming=true -o - %s | FileCheck %s
2+
# RUN: llc -run-pass=aarch64-ldst-opt -mtriple=arm64-apple-iphoneos -verify-machineinstrs -o - %s | FileCheck --check-prefix=NO-RENAME %s
23

4+
# NO-RENAME-NOT: STP
5+
# NO-RENAME: test12
6+
# NO-RENAME: STP
7+
# NO-RENAME-NOT: STP
8+
#
39
---
410
# CHECK-LABEL: name: test1
511
# CHECK: bb.0:

0 commit comments

Comments
 (0)