Skip to content

[LoongArch] Enable alias analysis by default #114980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 6, 2024
Merged

Conversation

heiher
Copy link
Member

@heiher heiher commented Nov 5, 2024

Enable use of alias analysis during code generation.

@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2024

@llvm/pr-subscribers-backend-loongarch

Author: hev (heiher)

Changes

Enable use of alias analysis during code generation.


Full diff: https://github.com/llvm/llvm-project/pull/114980.diff

3 Files Affected:

  • (modified) llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp (+7)
  • (modified) llvm/lib/Target/LoongArch/LoongArchSubtarget.h (+1)
  • (modified) llvm/test/CodeGen/LoongArch/merge-load-store.ll (+2-16)
diff --git a/llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp b/llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp
index 57babfc917f897..3acbe4992273a3 100644
--- a/llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp
@@ -22,8 +22,15 @@ using namespace llvm;
 #define GET_SUBTARGETINFO_CTOR
 #include "LoongArchGenSubtargetInfo.inc"
 
+static cl::opt<bool> UseAA("loongarch-use-aa", cl::init(true),
+                           cl::desc("Enable the use of AA during codegen."));
+
 void LoongArchSubtarget::anchor() {}
 
+// Enable use of alias analysis during code generation (during MI scheduling,
+// DAGCombine, etc.).
+bool LoongArchSubtarget::useAA() const { return UseAA; }
+
 LoongArchSubtarget &LoongArchSubtarget::initializeSubtargetDependencies(
     const Triple &TT, StringRef CPU, StringRef TuneCPU, StringRef FS,
     StringRef ABIName) {
diff --git a/llvm/lib/Target/LoongArch/LoongArchSubtarget.h b/llvm/lib/Target/LoongArch/LoongArchSubtarget.h
index a8752c8070aa66..5e12bafebb0d52 100644
--- a/llvm/lib/Target/LoongArch/LoongArchSubtarget.h
+++ b/llvm/lib/Target/LoongArch/LoongArchSubtarget.h
@@ -105,6 +105,7 @@ class LoongArchSubtarget : public LoongArchGenSubtargetInfo {
   unsigned getMaxBytesForAlignment() const { return MaxBytesForAlignment; }
   unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
   bool enableMachineScheduler() const override { return true; }
+  bool useAA() const override;
 };
 } // end namespace llvm
 
diff --git a/llvm/test/CodeGen/LoongArch/merge-load-store.ll b/llvm/test/CodeGen/LoongArch/merge-load-store.ll
index 2eac65ebb1488d..b45bbc95530795 100644
--- a/llvm/test/CodeGen/LoongArch/merge-load-store.ll
+++ b/llvm/test/CodeGen/LoongArch/merge-load-store.ll
@@ -27,22 +27,8 @@ define void @merge_load_store(ptr noalias nocapture noundef readonly align 1 der
 ;
 ; LA64-LABEL: merge_load_store:
 ; LA64:       # %bb.0: # %start
-; LA64-NEXT:    ld.b $a2, $a0, 0
-; LA64-NEXT:    ld.b $a3, $a0, 1
-; LA64-NEXT:    ld.b $a4, $a0, 2
-; LA64-NEXT:    ld.b $a5, $a0, 3
-; LA64-NEXT:    st.b $a2, $a1, 0
-; LA64-NEXT:    st.b $a3, $a1, 1
-; LA64-NEXT:    st.b $a4, $a1, 2
-; LA64-NEXT:    st.b $a5, $a1, 3
-; LA64-NEXT:    ld.b $a2, $a0, 4
-; LA64-NEXT:    ld.b $a3, $a0, 5
-; LA64-NEXT:    ld.b $a4, $a0, 6
-; LA64-NEXT:    ld.b $a0, $a0, 7
-; LA64-NEXT:    st.b $a2, $a1, 4
-; LA64-NEXT:    st.b $a3, $a1, 5
-; LA64-NEXT:    st.b $a4, $a1, 6
-; LA64-NEXT:    st.b $a0, $a1, 7
+; LA64-NEXT:    ld.d $a0, $a0, 0
+; LA64-NEXT:    st.d $a0, $a1, 0
 ; LA64-NEXT:    ret
 start:
   %_3 = load i8, ptr %src, align 1

Copy link
Contributor

@SixWeining SixWeining left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@wangleiat wangleiat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@heiher heiher merged commit cab606c into llvm:main Nov 6, 2024
6 of 8 checks passed
@heiher heiher deleted the loong64-use-aa branch November 6, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants