Skip to content

Commit f3c92a0

Browse files
authored
[RISCV] Make PostRAScheduler a target feature (#68692)
This is what AArch64 has done in https://reviews.llvm.org/D20762. Tests are added in macro fusion tests, which uncover a bug that DAG mutations don't take effect.
1 parent 15d78ce commit f3c92a0

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,9 @@ def FeatureUnalignedVectorMem
902902
"true", "Has reasonably performant unaligned vector "
903903
"loads and stores">;
904904

905+
def FeaturePostRAScheduler : SubtargetFeature<"use-postra-scheduler",
906+
"UsePostRAScheduler", "true", "Schedule again after register allocation">;
907+
905908
def TuneNoOptimizedZeroStrideLoad
906909
: SubtargetFeature<"no-optimized-zero-stride-load", "HasOptimizedZeroStrideLoad",
907910
"false", "Hasn't optimized (perform fewer memory operations)"

llvm/lib/Target/RISCV/RISCVSubtarget.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
107107
}
108108
bool enableMachineScheduler() const override { return true; }
109109

110+
bool enablePostRAScheduler() const override {
111+
return getSchedModel().PostRAScheduler || UsePostRAScheduler;
112+
}
113+
110114
Align getPrefFunctionAlignment() const {
111115
return Align(TuneInfo->PrefFunctionAlignment);
112116
}

llvm/test/CodeGen/RISCV/macro-fusion-lui-addi.ll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
;RUN: | FileCheck %s --check-prefix=NOFUSION
44
;RUN: llc < %s -mtriple=riscv64 -mattr=+f,+lui-addi-fusion -mcpu=sifive-u74 \
55
;RUN: -target-abi=lp64f | FileCheck %s --check-prefix=FUSION
6+
;RUN: llc < %s -mtriple=riscv64 -mattr=+f,+lui-addi-fusion,+use-postra-scheduler -mcpu=sifive-u74 \
7+
;RUN: -target-abi=lp64f | FileCheck %s --check-prefixes=FUSION-POSTRA
68

79
@.str = private constant [4 x i8] c"%f\0A\00", align 1
810

@@ -20,6 +22,13 @@ define void @foo(i32 signext %0, i32 signext %1) {
2022
; FUSION-NEXT: lui a0, %hi(.L.str)
2123
; FUSION-NEXT: addi a0, a0, %lo(.L.str)
2224
; FUSION-NEXT: tail bar@plt
25+
;
26+
; FUSION-POSTRA-LABEL: foo:
27+
; FUSION-POSTRA: # %bb.0:
28+
; FUSION-POSTRA-NEXT: lui a0, %hi(.L.str)
29+
; FUSION-POSTRA-NEXT: fcvt.s.w fa0, a1
30+
; FUSION-POSTRA-NEXT: addi a0, a0, %lo(.L.str)
31+
; FUSION-POSTRA-NEXT: tail bar@plt
2332
%3 = sitofp i32 %1 to float
2433
tail call void @bar(ptr @.str, float %3)
2534
ret void
@@ -40,5 +49,11 @@ define i32 @test_matint() {
4049
; FUSION-NEXT: lui a0, 1
4150
; FUSION-NEXT: addiw a0, a0, -2048
4251
; FUSION-NEXT: ret
52+
;
53+
; FUSION-POSTRA-LABEL: test_matint:
54+
; FUSION-POSTRA: # %bb.0:
55+
; FUSION-POSTRA-NEXT: lui a0, 1
56+
; FUSION-POSTRA-NEXT: addiw a0, a0, -2048
57+
; FUSION-POSTRA-NEXT: ret
4358
ret i32 2048
4459
}

0 commit comments

Comments
 (0)