Skip to content

Commit c7cd7a0

Browse files
committed
[clang][test][RISCV] Pre-commit test for HasLegalHalfType patch
This test captures the codegen difference of D145071.
1 parent 30ce0c9 commit c7cd7a0

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
2+
// RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - \
3+
// RUN: | FileCheck -check-prefix=NOZFH %s
4+
// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - \
5+
// RUN: | FileCheck -check-prefix=NOZFH %s
6+
// RUN: %clang_cc1 -triple riscv32 -target-feature +zfh -emit-llvm %s -o - \
7+
// RUN: | FileCheck -check-prefix=ZFH %s
8+
// RUN: %clang_cc1 -triple riscv64 -target-feature +zfh -emit-llvm %s -o - \
9+
// RUN: | FileCheck -check-prefix=ZFH %s
10+
11+
_Float16 x, y, z;
12+
13+
// With no native half type support (no zfh), f16 will be promoted to f32.
14+
// With zfh, it shouldn't be (FIXME: set HasLegalHalfType = true in order to
15+
// get this behaviour for zfh).
16+
17+
// NOZFH-LABEL: define dso_local void @f16_add
18+
// NOZFH-SAME: () #[[ATTR0:[0-9]+]] {
19+
// NOZFH-NEXT: entry:
20+
// NOZFH-NEXT: [[TMP0:%.*]] = load half, ptr @y, align 2
21+
// NOZFH-NEXT: [[EXT:%.*]] = fpext half [[TMP0]] to float
22+
// NOZFH-NEXT: [[TMP1:%.*]] = load half, ptr @z, align 2
23+
// NOZFH-NEXT: [[EXT1:%.*]] = fpext half [[TMP1]] to float
24+
// NOZFH-NEXT: [[ADD:%.*]] = fadd float [[EXT]], [[EXT1]]
25+
// NOZFH-NEXT: [[UNPROMOTION:%.*]] = fptrunc float [[ADD]] to half
26+
// NOZFH-NEXT: store half [[UNPROMOTION]], ptr @x, align 2
27+
// NOZFH-NEXT: ret void
28+
//
29+
// ZFH-LABEL: define dso_local void @f16_add
30+
// ZFH-SAME: () #[[ATTR0:[0-9]+]] {
31+
// ZFH-NEXT: entry:
32+
// ZFH-NEXT: [[TMP0:%.*]] = load half, ptr @y, align 2
33+
// ZFH-NEXT: [[EXT:%.*]] = fpext half [[TMP0]] to float
34+
// ZFH-NEXT: [[TMP1:%.*]] = load half, ptr @z, align 2
35+
// ZFH-NEXT: [[EXT1:%.*]] = fpext half [[TMP1]] to float
36+
// ZFH-NEXT: [[ADD:%.*]] = fadd float [[EXT]], [[EXT1]]
37+
// ZFH-NEXT: [[UNPROMOTION:%.*]] = fptrunc float [[ADD]] to half
38+
// ZFH-NEXT: store half [[UNPROMOTION]], ptr @x, align 2
39+
// ZFH-NEXT: ret void
40+
//
41+
void f16_add() {
42+
x = y + z;
43+
}

0 commit comments

Comments
 (0)