Skip to content
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

[Clang][RISCV][RVV Intrinsic] Fix codegen redundant intrinsic names #77889

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

circYuan
Copy link
Contributor

This patch avoids adding redundant vcreate_v intrinsics to the RISCV IntrinsicList.
Since vcreate_v uses LFixedLog2LMUL, I believe we can simply set Log2LMUL to the smallest value (-3) to prevent the creation of redundant vcreate_v instances with the same intrinsic name and prototype in the IntrinsicList when clang creates it.

Since vcreate_v uses the FixLog2LMUL, we can simply set the Log2LMUL to
the smallest one to avoid creating redundant vcreate_v which contains
the same intrinsic name and the same prototype.
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@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 Jan 12, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 12, 2024

@llvm/pr-subscribers-clang

Author: 袁銓嶽 (circYuan)

Changes

This patch avoids adding redundant vcreate_v intrinsics to the RISCV IntrinsicList.
Since vcreate_v uses LFixedLog2LMUL, I believe we can simply set Log2LMUL to the smallest value (-3) to prevent the creation of redundant vcreate_v instances with the same intrinsic name and prototype in the IntrinsicList when clang creates it.


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

1 Files Affected:

  • (modified) clang/include/clang/Basic/riscv_vector.td (+5-3)
diff --git a/clang/include/clang/Basic/riscv_vector.td b/clang/include/clang/Basic/riscv_vector.td
index e7d78b03511fe9..1411d5375bdadd 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -2479,9 +2479,11 @@ let HasMasked = false, HasVL = false, IRName = "" in {
       }
       }] in {
 
-    defm : RVVNonTupleVCreateBuiltin<1, [0]>;
-    defm : RVVNonTupleVCreateBuiltin<2, [0, 1]>;
-    defm : RVVNonTupleVCreateBuiltin<3, [0, 1, 2]>;
+    let Log2LMUL = [-3] in {
+      defm : RVVNonTupleVCreateBuiltin<1, [0]>;
+      defm : RVVNonTupleVCreateBuiltin<2, [0, 1]>;
+      defm : RVVNonTupleVCreateBuiltin<3, [0, 1, 2]>;
+    }
 
     foreach nf = NFList in {
       let NF = nf in {

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 12, 2024

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

Author: 袁銓嶽 (circYuan)

Changes

This patch avoids adding redundant vcreate_v intrinsics to the RISCV IntrinsicList.
Since vcreate_v uses LFixedLog2LMUL, I believe we can simply set Log2LMUL to the smallest value (-3) to prevent the creation of redundant vcreate_v instances with the same intrinsic name and prototype in the IntrinsicList when clang creates it.


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

1 Files Affected:

  • (modified) clang/include/clang/Basic/riscv_vector.td (+5-3)
diff --git a/clang/include/clang/Basic/riscv_vector.td b/clang/include/clang/Basic/riscv_vector.td
index e7d78b03511fe9..1411d5375bdadd 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -2479,9 +2479,11 @@ let HasMasked = false, HasVL = false, IRName = "" in {
       }
       }] in {
 
-    defm : RVVNonTupleVCreateBuiltin<1, [0]>;
-    defm : RVVNonTupleVCreateBuiltin<2, [0, 1]>;
-    defm : RVVNonTupleVCreateBuiltin<3, [0, 1, 2]>;
+    let Log2LMUL = [-3] in {
+      defm : RVVNonTupleVCreateBuiltin<1, [0]>;
+      defm : RVVNonTupleVCreateBuiltin<2, [0, 1]>;
+      defm : RVVNonTupleVCreateBuiltin<3, [0, 1, 2]>;
+    }
 
     foreach nf = NFList in {
       let NF = nf in {

@4vtomat
Copy link
Member

4vtomat commented Jan 23, 2024

Since it only reduces about 160 of 54100 intrinsics generated, I have no opinion on this, just left the final decision to others~
But if this PR is finally decided to be merged, please add some comments around the code you added to explain, thanks!

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

@topperc
Copy link
Collaborator

topperc commented Jan 23, 2024

@circYuan do you need me to commit this for you?

@circYuan
Copy link
Contributor Author

Hi @4vtomat,
thanks for the comment, I have added the comments in the code.

Hi @topperc ,
Yes, please help me commit the patch after the new commit has been checked, many thanks!

Copy link
Member

@4vtomat 4vtomat left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM~

@topperc topperc merged commit d9dd5f0 into llvm:main Jan 26, 2024
4 checks passed
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.

None yet

4 participants