[llvm] [RISCV] Fix address type in Zacas seq_cst atomic pattern (PR #190729)

Jim Lin via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 6 22:25:14 PDT 2026


https://github.com/tclin914 created https://github.com/llvm/llvm-project/pull/190729

The seq_cst pattern in AMOCASPat used (vt GPR:$addr) for the address operand, while all other patterns (monotonic, acquire, release, acq_rel) consistently use (XLenVT GPR:$addr). This would produce a wrong type for the address when vt differs from XLenVT (e.g., amocas.d on RV32 where vt=i64).

>From eaec6a56e8bdd4096fd0311d24512d9d6f652d5d Mon Sep 17 00:00:00 2001
From: Jim Lin <jim at andestech.com>
Date: Tue, 7 Apr 2026 09:50:39 +0800
Subject: [PATCH] [RISCV] Fix address type in Zacas seq_cst atomic pattern

The seq_cst pattern in AMOCASPat used (vt GPR:$addr) for the address
operand, while all other patterns (monotonic, acquire, release,
acq_rel) consistently use (XLenVT GPR:$addr). This would produce a
wrong type for the address when vt differs from XLenVT (e.g., amocas.d
on RV32 where vt=i64).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply at anthropic.com>
---
 llvm/lib/Target/RISCV/RISCVInstrInfoZa.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZa.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZa.td
index 20e2142c70b48..8c96353cec5af 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoZa.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZa.td
@@ -87,7 +87,7 @@ multiclass AMOCASPat<string AtomicOp, string BaseInst, ValueType vt = XLenVT,
                                                    (vt GPR:$cmp),
                                                    (vt GPR:$new)),
               (!cast<RVInst>(BaseInst#"_AQRL") GPR:$cmp, GPR:$new, GPR:$addr)>;
-    def : Pat<(!cast<PatFrag>(AtomicOp#"_seq_cst") (vt GPR:$addr),
+    def : Pat<(!cast<PatFrag>(AtomicOp#"_seq_cst") (XLenVT GPR:$addr),
                                                    (vt GPR:$cmp),
                                                    (vt GPR:$new)),
               (!cast<RVInst>(BaseInst#"_AQRL") GPR:$cmp, GPR:$new, GPR:$addr)>;



More information about the llvm-commits mailing list