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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

Author: Jim Lin (tclin914)

<details>
<summary>Changes</summary>

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).

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


1 Files Affected:

- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoZa.td (+1-1) 


``````````diff
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)>;

``````````

</details>


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


More information about the llvm-commits mailing list