-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[HLSL] Implementation of the elementwise fmod builtin #108849
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
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
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,77 @@ | ||
// DirectX target: | ||
// | ||
// ---------- Native Half support test ----------- | ||
// | ||
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ | ||
// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ | ||
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ | ||
// RUN: -DFNATTRS=noundef -DTYPE=half | ||
|
||
// | ||
// ---------- No Native Half support test ----------- | ||
// | ||
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ | ||
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ | ||
// RUN: -o - | FileCheck %s \ | ||
// RUN: -DFNATTRS=noundef -DTYPE=float | ||
|
||
|
||
// Spirv target: | ||
// | ||
// ---------- Native Half support test ----------- | ||
// | ||
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ | ||
// RUN: spirv-unknown-vulkan-compute %s -fnative-half-type \ | ||
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ | ||
// RUN: -DFNATTRS="spir_func noundef" -DTYPE=half | ||
|
||
// | ||
// ---------- No Native Half support test ----------- | ||
// | ||
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ | ||
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \ | ||
// RUN: -o - | FileCheck %s \ | ||
// RUN: -DFNATTRS="spir_func noundef" -DTYPE=float | ||
|
||
|
||
|
||
// CHECK: define [[FNATTRS]] [[TYPE]] @ | ||
// CHECK: %fmod = frem [[TYPE]] | ||
// CHECK: ret [[TYPE]] %fmod | ||
half test_fmod_half(half p0, half p1) { return fmod(p0, p1); } | ||
|
||
// CHECK: define [[FNATTRS]] <2 x [[TYPE]]> @ | ||
// CHECK: %fmod = frem <2 x [[TYPE]]> | ||
// CHECK: ret <2 x [[TYPE]]> %fmod | ||
half2 test_fmod_half2(half2 p0, half2 p1) { return fmod(p0, p1); } | ||
|
||
// CHECK: define [[FNATTRS]] <3 x [[TYPE]]> @ | ||
// CHECK: %fmod = frem <3 x [[TYPE]]> | ||
// CHECK: ret <3 x [[TYPE]]> %fmod | ||
half3 test_fmod_half3(half3 p0, half3 p1) { return fmod(p0, p1); } | ||
|
||
// CHECK: define [[FNATTRS]] <4 x [[TYPE]]> @ | ||
// CHECK: %fmod = frem <4 x [[TYPE]]> | ||
// CHECK: ret <4 x [[TYPE]]> %fmod | ||
half4 test_fmod_half4(half4 p0, half4 p1) { return fmod(p0, p1); } | ||
|
||
// CHECK: define [[FNATTRS]] float @ | ||
// CHECK: %fmod = frem float | ||
// CHECK: ret float %fmod | ||
float test_fmod_float(float p0, float p1) { return fmod(p0, p1); } | ||
|
||
// CHECK: define [[FNATTRS]] <2 x float> @ | ||
// CHECK: %fmod = frem <2 x float> | ||
// CHECK: ret <2 x float> %fmod | ||
float2 test_fmod_float2(float2 p0, float2 p1) { return fmod(p0, p1); } | ||
|
||
// CHECK: define [[FNATTRS]] <3 x float> @ | ||
// CHECK: %fmod = frem <3 x float> | ||
// CHECK: ret <3 x float> %fmod | ||
float3 test_fmod_float3(float3 p0, float3 p1) { return fmod(p0, p1); } | ||
|
||
// CHECK: define [[FNATTRS]] <4 x float> @ | ||
// CHECK: %fmod = frem <4 x float> | ||
// CHECK: ret <4 x float> %fmod | ||
float4 test_fmod_float4(float4 p0, float4 p1) { return fmod(p0, p1); } | ||
|
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,22 @@ | ||
|
||
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected | ||
|
||
float builtin_bool_to_float_type_promotion(bool p1, bool p2) { | ||
return __builtin_elementwise_fmod(p1, p2); | ||
// expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'bool')}} | ||
} | ||
|
||
float2 builtin_fmod_int2_to_float2_promotion(int2 p1, int2 p2) { | ||
return __builtin_elementwise_fmod(p1, p2); | ||
// expected-error@-1 {{1st argument must be a floating point type (was 'int2' (aka 'vector<int, 2>'))}} | ||
} | ||
|
||
half builtin_fmod_double_type (double p0, double p1) { | ||
return __builtin_elementwise_fmod(p0, p1); | ||
// expected-error@-1 {{passing 'double' to parameter of incompatible type 'float'}} | ||
} | ||
|
||
half builtin_fmod_double2_type (double2 p0, double2 p1) { | ||
return __builtin_elementwise_fmod(p0, p1); | ||
// expected-error@-1 {{passing 'double2' (aka 'vector<double, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}} | ||
} |
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.