Skip to content

Commit

Permalink
[clang][RISCV] Set HasLegalHalfType to true if zhinx is enabled
Browse files Browse the repository at this point in the history
Now that codegen support for zhinx in landed (D149811), we should set
HasLegalHalfType=true for zhinx (see D145071 for the patch doing this
for zfh).

Differential Revision: https://reviews.llvm.org/D150777
  • Loading branch information
asb committed May 18, 2023
1 parent 0bf5f63 commit 8e82376
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion clang/lib/Basic/Targets/RISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ bool RISCVTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
if (ABI.empty())
ABI = ISAInfo->computeDefaultABI().str();

if (ISAInfo->hasExtension("zfh"))
if (ISAInfo->hasExtension("zfh") || ISAInfo->hasExtension("zhinx"))
HasLegalHalfType = true;

return true;
Expand Down
7 changes: 2 additions & 5 deletions clang/test/CodeGen/RISCV/Float16-arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@ _Float16 x, y, z;
// 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() {
Expand Down

0 comments on commit 8e82376

Please sign in to comment.