[PATCH] D145071: [clang][RISCV] Set HasLegalHalfType to true if zfh is enabled

Alex Bradbury via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 5 05:56:50 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG560065b6ecd5: [clang][RISCV] Set HasLegalHalfType to true if zfh is enabled (authored by asb).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D145071?vs=501507&id=519825#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145071/new/

https://reviews.llvm.org/D145071

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
@@ -11,8 +11,7 @@
 _Float16 x, y, z;
 
 // With no native half type support (no zfh), f16 will be promoted to f32.
-// With zfh, it shouldn't be (FIXME: set HasLegalHalfType = true in order to
-// get this behaviour for zfh).
+// With zfh, it shouldn't be.
 
 // NOZFH-LABEL: define dso_local void @f16_add
 // NOZFH-SAME: () #[[ATTR0:[0-9]+]] {
@@ -30,12 +29,9 @@
 // ZFH-SAME: () #[[ATTR0:[0-9]+]] {
 // ZFH-NEXT:  entry:
 // ZFH-NEXT:    [[TMP0:%.*]] = load half, ptr @y, align 2
-// ZFH-NEXT:    [[EXT:%.*]] = fpext half [[TMP0]] to float
 // ZFH-NEXT:    [[TMP1:%.*]] = load half, ptr @z, align 2
-// ZFH-NEXT:    [[EXT1:%.*]] = fpext half [[TMP1]] to float
-// ZFH-NEXT:    [[ADD:%.*]] = fadd float [[EXT]], [[EXT1]]
-// ZFH-NEXT:    [[UNPROMOTION:%.*]] = fptrunc float [[ADD]] to half
-// ZFH-NEXT:    store half [[UNPROMOTION]], ptr @x, align 2
+// ZFH-NEXT:    [[ADD:%.*]] = fadd half [[TMP0]], [[TMP1]]
+// ZFH-NEXT:    store half [[ADD]], ptr @x, align 2
 // ZFH-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,6 +320,9 @@
   if (ABI.empty())
     ABI = ISAInfo->computeDefaultABI().str();
 
+  if (ISAInfo->hasExtension("zfh"))
+    HasLegalHalfType = true;
+
   return true;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145071.519825.patch
Type: text/x-patch
Size: 1584 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230505/0b74c34b/attachment.bin>


More information about the cfe-commits mailing list