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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v

@llvm/pr-subscribers-clang

Author: Brandon Wu (4vtomat)

<details>
<summary>Changes</summary>

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


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


1 Files Affected:

- (modified) clang/include/clang/Basic/riscv_vector.td (+2-2) 


``````````diff
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 {

``````````

</details>


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


More information about the cfe-commits mailing list