Skip to content

Commit cab606c

Browse files
authored
[LoongArch] Enable alias analysis by default (#114980)
Enable use of alias analysis during code generation.
1 parent d8354d6 commit cab606c

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,15 @@ using namespace llvm;
2222
#define GET_SUBTARGETINFO_CTOR
2323
#include "LoongArchGenSubtargetInfo.inc"
2424

25+
static cl::opt<bool> UseAA("loongarch-use-aa", cl::init(true),
26+
cl::desc("Enable the use of AA during codegen."));
27+
2528
void LoongArchSubtarget::anchor() {}
2629

30+
// Enable use of alias analysis during code generation (during MI scheduling,
31+
// DAGCombine, etc.).
32+
bool LoongArchSubtarget::useAA() const { return UseAA; }
33+
2734
LoongArchSubtarget &LoongArchSubtarget::initializeSubtargetDependencies(
2835
const Triple &TT, StringRef CPU, StringRef TuneCPU, StringRef FS,
2936
StringRef ABIName) {

llvm/lib/Target/LoongArch/LoongArchSubtarget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class LoongArchSubtarget : public LoongArchGenSubtargetInfo {
105105
unsigned getMaxBytesForAlignment() const { return MaxBytesForAlignment; }
106106
unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
107107
bool enableMachineScheduler() const override { return true; }
108+
bool useAA() const override;
108109
};
109110
} // end namespace llvm
110111

llvm/test/CodeGen/LoongArch/merge-load-store.ll

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,8 @@ define void @merge_load_store(ptr noalias %src, ptr noalias %dst) unnamed_addr {
2727
;
2828
; LA64-LABEL: merge_load_store:
2929
; LA64: # %bb.0: # %start
30-
; LA64-NEXT: ld.b $a2, $a0, 0
31-
; LA64-NEXT: ld.b $a3, $a0, 1
32-
; LA64-NEXT: ld.b $a4, $a0, 2
33-
; LA64-NEXT: ld.b $a5, $a0, 3
34-
; LA64-NEXT: st.b $a2, $a1, 0
35-
; LA64-NEXT: st.b $a3, $a1, 1
36-
; LA64-NEXT: st.b $a4, $a1, 2
37-
; LA64-NEXT: st.b $a5, $a1, 3
38-
; LA64-NEXT: ld.b $a2, $a0, 4
39-
; LA64-NEXT: ld.b $a3, $a0, 5
40-
; LA64-NEXT: ld.b $a4, $a0, 6
41-
; LA64-NEXT: ld.b $a0, $a0, 7
42-
; LA64-NEXT: st.b $a2, $a1, 4
43-
; LA64-NEXT: st.b $a3, $a1, 5
44-
; LA64-NEXT: st.b $a4, $a1, 6
45-
; LA64-NEXT: st.b $a0, $a1, 7
30+
; LA64-NEXT: ld.d $a0, $a0, 0
31+
; LA64-NEXT: st.d $a0, $a1, 0
4632
; LA64-NEXT: ret
4733
start:
4834
%_3 = load i8, ptr %src, align 1

0 commit comments

Comments
 (0)