Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

4vtomat
Copy link
Member

@4vtomat 4vtomat commented Oct 8, 2024

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

@llvmbot llvmbot added clang Clang issues not falling into any other category backend:RISC-V clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Oct 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 8, 2024

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

@llvm/pr-subscribers-clang

Author: Brandon Wu (4vtomat)

Changes

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

@topperc
Copy link
Collaborator

topperc commented Oct 8, 2024

test?

…insert be truncated rather than zero extended

It's illegal if the index is 64 bits and is zero-extend to 32 bits.
@4vtomat 4vtomat force-pushed the tuple_intrinsic_utils branch from 6e11ffa to cd79ab5 Compare October 8, 2024 02:57
@4vtomat
Copy link
Member Author

4vtomat commented Oct 8, 2024

test?

Added!

Copy link
Contributor

@wangpc-pp wangpc-pp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@4vtomat 4vtomat merged commit 8ab7718 into llvm:main Oct 8, 2024
9 checks passed
@4vtomat 4vtomat deleted the tuple_intrinsic_utils branch October 8, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:RISC-V clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants