File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ static cl::opt<bool>
5757 cl::desc (" Enable the loop data prefetch pass" ),
5858 cl::init(false ));
5959
60+ static cl::opt<bool >
61+ EnableMergeBaseOffset (" loongarch-enable-merge-offset" ,
62+ cl::desc (" Enable the merge base offset pass" ),
63+ cl::init(true ), cl::Hidden);
64+
6065static Reloc::Model getEffectiveRelocModel (const Triple &TT,
6166 std::optional<Reloc::Model> RM) {
6267 return RM.value_or (Reloc::Static);
@@ -214,7 +219,7 @@ void LoongArchPassConfig::addMachineSSAOptimization() {
214219
215220void LoongArchPassConfig::addPreRegAlloc () {
216221 addPass (createLoongArchPreRAExpandPseudoPass ());
217- if (TM->getOptLevel () != CodeGenOptLevel::None)
222+ if (TM->getOptLevel () != CodeGenOptLevel::None && EnableMergeBaseOffset )
218223 addPass (createLoongArchMergeBaseOffsetOptPass ());
219224}
220225
Original file line number Diff line number Diff line change 1+ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+ ; RUN: llc --mtriple=loongarch64 -mattr=+d --relocation-model=static -O1 \
3+ ; RUN: < %s | FileCheck %s --check-prefix=MERGE
4+ ; RUN: llc --mtriple=loongarch64 -mattr=+d --relocation-model=static -O1 \
5+ ; RUN: --loongarch-enable-merge-offset=false < %s | FileCheck %s --check-prefix=NO_MERGE
6+
7+ @g = dso_local global i32 zeroinitializer , align 4
8+
9+ define void @foo () nounwind {
10+ ; MERGE-LABEL: foo:
11+ ; MERGE: # %bb.0:
12+ ; MERGE-NEXT: pcalau12i $a0, %pc_hi20(g)
13+ ; MERGE-NEXT: ld.w $zero, $a0, %pc_lo12(g)
14+ ; MERGE-NEXT: ret
15+ ;
16+ ; NO_MERGE-LABEL: foo:
17+ ; NO_MERGE: # %bb.0:
18+ ; NO_MERGE-NEXT: pcalau12i $a0, %pc_hi20(g)
19+ ; NO_MERGE-NEXT: addi.d $a0, $a0, %pc_lo12(g)
20+ ; NO_MERGE-NEXT: ld.w $zero, $a0, 0
21+ ; NO_MERGE-NEXT: ret
22+ %v = load volatile i32 , ptr @g
23+ ret void
24+ }
You can’t perform that action at this time.
0 commit comments