https://github.com/topperc updated https://github.com/llvm/llvm-project/pull/224739
>From ecfb32ef9bfd8d76c2f485d579f1bee0a2095985 Mon Sep 17 00:00:00 2001 From: Craig Topper <[email protected]> Date: Fri, 18 Sep 2026 13:22:10 -0700 Subject: [PATCH 1/4] [RISCV] Add a command line option to disable register overlap for vector index load. If a trap occurs on an element other than 0, some SiFive cores will write a garbage value to that element and all active elements after it in the destination register before running the trap handler. This is normally allowed by the spec if restarting the instruction would overwrite the elements with the correct results. For a vector indexed load with overlapping source and destination, writing the later elements with garbage corrupts some of the source indices. This prevents the instruction from restarting correctly once the fault has been handled. This option allows users to opt out of overlapping registers on these instructions. This is an alternative to #220079. --- clang/include/clang/Options/Options.td | 5 ++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp | 9 +++ clang/test/Driver/riscv-features.c | 5 ++ llvm/lib/Target/RISCV/RISCVFeatures.td | 6 ++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 14 +++++ .../Target/RISCV/RISCVInstrInfoVPseudos.td | 2 + llvm/lib/Target/RISCV/RISCVProcessors.td | 3 +- llvm/test/CodeGen/RISCV/features-info.ll | 1 + .../RISCV/rvv/vluxei-vloxei-overlap.ll | 57 +++++++++++++++++++ 9 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 llvm/test/CodeGen/RISCV/rvv/vluxei-vloxei-overlap.ll diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td index 4fc924f848507e..6c310b2fa2936a 100644 --- a/clang/include/clang/Options/Options.td +++ b/clang/include/clang/Options/Options.td @@ -5924,6 +5924,11 @@ def mzilsd_word_align : Flag<["-"], "mzilsd-word-align">, Group<m_Group>, HelpText<"Allow Zilsd/Zclsd memory accesses to be 4-byte aligned (RISC-V only)">; def mzilsd_strict_align : Flag<["-"], "mzilsd-strict-align">, Group<m_Group>, HelpText<"Force all Zilsd/Zclsd memory accesses to be 8-byte aligned (RISC-V only)">; +defm fix_sifive_mal_9174 : BoolOptionWithoutMarshalling<"m", "fix-sifive-mal-9174", + PosFlag<SetFalse, [], [], "Workaround SiFive erratum MAL-9174 by forcing vector indexed loads to have non-">, + NegFlag<SetTrue, [], [], "Allow vector indexed loads to have ">, + BothFlags<[], [], "overlapping source and destination register groups (RISC-V only)">>, + Group<m_Group>; def mno_thumb : Flag<["-"], "mno-thumb">, Group<m_arm_Features_Group>; def mrestrict_it: Flag<["-"], "mrestrict-it">, Group<m_arm_Features_Group>, HelpText<"Disallow generation of complex IT blocks. It is off by default.">; diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp index 8e650ddf92dfc1..7fb8641783642d 100644 --- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp +++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp @@ -178,6 +178,15 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple, Features.push_back("+unaligned-vector-mem"); } + if (const Arg *A = + Args.getLastArg(options::OPT_mfix_sifive_mal_9174, + options::OPT_mno_fix_sifive_mal_9174)) { + if (A->getOption().matches(options::OPT_mfix_sifive_mal_9174)) + Features.push_back("+fix-sifive-mal-9174"); + else + Features.push_back("-fix-sifive-mal-9174"); + } + if (Triple.isRISCV32()) { // Handle `-mzilsd-word-align` and `-mzilsd-strict-align` on rv32. These // interact with the scalar alignment options - if unaligned scalar memory diff --git a/clang/test/Driver/riscv-features.c b/clang/test/Driver/riscv-features.c index 97736ff81c7991..f0571e2c5746b7 100644 --- a/clang/test/Driver/riscv-features.c +++ b/clang/test/Driver/riscv-features.c @@ -48,6 +48,11 @@ // FAST-VECTOR-UNALIGNED-ACCESS: "-target-feature" "+unaligned-vector-mem" // NO-FAST-VECTOR-UNALIGNED-ACCESS: "-target-feature" "-unaligned-vector-mem" +// RUN: %clang --target=riscv32-unknown-elf -### %s -mfix-sifive-mal-9174 2>&1 | FileCheck %s -check-prefix=FIX-SIFIVE-MAL-9174 +// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-fix-sifive-mal-9174 2>&1 | FileCheck %s -check-prefix=NO-FIX-SIFIVE-MAL-9174 +// FIX-SIFIVE-MAL-9174: "-target-feature" "+fix-sifive-mal-9174" +// NO-FIX-SIFIVE-MAL-9174: "-target-feature" "-fix-sifive-mal-9174" + // RUN: %clang --target=riscv32-unknown-elf -### %s 2>&1 | FileCheck %s -check-prefix=NOUWTABLE // RUN: %clang --target=riscv32-unknown-elf -fasynchronous-unwind-tables -### %s 2>&1 | FileCheck %s -check-prefix=UWTABLE // RUN: %clang --target=riscv64-unknown-elf -### %s 2>&1 | FileCheck %s -check-prefix=NOUWTABLE diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td index 79b90b3b2defbb..9fc64a64d419ce 100644 --- a/llvm/lib/Target/RISCV/RISCVFeatures.td +++ b/llvm/lib/Target/RISCV/RISCVFeatures.td @@ -2094,6 +2094,12 @@ def FeatureTaggedGlobals : SubtargetFeature<"tagged-globals", "true", "Use an instruction sequence for taking the address of a global " "that allows a memory tag in the upper address bits">; +def FeatureFixSiFiveMAL9174 + : SubtargetFeature<"fix-sifive-mal-9174", "FixSiFiveMAL_9174", "true", + "Workaround SiFive erratum MAL-9174 by disallowing " + "overlapping source and destination for vector index " + "loads">; + //===----------------------------------------------------------------------===// // Tuning features //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 8be82d596e8843..04caece741cb35 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -28603,6 +28603,20 @@ RISCVTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI, void RISCVTargetLowering::AdjustInstrPostInstrSelection(MachineInstr &MI, SDNode *Node) const { + if (Subtarget.fixSiFiveMAL_9174()) { + const RISCVVPseudosTable::PseudoInfo *RVV = + RISCVVPseudosTable::getPseudoInfo(MI.getOpcode()); + if (RVV && (RVV->BaseInstr == RISCV::VLUXEI8_V || + RVV->BaseInstr == RISCV::VLUXEI16_V || + RVV->BaseInstr == RISCV::VLUXEI32_V || + RVV->BaseInstr == RISCV::VLUXEI64_V || + RVV->BaseInstr == RISCV::VLOXEI8_V || + RVV->BaseInstr == RISCV::VLOXEI16_V || + RVV->BaseInstr == RISCV::VLOXEI32_V || + RVV->BaseInstr == RISCV::VLOXEI64_V)) + MI.getOperand(0).setIsEarlyClobber(true); + } + // If instruction defines FRM operand, conservatively set it as non-dead to // express data dependency with FRM users and prevent incorrect instruction // reordering. diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td index c6241f582de674..e2fc58234e2081 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td @@ -936,6 +936,7 @@ class VPseudoILoadNoMask<VReg RetClass, let HasVecPolicyOp = 1; let Constraints = !if(!eq(EarlyClobber, 1), "@earlyclobber $rd, $rd = $passthru", "$rd = $passthru"); let TargetOverlapConstraintType = TargetConstraintType; + let hasPostISelHook = 1; } class VPseudoILoadMask<VReg RetClass, @@ -960,6 +961,7 @@ class VPseudoILoadMask<VReg RetClass, let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; let IncludeInInversePseudoTable = 0; + let hasPostISelHook = 1; } class VPseudoUSStoreNoMask<VReg StClass, diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td b/llvm/lib/Target/RISCV/RISCVProcessors.td index 22b478e7fed72a..e20db641e259b3 100644 --- a/llvm/lib/Target/RISCV/RISCVProcessors.td +++ b/llvm/lib/Target/RISCV/RISCVProcessors.td @@ -614,7 +614,8 @@ def SIFIVE_P870_D : RISCVProcessorModel<"sifive-p870-d", SiFiveP800Model, FeatureStdExtZvksg, FeatureStdExtZvl128b, FeatureUnalignedScalarMem, - FeatureUnalignedVectorMem]), + FeatureUnalignedVectorMem, + FeatureFixSiFiveMAL9174]), [TuneNoDefaultUnroll, TuneConditionalCompressedMoveFusion, TuneLUIADDIFusion, diff --git a/llvm/test/CodeGen/RISCV/features-info.ll b/llvm/test/CodeGen/RISCV/features-info.ll index 4164f9697af651..a1be482da2528b 100644 --- a/llvm/test/CodeGen/RISCV/features-info.ll +++ b/llvm/test/CodeGen/RISCV/features-info.ll @@ -69,6 +69,7 @@ ; CHECK-NEXT: experimental-zvzip - 'Zvzip' (Vector Reordering Structured Data). ; CHECK-NEXT: experimental-zyhybrid - 'Zyhybrid' (Hybrid Extension for RVI Compatibility). ; CHECK-NEXT: f - 'F' (Single-Precision Floating-Point). +; CHECK-NEXT: fix-sifive-mal-9174 - Workaround SiFive erratum MAL-9174 by disallowing overlapping source and destination for vector index loads. ; CHECK-NEXT: forced-atomics - Assume that lock-free native-width atomics are available. ; CHECK-NEXT: fusion-add-load - Enable ADD(.UW) + load macrofusion. ; CHECK-NEXT: fusion-add-mem - Enable ADD+LOAD/STORE macrofusion. diff --git a/llvm/test/CodeGen/RISCV/rvv/vluxei-vloxei-overlap.ll b/llvm/test/CodeGen/RISCV/rvv/vluxei-vloxei-overlap.ll new file mode 100644 index 00000000000000..87d5939ff4c681 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/vluxei-vloxei-overlap.ll @@ -0,0 +1,57 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+v \ +; RUN: -verify-machineinstrs -target-abi=ilp32d | FileCheck %s --check-prefixes=OVERLAP +; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v \ +; RUN: -verify-machineinstrs -target-abi=lp64d | FileCheck %s --check-prefixes=OVERLAP +; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+v,+fix-sifive-mal-9174 \ +; RUN: -verify-machineinstrs -target-abi=ilp32d | FileCheck %s --check-prefixes=NOOVERLAP +; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v,+fix-sifive-mal-9174 \ +; RUN: -verify-machineinstrs -target-abi=lp64d | FileCheck %s --check-prefixes=NOOVERLAP +; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mcpu=sifive-p870-d \ +; RUN: -verify-machineinstrs -target-abi=lp64d | FileCheck %s --check-prefixes=NOOVERLAP + +define <vscale x 1 x i8> @intrinsic_vluxei_v_nxv1i8_nxv1i8_nxv1i32(ptr %0, <vscale x 1 x i32> %1, iXLen %2) nounwind { +; OVERLAP-LABEL: intrinsic_vluxei_v_nxv1i8_nxv1i8_nxv1i32: +; OVERLAP: # %bb.0: # %entry +; OVERLAP-NEXT: vsetvli zero, a1, e8, mf8, ta, ma +; OVERLAP-NEXT: vluxei32.v v8, (a0), v8 +; OVERLAP-NEXT: ret +; +; NOOVERLAP-LABEL: intrinsic_vluxei_v_nxv1i8_nxv1i8_nxv1i32: +; NOOVERLAP: # %bb.0: # %entry +; NOOVERLAP-NEXT: vsetvli zero, a1, e8, mf8, ta, ma +; NOOVERLAP-NEXT: vluxei32.v v9, (a0), v8 +; NOOVERLAP-NEXT: vmv1r.v v8, v9 +; NOOVERLAP-NEXT: ret +entry: + %a = call <vscale x 1 x i8> @llvm.riscv.vluxei.nxv1i8.nxv1i32( + <vscale x 1 x i8> poison, + ptr %0, + <vscale x 1 x i32> %1, + iXLen %2) + + ret <vscale x 1 x i8> %a +} + +define <vscale x 1 x i8> @intrinsic_vloxei_v_nxv1i8_nxv1i8_nxv1i32(ptr %0, <vscale x 1 x i32> %1, iXLen %2) nounwind { +; OVERLAP-LABEL: intrinsic_vloxei_v_nxv1i8_nxv1i8_nxv1i32: +; OVERLAP: # %bb.0: # %entry +; OVERLAP-NEXT: vsetvli zero, a1, e8, mf8, ta, ma +; OVERLAP-NEXT: vloxei32.v v8, (a0), v8 +; OVERLAP-NEXT: ret +; +; NOOVERLAP-LABEL: intrinsic_vloxei_v_nxv1i8_nxv1i8_nxv1i32: +; NOOVERLAP: # %bb.0: # %entry +; NOOVERLAP-NEXT: vsetvli zero, a1, e8, mf8, ta, ma +; NOOVERLAP-NEXT: vloxei32.v v9, (a0), v8 +; NOOVERLAP-NEXT: vmv1r.v v8, v9 +; NOOVERLAP-NEXT: ret +entry: + %a = call <vscale x 1 x i8> @llvm.riscv.vloxei.nxv1i8.nxv1i32( + <vscale x 1 x i8> poison, + ptr %0, + <vscale x 1 x i32> %1, + iXLen %2) + + ret <vscale x 1 x i8> %a +} >From b608ed31d85435834cd04889ea836be8b7411c43 Mon Sep 17 00:00:00 2001 From: Craig Topper <[email protected]> Date: Thu, 12 Nov 2026 20:02:23 -0800 Subject: [PATCH 2/4] fixup! clang-format --- clang/lib/Driver/ToolChains/Arch/RISCV.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp index 7fb8641783642d..db21c46d7f6f17 100644 --- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp +++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp @@ -178,9 +178,8 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple, Features.push_back("+unaligned-vector-mem"); } - if (const Arg *A = - Args.getLastArg(options::OPT_mfix_sifive_mal_9174, - options::OPT_mno_fix_sifive_mal_9174)) { + if (const Arg *A = Args.getLastArg(options::OPT_mfix_sifive_mal_9174, + options::OPT_mno_fix_sifive_mal_9174)) { if (A->getOption().matches(options::OPT_mfix_sifive_mal_9174)) Features.push_back("+fix-sifive-mal-9174"); else >From 3e8f0b9898f04eb5d37ae6232301480d863aa114 Mon Sep 17 00:00:00 2001 From: Craig Topper <[email protected]> Date: Fri, 13 Nov 2026 09:31:22 -0800 Subject: [PATCH 3/4] fixup! Drop underscore --- llvm/lib/Target/RISCV/RISCVFeatures.td | 2 +- llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td index 9fc64a64d419ce..2b2a60f2b61bd7 100644 --- a/llvm/lib/Target/RISCV/RISCVFeatures.td +++ b/llvm/lib/Target/RISCV/RISCVFeatures.td @@ -2095,7 +2095,7 @@ def FeatureTaggedGlobals : SubtargetFeature<"tagged-globals", "that allows a memory tag in the upper address bits">; def FeatureFixSiFiveMAL9174 - : SubtargetFeature<"fix-sifive-mal-9174", "FixSiFiveMAL_9174", "true", + : SubtargetFeature<"fix-sifive-mal-9174", "FixSiFiveMAL9174", "true", "Workaround SiFive erratum MAL-9174 by disallowing " "overlapping source and destination for vector index " "loads">; diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 04caece741cb35..2d88d628091464 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -28603,7 +28603,7 @@ RISCVTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI, void RISCVTargetLowering::AdjustInstrPostInstrSelection(MachineInstr &MI, SDNode *Node) const { - if (Subtarget.fixSiFiveMAL_9174()) { + if (Subtarget.fixSiFiveMAL9174()) { const RISCVVPseudosTable::PseudoInfo *RVV = RISCVVPseudosTable::getPseudoInfo(MI.getOpcode()); if (RVV && (RVV->BaseInstr == RISCV::VLUXEI8_V || >From 81225708f81db04bd2cbc49d5cf413f54f1320ca Mon Sep 17 00:00:00 2001 From: Craig Topper <[email protected]> Date: Mon, 16 Nov 2026 15:48:39 -0800 Subject: [PATCH 4/4] Add second bug number. --- clang/include/clang/Options/Options.td | 6 ++++-- clang/lib/Driver/ToolChains/Arch/RISCV.cpp | 10 +++++----- clang/test/Driver/riscv-features.c | 8 ++++---- llvm/lib/Target/RISCV/RISCVFeatures.td | 11 ++++++----- llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 2 +- llvm/lib/Target/RISCV/RISCVProcessors.td | 2 +- llvm/test/CodeGen/RISCV/features-info.ll | 2 +- llvm/test/CodeGen/RISCV/rvv/vluxei-vloxei-overlap.ll | 4 ++-- 8 files changed, 24 insertions(+), 21 deletions(-) diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td index 6c310b2fa2936a..2c22c360ae618e 100644 --- a/clang/include/clang/Options/Options.td +++ b/clang/include/clang/Options/Options.td @@ -5924,8 +5924,10 @@ def mzilsd_word_align : Flag<["-"], "mzilsd-word-align">, Group<m_Group>, HelpText<"Allow Zilsd/Zclsd memory accesses to be 4-byte aligned (RISC-V only)">; def mzilsd_strict_align : Flag<["-"], "mzilsd-strict-align">, Group<m_Group>, HelpText<"Force all Zilsd/Zclsd memory accesses to be 8-byte aligned (RISC-V only)">; -defm fix_sifive_mal_9174 : BoolOptionWithoutMarshalling<"m", "fix-sifive-mal-9174", - PosFlag<SetFalse, [], [], "Workaround SiFive erratum MAL-9174 by forcing vector indexed loads to have non-">, +defm fix_sifive_mal_9174_mal_9191 : BoolOptionWithoutMarshalling<"m", "fix-sifive-mal-9174-mal-9191", + PosFlag<SetFalse, [], [], + "Workaround SiFive erratum MAL-9174 or MAL-9191 by forcing vector " + "indexed loads to have non-">, NegFlag<SetTrue, [], [], "Allow vector indexed loads to have ">, BothFlags<[], [], "overlapping source and destination register groups (RISC-V only)">>, Group<m_Group>; diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp index db21c46d7f6f17..c1c306b5e76809 100644 --- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp +++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp @@ -178,12 +178,12 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple, Features.push_back("+unaligned-vector-mem"); } - if (const Arg *A = Args.getLastArg(options::OPT_mfix_sifive_mal_9174, - options::OPT_mno_fix_sifive_mal_9174)) { - if (A->getOption().matches(options::OPT_mfix_sifive_mal_9174)) - Features.push_back("+fix-sifive-mal-9174"); + if (const Arg *A = Args.getLastArg(options::OPT_mfix_sifive_mal_9174_mal_9191, + options::OPT_mno_fix_sifive_mal_9174_mal_9191)) { + if (A->getOption().matches(options::OPT_mfix_sifive_mal_9174_mal_9191)) + Features.push_back("+fix-sifive-mal-9174-mal-9191"); else - Features.push_back("-fix-sifive-mal-9174"); + Features.push_back("-fix-sifive-mal-9174-mal-9191"); } if (Triple.isRISCV32()) { diff --git a/clang/test/Driver/riscv-features.c b/clang/test/Driver/riscv-features.c index f0571e2c5746b7..b7b714468a5091 100644 --- a/clang/test/Driver/riscv-features.c +++ b/clang/test/Driver/riscv-features.c @@ -48,10 +48,10 @@ // FAST-VECTOR-UNALIGNED-ACCESS: "-target-feature" "+unaligned-vector-mem" // NO-FAST-VECTOR-UNALIGNED-ACCESS: "-target-feature" "-unaligned-vector-mem" -// RUN: %clang --target=riscv32-unknown-elf -### %s -mfix-sifive-mal-9174 2>&1 | FileCheck %s -check-prefix=FIX-SIFIVE-MAL-9174 -// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-fix-sifive-mal-9174 2>&1 | FileCheck %s -check-prefix=NO-FIX-SIFIVE-MAL-9174 -// FIX-SIFIVE-MAL-9174: "-target-feature" "+fix-sifive-mal-9174" -// NO-FIX-SIFIVE-MAL-9174: "-target-feature" "-fix-sifive-mal-9174" +// RUN: %clang --target=riscv32-unknown-elf -### %s -mfix-sifive-mal-9174-mal-9191 2>&1 | FileCheck %s -check-prefix=FIX-SIFIVE-MAL-9174-MAL-9191 +// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-fix-sifive-mal-9174-mal-9191 2>&1 | FileCheck %s -check-prefix=NO-FIX-SIFIVE-MAL-9174-MAL-9191 +// FIX-SIFIVE-MAL-9174-MAL-9191: "-target-feature" "+fix-sifive-mal-9174-mal-9191" +// NO-FIX-SIFIVE-MAL-9174-MAL-9191: "-target-feature" "-fix-sifive-mal-9174-mal-9191" // RUN: %clang --target=riscv32-unknown-elf -### %s 2>&1 | FileCheck %s -check-prefix=NOUWTABLE // RUN: %clang --target=riscv32-unknown-elf -fasynchronous-unwind-tables -### %s 2>&1 | FileCheck %s -check-prefix=UWTABLE diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td index 2b2a60f2b61bd7..471ff990434119 100644 --- a/llvm/lib/Target/RISCV/RISCVFeatures.td +++ b/llvm/lib/Target/RISCV/RISCVFeatures.td @@ -2094,11 +2094,12 @@ def FeatureTaggedGlobals : SubtargetFeature<"tagged-globals", "true", "Use an instruction sequence for taking the address of a global " "that allows a memory tag in the upper address bits">; -def FeatureFixSiFiveMAL9174 - : SubtargetFeature<"fix-sifive-mal-9174", "FixSiFiveMAL9174", "true", - "Workaround SiFive erratum MAL-9174 by disallowing " - "overlapping source and destination for vector index " - "loads">; +def FeatureFixSiFiveMAL9174MAL9191 + : SubtargetFeature<"fix-sifive-mal-9174-mal-9191", + "FixSiFiveMAL9174MAL9191", "true", + "Workaround SiFive erratum MAL-9174 or MAL-9191 by " + "disallowing overlapping source and destination for " + "vector indexed loads">; //===----------------------------------------------------------------------===// // Tuning features diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 2d88d628091464..d836c24f7c431b 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -28603,7 +28603,7 @@ RISCVTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI, void RISCVTargetLowering::AdjustInstrPostInstrSelection(MachineInstr &MI, SDNode *Node) const { - if (Subtarget.fixSiFiveMAL9174()) { + if (Subtarget.fixSiFiveMAL9174MAL9191()) { const RISCVVPseudosTable::PseudoInfo *RVV = RISCVVPseudosTable::getPseudoInfo(MI.getOpcode()); if (RVV && (RVV->BaseInstr == RISCV::VLUXEI8_V || diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td b/llvm/lib/Target/RISCV/RISCVProcessors.td index e20db641e259b3..3cc763dc017128 100644 --- a/llvm/lib/Target/RISCV/RISCVProcessors.td +++ b/llvm/lib/Target/RISCV/RISCVProcessors.td @@ -615,7 +615,7 @@ def SIFIVE_P870_D : RISCVProcessorModel<"sifive-p870-d", SiFiveP800Model, FeatureStdExtZvl128b, FeatureUnalignedScalarMem, FeatureUnalignedVectorMem, - FeatureFixSiFiveMAL9174]), + FeatureFixSiFiveMAL9174MAL9191]), [TuneNoDefaultUnroll, TuneConditionalCompressedMoveFusion, TuneLUIADDIFusion, diff --git a/llvm/test/CodeGen/RISCV/features-info.ll b/llvm/test/CodeGen/RISCV/features-info.ll index a1be482da2528b..3e8c7a110eaa3c 100644 --- a/llvm/test/CodeGen/RISCV/features-info.ll +++ b/llvm/test/CodeGen/RISCV/features-info.ll @@ -69,7 +69,7 @@ ; CHECK-NEXT: experimental-zvzip - 'Zvzip' (Vector Reordering Structured Data). ; CHECK-NEXT: experimental-zyhybrid - 'Zyhybrid' (Hybrid Extension for RVI Compatibility). ; CHECK-NEXT: f - 'F' (Single-Precision Floating-Point). -; CHECK-NEXT: fix-sifive-mal-9174 - Workaround SiFive erratum MAL-9174 by disallowing overlapping source and destination for vector index loads. +; CHECK-NEXT: fix-sifive-mal-9174-mal-9191 - Workaround SiFive erratum MAL-9174 or MAL-9191 by disallowing overlapping source and destination for vector indexed loads. ; CHECK-NEXT: forced-atomics - Assume that lock-free native-width atomics are available. ; CHECK-NEXT: fusion-add-load - Enable ADD(.UW) + load macrofusion. ; CHECK-NEXT: fusion-add-mem - Enable ADD+LOAD/STORE macrofusion. diff --git a/llvm/test/CodeGen/RISCV/rvv/vluxei-vloxei-overlap.ll b/llvm/test/CodeGen/RISCV/rvv/vluxei-vloxei-overlap.ll index 87d5939ff4c681..a825c7cfba7b7e 100644 --- a/llvm/test/CodeGen/RISCV/rvv/vluxei-vloxei-overlap.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vluxei-vloxei-overlap.ll @@ -3,9 +3,9 @@ ; RUN: -verify-machineinstrs -target-abi=ilp32d | FileCheck %s --check-prefixes=OVERLAP ; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v \ ; RUN: -verify-machineinstrs -target-abi=lp64d | FileCheck %s --check-prefixes=OVERLAP -; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+v,+fix-sifive-mal-9174 \ +; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+v,+fix-sifive-mal-9174-mal-9191 \ ; RUN: -verify-machineinstrs -target-abi=ilp32d | FileCheck %s --check-prefixes=NOOVERLAP -; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v,+fix-sifive-mal-9174 \ +; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v,+fix-sifive-mal-9174-mal-9191 \ ; RUN: -verify-machineinstrs -target-abi=lp64d | FileCheck %s --check-prefixes=NOOVERLAP ; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mcpu=sifive-p870-d \ ; RUN: -verify-machineinstrs -target-abi=lp64d | FileCheck %s --check-prefixes=NOOVERLAP _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
