-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[SystemZ] Add support for half (fp16) #109164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b2c4084
Initial experiments (with integer regs for fp16).
JonPsson1 aefc5cc
Review updates
JonPsson1 cde94f8
Updated per review + fix.
JonPsson1 25576d7
Updates
JonPsson1 1aff968
Add extendhfdf2_test.c
JonPsson1 9f97d49
Rebase
JonPsson1 9ed85d3
Updates per review.
JonPsson1 ddef5ab
Review updates.
JonPsson1 ae1bea6
Wait with FCOPYSIGN optimization.
JonPsson1 fd0f04c
Fix typo
JonPsson1 6bad83a
Update SystemZScheduleZ17.td
JonPsson1 0c2b0c8
Minor updates of two CodeGen/SystemZ tests
JonPsson1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// RUN: %clang_cc1 -triple s390x-linux-gnu \ | ||
// RUN: -ffloat16-excess-precision=standard -emit-llvm -o - %s \ | ||
// RUN: | FileCheck %s -check-prefix=STANDARD | ||
|
||
// RUN: %clang_cc1 -triple s390x-linux-gnu \ | ||
// RUN: -ffloat16-excess-precision=none -emit-llvm -o - %s \ | ||
// RUN: | FileCheck %s -check-prefix=NONE | ||
|
||
// RUN: %clang_cc1 -triple s390x-linux-gnu \ | ||
// RUN: -ffloat16-excess-precision=fast -emit-llvm -o - %s \ | ||
// RUN: | FileCheck %s -check-prefix=FAST | ||
|
||
_Float16 f(_Float16 a, _Float16 b, _Float16 c, _Float16 d) { | ||
return a * b + c * d; | ||
} | ||
|
||
// STANDARD-LABEL: define dso_local half @f(half noundef %a, half noundef %b, half noundef %c, half noundef %d) #0 { | ||
// STANDARD-NEXT: entry: | ||
// STANDARD-NEXT: %a.addr = alloca half, align 2 | ||
// STANDARD-NEXT: %b.addr = alloca half, align 2 | ||
// STANDARD-NEXT: %c.addr = alloca half, align 2 | ||
// STANDARD-NEXT: %d.addr = alloca half, align 2 | ||
// STANDARD-NEXT: store half %a, ptr %a.addr, align 2 | ||
// STANDARD-NEXT: store half %b, ptr %b.addr, align 2 | ||
// STANDARD-NEXT: store half %c, ptr %c.addr, align 2 | ||
// STANDARD-NEXT: store half %d, ptr %d.addr, align 2 | ||
// STANDARD-NEXT: %0 = load half, ptr %a.addr, align 2 | ||
// STANDARD-NEXT: %ext = fpext half %0 to float | ||
// STANDARD-NEXT: %1 = load half, ptr %b.addr, align 2 | ||
// STANDARD-NEXT: %ext1 = fpext half %1 to float | ||
// STANDARD-NEXT: %mul = fmul float %ext, %ext1 | ||
// STANDARD-NEXT: %2 = load half, ptr %c.addr, align 2 | ||
// STANDARD-NEXT: %ext2 = fpext half %2 to float | ||
// STANDARD-NEXT: %3 = load half, ptr %d.addr, align 2 | ||
// STANDARD-NEXT: %ext3 = fpext half %3 to float | ||
// STANDARD-NEXT: %mul4 = fmul float %ext2, %ext3 | ||
// STANDARD-NEXT: %add = fadd float %mul, %mul4 | ||
// STANDARD-NEXT: %unpromotion = fptrunc float %add to half | ||
// STANDARD-NEXT: ret half %unpromotion | ||
// STANDARD-NEXT: } | ||
|
||
// NONE-LABEL: define dso_local half @f(half noundef %a, half noundef %b, half noundef %c, half noundef %d) #0 { | ||
// NONE-NEXT: entry: | ||
// NONE-NEXT: %a.addr = alloca half, align 2 | ||
// NONE-NEXT: %b.addr = alloca half, align 2 | ||
// NONE-NEXT: %c.addr = alloca half, align 2 | ||
// NONE-NEXT: %d.addr = alloca half, align 2 | ||
// NONE-NEXT: store half %a, ptr %a.addr, align 2 | ||
// NONE-NEXT: store half %b, ptr %b.addr, align 2 | ||
// NONE-NEXT: store half %c, ptr %c.addr, align 2 | ||
// NONE-NEXT: store half %d, ptr %d.addr, align 2 | ||
// NONE-NEXT: %0 = load half, ptr %a.addr, align 2 | ||
// NONE-NEXT: %1 = load half, ptr %b.addr, align 2 | ||
// NONE-NEXT: %mul = fmul half %0, %1 | ||
// NONE-NEXT: %2 = load half, ptr %c.addr, align 2 | ||
// NONE-NEXT: %3 = load half, ptr %d.addr, align 2 | ||
// NONE-NEXT: %mul1 = fmul half %2, %3 | ||
// NONE-NEXT: %add = fadd half %mul, %mul1 | ||
// NONE-NEXT: ret half %add | ||
// NONE-NEXT: } | ||
|
||
// FAST-LABEL: define dso_local half @f(half noundef %a, half noundef %b, half noundef %c, half noundef %d) #0 { | ||
// FAST-NEXT: entry: | ||
// FAST-NEXT: %a.addr = alloca half, align 2 | ||
// FAST-NEXT: %b.addr = alloca half, align 2 | ||
// FAST-NEXT: %c.addr = alloca half, align 2 | ||
// FAST-NEXT: %d.addr = alloca half, align 2 | ||
// FAST-NEXT: store half %a, ptr %a.addr, align 2 | ||
// FAST-NEXT: store half %b, ptr %b.addr, align 2 | ||
// FAST-NEXT: store half %c, ptr %c.addr, align 2 | ||
// FAST-NEXT: store half %d, ptr %d.addr, align 2 | ||
// FAST-NEXT: %0 = load half, ptr %a.addr, align 2 | ||
// FAST-NEXT: %ext = fpext half %0 to float | ||
// FAST-NEXT: %1 = load half, ptr %b.addr, align 2 | ||
// FAST-NEXT: %ext1 = fpext half %1 to float | ||
// FAST-NEXT: %mul = fmul float %ext, %ext1 | ||
// FAST-NEXT: %2 = load half, ptr %c.addr, align 2 | ||
// FAST-NEXT: %ext2 = fpext half %2 to float | ||
// FAST-NEXT: %3 = load half, ptr %d.addr, align 2 | ||
// FAST-NEXT: %ext3 = fpext half %3 to float | ||
// FAST-NEXT: %mul4 = fmul float %ext2, %ext3 | ||
// FAST-NEXT: %add = fadd float %mul, %mul4 | ||
// FAST-NEXT: %unpromotion = fptrunc float %add to half | ||
// FAST-NEXT: ret half %unpromotion | ||
// FAST-NEXT: } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// RUN: %clang_cc1 -triple s390x-linux-gnu -emit-llvm -o - %s \ | ||
// RUN: | FileCheck %s | ||
|
||
void f(__fp16 *a, __fp16 *b, __fp16 *c, __fp16 *d, __fp16 *e) { | ||
*e = (*a) * (*b) + (*c) * (*d); | ||
} | ||
|
||
// CHECK-LABEL: define dso_local void @f(ptr noundef %a, ptr noundef %b, ptr noundef %c, ptr noundef %d, ptr noundef %e) #0 { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: %a.addr = alloca ptr, align 8 | ||
// CHECK-NEXT: %b.addr = alloca ptr, align 8 | ||
// CHECK-NEXT: %c.addr = alloca ptr, align 8 | ||
// CHECK-NEXT: %d.addr = alloca ptr, align 8 | ||
// CHECK-NEXT: %e.addr = alloca ptr, align 8 | ||
// CHECK-NEXT: store ptr %a, ptr %a.addr, align 8 | ||
// CHECK-NEXT: store ptr %b, ptr %b.addr, align 8 | ||
// CHECK-NEXT: store ptr %c, ptr %c.addr, align 8 | ||
// CHECK-NEXT: store ptr %d, ptr %d.addr, align 8 | ||
// CHECK-NEXT: store ptr %e, ptr %e.addr, align 8 | ||
// CHECK-NEXT: %0 = load ptr, ptr %a.addr, align 8 | ||
// CHECK-NEXT: %1 = load half, ptr %0, align 2 | ||
// CHECK-NEXT: %conv = fpext half %1 to float | ||
// CHECK-NEXT: %2 = load ptr, ptr %b.addr, align 8 | ||
// CHECK-NEXT: %3 = load half, ptr %2, align 2 | ||
// CHECK-NEXT: %conv1 = fpext half %3 to float | ||
// CHECK-NEXT: %mul = fmul float %conv, %conv1 | ||
// CHECK-NEXT: %4 = load ptr, ptr %c.addr, align 8 | ||
// CHECK-NEXT: %5 = load half, ptr %4, align 2 | ||
// CHECK-NEXT: %conv2 = fpext half %5 to float | ||
// CHECK-NEXT: %6 = load ptr, ptr %d.addr, align 8 | ||
// CHECK-NEXT: %7 = load half, ptr %6, align 2 | ||
// CHECK-NEXT: %conv3 = fpext half %7 to float | ||
// CHECK-NEXT: %mul4 = fmul float %conv2, %conv3 | ||
// CHECK-NEXT: %add = fadd float %mul, %mul4 | ||
// CHECK-NEXT: %8 = fptrunc float %add to half | ||
// CHECK-NEXT: %9 = load ptr, ptr %e.addr, align 8 | ||
// CHECK-NEXT: store half %8, ptr %9, align 2 | ||
// CHECK-NEXT: ret void | ||
// CHECK-NEXT: } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.