-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[HLSL] Add additional overloads for min and max to allow for mixed scalar and vector arguments #129334
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
[HLSL] Add additional overloads for min and max to allow for mixed scalar and vector arguments #129334
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,9 @@ int16_t3 test_min_short3(int16_t3 p0, int16_t3 p1) { return min(p0, p1); } | |
| // NATIVE_HALF-LABEL: define noundef <4 x i16> @_Z15test_min_short4 | ||
| // NATIVE_HALF: call <4 x i16> @llvm.smin.v4i16 | ||
| int16_t4 test_min_short4(int16_t4 p0, int16_t4 p1) { return min(p0, p1); } | ||
| // NATIVE_HALF-LABEL: define noundef <4 x i16> {{.*}}test_min_short4_mismatch | ||
| // NATIVE_HALF: call <4 x i16> @llvm.smin.v4i16 | ||
| int16_t4 test_min_short4_mismatch(int16_t4 p0, int16_t p1) { return min(p0, p1); } | ||
|
|
||
| // NATIVE_HALF-LABEL: define noundef i16 @_Z15test_min_ushort | ||
| // NATIVE_HALF: call i16 @llvm.umin.i16( | ||
|
|
@@ -31,6 +34,9 @@ uint16_t3 test_min_ushort3(uint16_t3 p0, uint16_t3 p1) { return min(p0, p1); } | |
| // NATIVE_HALF-LABEL: define noundef <4 x i16> @_Z16test_min_ushort4 | ||
| // NATIVE_HALF: call <4 x i16> @llvm.umin.v4i16 | ||
| uint16_t4 test_min_ushort4(uint16_t4 p0, uint16_t4 p1) { return min(p0, p1); } | ||
| // NATIVE_HALF-LABEL: define noundef <4 x i16> {{.*}}test_min_ushort4_mismatch | ||
| // NATIVE_HALF: call <4 x i16> @llvm.umin.v4i16 | ||
| uint16_t4 test_min_ushort4_mismatch(uint16_t4 p0, uint16_t p1) { return min(p0, p1); } | ||
| #endif | ||
|
|
||
| // CHECK-LABEL: define noundef i32 @_Z12test_min_int | ||
|
|
@@ -45,6 +51,9 @@ int3 test_min_int3(int3 p0, int3 p1) { return min(p0, p1); } | |
| // CHECK-LABEL: define noundef <4 x i32> @_Z13test_min_int4 | ||
| // CHECK: call <4 x i32> @llvm.smin.v4i32 | ||
| int4 test_min_int4(int4 p0, int4 p1) { return min(p0, p1); } | ||
| // CHECK-LABEL: define noundef <4 x i32> {{.*}}test_min_int4_mismatch | ||
| // CHECK: call <4 x i32> @llvm.smin.v4i32 | ||
| int4 test_min_int4_mismatch(int4 p0, int p1) { return min(p0, p1); } | ||
|
|
||
| // CHECK-LABEL: define noundef i32 @_Z13test_min_uint | ||
| // CHECK: call i32 @llvm.umin.i32( | ||
|
|
@@ -58,6 +67,9 @@ uint3 test_min_uint3(uint3 p0, uint3 p1) { return min(p0, p1); } | |
| // CHECK-LABEL: define noundef <4 x i32> @_Z14test_min_uint4 | ||
| // CHECK: call <4 x i32> @llvm.umin.v4i32 | ||
| uint4 test_min_uint4(uint4 p0, uint4 p1) { return min(p0, p1); } | ||
| // CHECK-LABEL: define noundef <4 x i32> {{.*}}test_min_uint4_mismatch | ||
| // CHECK: call <4 x i32> @llvm.umin.v4i32 | ||
| uint4 test_min_uint4_mismatch(uint4 p0, uint p1) { return min(p0, p1); } | ||
|
|
||
| // CHECK-LABEL: define noundef i64 @_Z13test_min_long | ||
| // CHECK: call i64 @llvm.smin.i64( | ||
|
|
@@ -71,6 +83,9 @@ int64_t3 test_min_long3(int64_t3 p0, int64_t3 p1) { return min(p0, p1); } | |
| // CHECK-LABEL: define noundef <4 x i64> @_Z14test_min_long4 | ||
| // CHECK: call <4 x i64> @llvm.smin.v4i64 | ||
| int64_t4 test_min_long4(int64_t4 p0, int64_t4 p1) { return min(p0, p1); } | ||
| // CHECK-LABEL: define noundef <4 x i64> {{.*}}test_min_long4_mismatch | ||
| // CHECK: call <4 x i64> @llvm.smin.v4i64 | ||
| int64_t4 test_min_long4_mismatch(int64_t4 p0, int64_t p1) { return min(p0, p1); } | ||
|
|
||
| // CHECK-LABEL: define noundef i64 @_Z14test_min_ulong | ||
| // CHECK: call i64 @llvm.umin.i64( | ||
|
|
@@ -84,6 +99,9 @@ uint64_t3 test_min_ulong3(uint64_t3 p0, uint64_t3 p1) { return min(p0, p1); } | |
| // CHECK-LABEL: define noundef <4 x i64> @_Z15test_min_ulong4 | ||
| // CHECK: call <4 x i64> @llvm.umin.v4i64 | ||
| uint64_t4 test_min_ulong4(uint64_t4 p0, uint64_t4 p1) { return min(p0, p1); } | ||
| // CHECK-LABEL: define noundef <4 x i64> {{.*}}test_min_ulong4_mismatch | ||
| // CHECK: call <4 x i64> @llvm.umin.v4i64 | ||
| uint64_t4 test_min_ulong4_mismatch(uint64_t4 p0, uint64_t p1) { return min(p0, p1); } | ||
|
|
||
| // NATIVE_HALF-LABEL: define noundef nofpclass(nan inf) half @_Z13test_min_half | ||
| // NATIVE_HALF: call reassoc nnan ninf nsz arcp afn half @llvm.minnum.f16( | ||
|
|
@@ -105,6 +123,11 @@ half3 test_min_half3(half3 p0, half3 p1) { return min(p0, p1); } | |
| // NO_HALF-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z14test_min_half4 | ||
| // NO_HALF: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.minnum.v4f32( | ||
| half4 test_min_half4(half4 p0, half4 p1) { return min(p0, p1); } | ||
| // NATIVE_HALF-LABEL: define noundef nofpclass(nan inf) <4 x half> {{.*}}test_min_half4_mismatch | ||
| // NATIVE_HALF: call reassoc nnan ninf nsz arcp afn <4 x half> @llvm.minnum.v4f16 | ||
| // NO_HALF-LABEL: define noundef nofpclass(nan inf) <4 x float> {{.*}}test_min_half4_mismatch | ||
| // NO_HALF: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.minnum.v4f32( | ||
| half4 test_min_half4_mismatch(half4 p0, half p1) { return min(p0, p1); } | ||
|
|
||
| // CHECK-LABEL: define noundef nofpclass(nan inf) float @_Z14test_min_float | ||
| // CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.minnum.f32( | ||
|
|
@@ -118,6 +141,9 @@ float3 test_min_float3(float3 p0, float3 p1) { return min(p0, p1); } | |
| // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z15test_min_float4 | ||
| // CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.minnum.v4f32 | ||
| float4 test_min_float4(float4 p0, float4 p1) { return min(p0, p1); } | ||
| // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> {{.*}}test_min_float4_mismatch | ||
| // CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.minnum.v4f32 | ||
| float4 test_min_float4_mismatch(float4 p0, float p1) { return min(p0, p1); } | ||
|
|
||
| // CHECK-LABEL: define noundef nofpclass(nan inf) double @_Z15test_min_double | ||
| // CHECK: call reassoc nnan ninf nsz arcp afn double @llvm.minnum.f64( | ||
|
|
@@ -131,3 +157,9 @@ double3 test_min_double3(double3 p0, double3 p1) { return min(p0, p1); } | |
| // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> @_Z16test_min_double4 | ||
| // CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.minnum.v4f64 | ||
| double4 test_min_double4(double4 p0, double4 p1) { return min(p0, p1); } | ||
| // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> {{.*}}test_min_double4_mismatch | ||
| // CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.minnum.v4f64 | ||
| double4 test_min_double4_mismatch(double4 p0, double p1) { return min(p0, p1); } | ||
| // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> {{.*}}test_min_double4_mismatch2 | ||
| // CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.minnum.v4f64 | ||
| double4 test_min_double4_mismatch2(double4 p0, double p1) { return min(p1, p0); } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this parameter swap test be applicable to all the rest of the tests? Why just double?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I just didn't want to add tons of tests; I also didn't add a test for each size of vector, only the vec4s. I can add more tests if you think its important. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user were to call the max function with, say, a half2 and a half3, is it our intention to reject that / emit an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that is my understanding
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only want to aditionally allow things of the form max(vector<T,N>, T) or max(T, vector<T,N>)