[PATCH] D150777: [clang][RISCV] Set HasLegalHalfType to true if zhinx is enabled

Alex Bradbury via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 17 07:10:41 PDT 2023


asb created this revision.
asb added reviewers: craig.topper, kito-cheng, realqhc.
Herald added subscribers: jobnoorman, luke, wingo, pmatos, VincentWu, 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, arichardson.
Herald added a project: All.
asb requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: clang.

Now that codegen support for zhinx in landed (D149811 <https://reviews.llvm.org/D149811>), we should set HasLegalHalfType=true for zhinx (see D145071 <https://reviews.llvm.org/D145071> for the patch doing this for zfh).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150777

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/CodeGen/RISCV/Float16-arith.c


Index: clang/test/CodeGen/RISCV/Float16-arith.c
===================================================================
--- clang/test/CodeGen/RISCV/Float16-arith.c
+++ clang/test/CodeGen/RISCV/Float16-arith.c
@@ -42,12 +42,9 @@
 // ZHINX-SAME: () #[[ATTR0:[0-9]+]] {
 // ZHINX-NEXT:  entry:
 // ZHINX-NEXT:    [[TMP0:%.*]] = load half, ptr @y, align 2
-// ZHINX-NEXT:    [[EXT:%.*]] = fpext half [[TMP0]] to float
 // ZHINX-NEXT:    [[TMP1:%.*]] = load half, ptr @z, align 2
-// ZHINX-NEXT:    [[EXT1:%.*]] = fpext half [[TMP1]] to float
-// ZHINX-NEXT:    [[ADD:%.*]] = fadd float [[EXT]], [[EXT1]]
-// ZHINX-NEXT:    [[UNPROMOTION:%.*]] = fptrunc float [[ADD]] to half
-// ZHINX-NEXT:    store half [[UNPROMOTION]], ptr @x, align 2
+// ZHINX-NEXT:    [[ADD:%.*]] = fadd half [[TMP0]], [[TMP1]]
+// ZHINX-NEXT:    store half [[ADD]], ptr @x, align 2
 // ZHINX-NEXT:    ret void
 //
 void f16_add() {
Index: clang/lib/Basic/Targets/RISCV.cpp
===================================================================
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -320,7 +320,7 @@
   if (ABI.empty())
     ABI = ISAInfo->computeDefaultABI().str();
 
-  if (ISAInfo->hasExtension("zfh"))
+  if (ISAInfo->hasExtension("zfh") || ISAInfo->hasExtension("zhinx"))
     HasLegalHalfType = true;
 
   return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150777.523041.patch
Type: text/x-patch
Size: 1328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230517/040a7f63/attachment.bin>


More information about the cfe-commits mailing list