[clang] [clang][RISCV] Make the index of riscv_tuple_extract and riscv_tuple_insert be truncated rather than zero extended (PR #111466)

Brandon Wu via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 7 19:40:05 PDT 2024


https://github.com/4vtomat created https://github.com/llvm/llvm-project/pull/111466

It's illegal if the index is 64 bits and is zero-extend to 32 bits.


>From 6e11ffa9585cf189382501d44915f211abd4be46 Mon Sep 17 00:00:00 2001
From: Brandon Wu <brandon.wu at sifive.com>
Date: Mon, 7 Oct 2024 19:33:41 -0700
Subject: [PATCH] [clang][RISCV] Make the index of riscv_tuple_extract and
 riscv_tuple_insert be truncated rather than zero extended

It's illegal if the index is 64 bits and is zero-extend to 32 bits.
---
 clang/include/clang/Basic/riscv_vector.td | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/riscv_vector.td b/clang/include/clang/Basic/riscv_vector.td
index 6e57e51793a712..1387494c4aeb00 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -2564,7 +2564,7 @@ let HasMasked = false, HasVL = false, IRName = "" in {
 
         return Builder.CreateIntrinsic(Intrinsic::riscv_tuple_extract,
                                        {ResultType, Ops[0]->getType()},
-                                       {Ops[0], Builder.CreateZExt(Ops[1],
+                                       {Ops[0], Builder.CreateTrunc(Ops[1],
                                         Builder.getInt32Ty())});
       }
       }] in {
@@ -2606,7 +2606,7 @@ let HasMasked = false, HasVL = false, IRName = "" in {
         return Builder.CreateIntrinsic(Intrinsic::riscv_tuple_insert,
                                        {ResultType, Ops[2]->getType()},
                                        {Ops[0], Ops[2],
-                                        Builder.CreateZExt(Ops[1],Builder.getInt32Ty())});
+                                        Builder.CreateTrunc(Ops[1],Builder.getInt32Ty())});
       }
       }] in {
     foreach dst_lmul = ["(LFixedLog2LMUL:1)", "(LFixedLog2LMUL:2)", "(LFixedLog2LMUL:3)"] in {



More information about the cfe-commits mailing list