Skip to content

Commit d4f38f4

Browse files
authored
[LLVM][ARM][CodeGen]Define branch instruction alignment for m85 and m7 (#109647)
Branch instruction alignments were not defined for cortex-m85 and cortex-m7 which misses an optimisation opportunity. With this patch we see performance improvements as high as 5% on some benchmarks with most around 1%.
1 parent a3cf01d commit d4f38f4

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

llvm/lib/Target/ARM/ARMFeatures.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ def FeaturePref32BitThumb : SubtargetFeature<"32bit", "Prefers32BitThumb", "true
375375
def FeaturePrefLoopAlign32 : SubtargetFeature<"loop-align", "PrefLoopLogAlignment","2",
376376
"Prefer 32-bit alignment for loops">;
377377

378+
def FeaturePrefLoopAlign64 : SubtargetFeature<"loop-align-64", "PrefLoopLogAlignment","3",
379+
"Prefer 64-bit alignment for loops">;
380+
378381
def FeatureMVEVectorCostFactor1 : SubtargetFeature<"mve1beat", "MVEVectorCostFactor", "4",
379382
"Model MVE instructions as a 1 beat per tick architecture">;
380383

llvm/lib/Target/ARM/ARMProcessors.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ def : ProcessorModel<"cortex-m4", CortexM4Model, [ARMv7em,
344344
def : ProcessorModel<"cortex-m7", CortexM7Model, [ARMv7em,
345345
ProcM7,
346346
FeatureFPARMv8_D16,
347+
FeaturePrefLoopAlign64,
347348
FeatureUseMIPipeliner,
348349
FeatureUseMISched]>;
349350

@@ -385,6 +386,7 @@ def : ProcessorModel<"cortex-m85", CortexM85Model, [ARMv81mMainline,
385386
FeatureDSP,
386387
FeatureFPARMv8_D16,
387388
FeaturePACBTI,
389+
FeaturePrefLoopAlign64,
388390
FeatureUseMISched,
389391
HasMVEFloatOps]>;
390392

llvm/test/CodeGen/ARM/preferred-function-alignment.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m85 < %s | FileCheck --check-prefixes=CHECK,ALIGN-16,ALIGN-CS-16 %s
1+
; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m85 < %s | FileCheck --check-prefixes=CHECK,ALIGN-64,ALIGN-CS-16 %s
22
; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m23 < %s | FileCheck --check-prefixes=CHECK,ALIGN-16,ALIGN-CS-16 %s
33

44
; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-a5 < %s | FileCheck --check-prefixes=CHECK,ALIGN-32,ALIGN-CS-32 %s
55
; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m33 < %s | FileCheck --check-prefixes=CHECK,ALIGN-32,ALIGN-CS-16 %s
66
; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m55 < %s | FileCheck --check-prefixes=CHECK,ALIGN-32,ALIGN-CS-16 %s
7-
7+
; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m7 < %s | FileCheck --check-prefixes=CHECK,ALIGN-64,ALIGN-CS-16 %s
88

99
; CHECK-LABEL: test
1010
; ALIGN-16: .p2align 1
1111
; ALIGN-32: .p2align 2
12+
; ALIGN-64: .p2align 3
1213

1314
define void @test() {
1415
ret void

0 commit comments

Comments
 (0)