[clang] [Clang][RISCV][RVV Intrinsic] Fix codegen redundant intrinsic names (PR #77889)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 12 00:17:12 PST 2024


https://github.com/circYuan created https://github.com/llvm/llvm-project/pull/77889

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.

>From 8562ac9ab907c3b99b3890792c0f288c0e61588d Mon Sep 17 00:00:00 2001
From: Tony Chuan-Yue Yuan <yuan593 at andestech.com>
Date: Fri, 12 Jan 2024 15:31:45 +0800
Subject: [PATCH] [Clang][RISCV][RVV Intrinsic] Fix codegen redundant intrinsic
 names

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.
---
 clang/include/clang/Basic/riscv_vector.td | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

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 {



More information about the cfe-commits mailing list