[PATCH] D112102: [RISCV] Reduce the number of RISCV vector builtins by an order of magnitude.

Craig Topper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 19 15:42:44 PDT 2021


craig.topper created this revision.
craig.topper added reviewers: khchen, kito-cheng, arcbbb, HsiangKai, evandro, MaskRay, aeubanks, nikic.
Herald added subscribers: achieveartificialintelligence, StephenFan, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
craig.topper requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: llvm-commits.

All but 2 of the vector builtins are only used by clang_builtin_alias.
When using clang_builtin_alias, the type string of the builtin is never
checked. Only the types in the function definition used for the alias
are checked.

This patch takes advantage of this to share a single builtin for
many differnet types. We already used type overloads on the IR intrinsic
so the codegen for the builtins that are being merge were already
the same. This extends the type overloading to the builtins.

I had to make a few tweaks to make this work.
-Floating point vector-vector vmerge now uses the vmerge intrinsic
 instead of the vfmerge intrinsic. New isel patterns and tests are
 added to support this.
-The SemaChecking for the immediate of vset_v/vget_v has been removed.
 Determining the valid range is harder now. I've added masking to
 ManualCodegen to ensure valid IR for invalid input.

This reduces the number of builtins from ~2500 to ~1100.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112102

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmerge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmerge.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/test/CodeGen/RISCV/rvv/vmerge-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vmerge-rv64.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112102.380796.patch
Type: text/x-patch
Size: 57652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211019/afeb1236/attachment-0001.bin>


More information about the cfe-commits mailing list