[llvm] [RISCV] Move FeatureUnalignedScalarMem out of Andes45TuneFeatures (PR #221166)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 4 01:15:22 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-risc-v

Author: Jim Lin (tclin914)

<details>
<summary>Changes</summary>

Other processors list FeatureUnalignedScalarMem among their features rather than their tune features, and the 45-series should match. The feature is somewhat architectural: -mtune is only supposed to affect performance, but enabling this through Andes45TuneFeatures lets -mtune introduce unaligned accesses that crash on a CPU which does not support them.

Move it into the feature list of each 45-series processor (andes-n45, andes-nx45, andes-a45, andes-ax45 and andes-ax45mpv), where it is selected by -mcpu.

Drop andes-45-unaligned-scalar-mem.ll, which relied on obtaining the feature through "tune-cpu", and instead cover the new behaviour in memcpy.ll with -mcpu=andes-a45/-mcpu=andes-ax45. The new RUN lines pass -mtune=rocket so that the 45-series scheduling model does not reorder the output, letting them reuse the existing check lines.

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


3 Files Affected:

- (modified) llvm/lib/Target/RISCV/RISCVProcessors.td (+11-7) 
- (removed) llvm/test/CodeGen/RISCV/andes-45-unaligned-scalar-mem.ll (-15) 
- (modified) llvm/test/CodeGen/RISCV/memcpy.ll (+4) 


``````````diff
diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td b/llvm/lib/Target/RISCV/RISCVProcessors.td
index e144d81b597ce..38c3c884bf3ee 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -998,8 +998,7 @@ def ANDES_AX25 : RISCVProcessorModel<"andes-ax25",
                                       FeatureStdExtC,
                                       FeatureVendorXAndesPerf]>;
 
-defvar Andes45TuneFeatures = [FeatureUnalignedScalarMem,
-                              TuneAndes45,
+defvar Andes45TuneFeatures = [TuneAndes45,
                               TuneNoDefaultUnroll,
                               TuneShortForwardBranchIALU,
                               TunePostRAScheduler];
@@ -1018,7 +1017,8 @@ def ANDES_N45 : RISCVProcessorModel<"andes-n45",
                                      FeatureStdExtF,
                                      FeatureStdExtD,
                                      FeatureStdExtC,
-                                     FeatureVendorXAndesPerf],
+                                     FeatureVendorXAndesPerf,
+                                     FeatureUnalignedScalarMem],
                                     Andes45TuneFeatures>;
 
 def ANDES_NX45 : RISCVProcessorModel<"andes-nx45",
@@ -1032,7 +1032,8 @@ def ANDES_NX45 : RISCVProcessorModel<"andes-nx45",
                                       FeatureStdExtF,
                                       FeatureStdExtD,
                                       FeatureStdExtC,
-                                      FeatureVendorXAndesPerf],
+                                      FeatureVendorXAndesPerf,
+                                      FeatureUnalignedScalarMem],
                                      Andes45TuneFeatures>;
 
 def ANDES_A45 : RISCVProcessorModel<"andes-a45",
@@ -1046,7 +1047,8 @@ def ANDES_A45 : RISCVProcessorModel<"andes-a45",
                                      FeatureStdExtF,
                                      FeatureStdExtD,
                                      FeatureStdExtC,
-                                     FeatureVendorXAndesPerf],
+                                     FeatureVendorXAndesPerf,
+                                     FeatureUnalignedScalarMem],
                                     Andes45TuneFeatures>;
 
 def ANDES_AX45 : RISCVProcessorModel<"andes-ax45",
@@ -1060,7 +1062,8 @@ def ANDES_AX45 : RISCVProcessorModel<"andes-ax45",
                                       FeatureStdExtF,
                                       FeatureStdExtD,
                                       FeatureStdExtC,
-                                      FeatureVendorXAndesPerf],
+                                      FeatureVendorXAndesPerf,
+                                      FeatureUnalignedScalarMem],
                                      Andes45TuneFeatures>;
 
 def ANDES_AX45MPV : RISCVProcessorModel<"andes-ax45mpv",
@@ -1075,7 +1078,8 @@ def ANDES_AX45MPV : RISCVProcessorModel<"andes-ax45mpv",
                                          FeatureStdExtD,
                                          FeatureStdExtC,
                                          FeatureStdExtV,
-                                         FeatureVendorXAndesPerf],
+                                         FeatureVendorXAndesPerf,
+                                         FeatureUnalignedScalarMem],
                                         Andes45TuneFeatures>;
 
 def ESPERANTO_SOC1 : RISCVProcessorModel<"et-soc1",
diff --git a/llvm/test/CodeGen/RISCV/andes-45-unaligned-scalar-mem.ll b/llvm/test/CodeGen/RISCV/andes-45-unaligned-scalar-mem.ll
deleted file mode 100644
index 8b05548a1b353..0000000000000
--- a/llvm/test/CodeGen/RISCV/andes-45-unaligned-scalar-mem.ll
+++ /dev/null
@@ -1,15 +0,0 @@
-; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s | FileCheck %s
-
-declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)
-
-define void @memcpy51(ptr %dst, ptr %src) #0 {
-; CHECK-LABEL: memcpy51:
-; CHECK-NOT: call
-; CHECK: ld
-; CHECK: sd
-; CHECK: ret
-  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %dst, ptr align 1 %src, i64 51, i1 false)
-  ret void
-}
-
-attributes #0 = { "tune-cpu"="andes-45-series" }
diff --git a/llvm/test/CodeGen/RISCV/memcpy.ll b/llvm/test/CodeGen/RISCV/memcpy.ll
index 5a15a6f2a29e3..859d1039527ce 100644
--- a/llvm/test/CodeGen/RISCV/memcpy.ll
+++ b/llvm/test/CodeGen/RISCV/memcpy.ll
@@ -5,8 +5,12 @@
 ; RUN:   | FileCheck %s --check-prefixes=RV64-BOTH,RV64
 ; RUN: llc < %s -mtriple=riscv32 -mattr=+unaligned-scalar-mem \
 ; RUN:   | FileCheck %s --check-prefixes=RV32-BOTH,RV32-FAST
+; RUN: llc < %s -mtriple=riscv32 -mcpu=andes-a45 -mtune=rocket \
+; RUN:   | FileCheck %s --check-prefixes=RV32-BOTH,RV32-FAST
 ; RUN: llc < %s -mtriple=riscv64 -mattr=+unaligned-scalar-mem \
 ; RUN:   | FileCheck %s --check-prefixes=RV64-BOTH,RV64-FAST
+; RUN: llc < %s -mtriple=riscv64 -mcpu=andes-ax45 -mtune=rocket \
+; RUN:   | FileCheck %s --check-prefixes=RV64-BOTH,RV64-FAST
 
 ; ----------------------------------------------------------------------
 ; Fully unaligned cases

``````````

</details>


https://github.com/llvm/llvm-project/pull/221166


More information about the llvm-commits mailing list