-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Clang][AMDGPU] Add __builtin_amdgcn_cvt_off_f32_i4 #133741
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 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
41af387
[Clang][AMDGPU] Add __builtin_amdgcn_cvt_off_f32_i4
jmmartinez dc78e8a
[Review] Turn builtin input from unsigned to signed
jmmartinez 1cf0a9c
[Review] Added signed OpenCL CodeGen test
jmmartinez c10a091
[Review] Add line in the Release notes
jmmartinez 73efe54
[Review] Move pattern into instruction declaration
jmmartinez 89520ee
[Review] Handle undef & poison and update tests
jmmartinez eea660c
CI4BitAsInt -> CArg4BitAsInt
jmmartinez 4b7a154
[Review] Forgot the constexpr case
jmmartinez 57f299e
[Review] Tabulate the operation result to avoid operations that could…
jmmartinez e87dd39
[Review] static constexpr and mask
jmmartinez 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
27 changes: 27 additions & 0 deletions
27
clang/test/CodeGenOpenCL/builtins-amdgcn-cvt-off-f32-i4.cl
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,27 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py | ||
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL1.2 \ | ||
// RUN: -emit-llvm -o - | FileCheck %s | ||
|
||
// CHECK-LABEL: @test_builtin_amdgcn_cvt_off_f32_i4_ui( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5) | ||
// CHECK-NEXT: store i32 [[N:%.*]], ptr addrspace(5) [[N_ADDR]], align 4 | ||
// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4 | ||
// CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.amdgcn.cvt.off.f32.i4(i32 [[TMP0]]) | ||
// CHECK-NEXT: ret float [[TMP1]] | ||
// | ||
float test_builtin_amdgcn_cvt_off_f32_i4_ui(unsigned n) { | ||
return __builtin_amdgcn_cvt_off_f32_i4(n); | ||
} | ||
|
||
// CHECK-LABEL: @test_builtin_amdgcn_cvt_off_f32_i4_i( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5) | ||
// CHECK-NEXT: store i32 [[N:%.*]], ptr addrspace(5) [[N_ADDR]], align 4 | ||
// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4 | ||
// CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.amdgcn.cvt.off.f32.i4(i32 [[TMP0]]) | ||
// CHECK-NEXT: ret float [[TMP1]] | ||
// | ||
float test_builtin_amdgcn_cvt_off_f32_i4_i(int n) { | ||
return __builtin_amdgcn_cvt_off_f32_i4(n); | ||
} |
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,8 @@ | ||
// RUN: %clang_cc1 -triple amdgcn-- -verify -S -o - %s | ||
|
||
void test_builtin_amdgcn_cvt_off_f32_i4(int n) { | ||
struct A{ unsigned x; } a; | ||
__builtin_amdgcn_cvt_off_f32_i4(n, n); // expected-error {{too many arguments to function call, expected 1, have 2}} | ||
__builtin_amdgcn_cvt_off_f32_i4(); // expected-error {{too few arguments to function call, expected 1, have 0}} | ||
__builtin_amdgcn_cvt_off_f32_i4(a); // expected-error {{passing '__private struct A' to parameter of incompatible type 'int'}} | ||
} |
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
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,23 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc -mtriple=amdgcn -mcpu=gfx90a -verify-machineinstrs %s -o - | FileCheck %s | ||
; RUN: llc -mtriple=amdgcn -mcpu=gfx90a -verify-machineinstrs %s --global-isel -o - | FileCheck %s | ||
jmmartinez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
declare float @llvm.amdgcn.cvt.off.f32.i4(i32) | ||
|
||
define amdgpu_cs float @cvt_var(i32 %a) { | ||
; CHECK-LABEL: cvt_var: | ||
; CHECK: ; %bb.0: | ||
; CHECK-NEXT: v_cvt_off_f32_i4_e32 v0, v0 | ||
; CHECK-NEXT: ; return to shader part epilog | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 %a) | ||
ret float %ret | ||
} | ||
|
||
define amdgpu_cs float @cvt_imm() { | ||
; CHECK-LABEL: cvt_imm: | ||
; CHECK: ; %bb.0: | ||
; CHECK-NEXT: v_cvt_off_f32_i4_e32 v0, 4 | ||
; CHECK-NEXT: ; return to shader part epilog | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 4) | ||
ret float %ret | ||
} |
158 changes: 158 additions & 0 deletions
158
llvm/test/CodeGen/AMDGPU/simplify-amdgcn.cvt.off.f32.i4.ll
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,158 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=instcombine < %s | FileCheck %s | ||
jmmartinez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
jmmartinez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
declare float @llvm.amdgcn.cvt.off.f32.i4(i32) | ||
|
||
define float @cvt_var(i32 %a) { | ||
; CHECK-LABEL: define float @cvt_var( | ||
; CHECK-SAME: i32 [[A:%.*]]) { | ||
; CHECK-NEXT: [[RET:%.*]] = call float @llvm.amdgcn.cvt.off.f32.i4(i32 [[A]]) | ||
; CHECK-NEXT: ret float [[RET]] | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 %a) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_0() { | ||
; CHECK-LABEL: define float @cvt_imm_0() { | ||
; CHECK-NEXT: ret float 0.000000e+00 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 0) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_1() { | ||
; CHECK-LABEL: define float @cvt_imm_1() { | ||
; CHECK-NEXT: ret float 6.250000e-02 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 1) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_2() { | ||
; CHECK-LABEL: define float @cvt_imm_2() { | ||
; CHECK-NEXT: ret float 1.250000e-01 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 2) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_3() { | ||
; CHECK-LABEL: define float @cvt_imm_3() { | ||
; CHECK-NEXT: ret float 1.875000e-01 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 3) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_4() { | ||
; CHECK-LABEL: define float @cvt_imm_4() { | ||
; CHECK-NEXT: ret float 2.500000e-01 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 4) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_5() { | ||
; CHECK-LABEL: define float @cvt_imm_5() { | ||
; CHECK-NEXT: ret float 3.125000e-01 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 5) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_6() { | ||
; CHECK-LABEL: define float @cvt_imm_6() { | ||
; CHECK-NEXT: ret float 3.750000e-01 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 6) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_7() { | ||
; CHECK-LABEL: define float @cvt_imm_7() { | ||
; CHECK-NEXT: ret float 4.375000e-01 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 7) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_8() { | ||
; CHECK-LABEL: define float @cvt_imm_8() { | ||
; CHECK-NEXT: ret float -5.000000e-01 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 8) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_9() { | ||
; CHECK-LABEL: define float @cvt_imm_9() { | ||
; CHECK-NEXT: ret float -4.375000e-01 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 9) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_10() { | ||
; CHECK-LABEL: define float @cvt_imm_10() { | ||
; CHECK-NEXT: ret float -3.750000e-01 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 10) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_11() { | ||
; CHECK-LABEL: define float @cvt_imm_11() { | ||
; CHECK-NEXT: ret float -3.125000e-01 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 11) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_12() { | ||
; CHECK-LABEL: define float @cvt_imm_12() { | ||
; CHECK-NEXT: ret float -2.500000e-01 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 12) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_13() { | ||
; CHECK-LABEL: define float @cvt_imm_13() { | ||
; CHECK-NEXT: ret float -1.875000e-01 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 13) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_14() { | ||
; CHECK-LABEL: define float @cvt_imm_14() { | ||
; CHECK-NEXT: ret float -1.250000e-01 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 14) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_15() { | ||
; CHECK-LABEL: define float @cvt_imm_15() { | ||
; CHECK-NEXT: ret float -6.250000e-02 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 15) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_underflow() { | ||
; CHECK-LABEL: define float @cvt_imm_underflow() { | ||
; CHECK-NEXT: ret float -6.250000e-02 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 -1) | ||
ret float %ret | ||
} | ||
|
||
define float @cvt_imm_overflow() { | ||
; CHECK-LABEL: define float @cvt_imm_overflow() { | ||
; CHECK-NEXT: ret float 0.000000e+00 | ||
; | ||
%ret = call float @llvm.amdgcn.cvt.off.f32.i4(i32 16) | ||
ret float %ret | ||
} |
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.