From cb5dd19992fb77ca2be866d9c6f2f4436c8b1c1e Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 7 Sep 2023 23:01:53 -0700 Subject: Incur l-value conversion cost during overload resolution. (#3195) * Incur l-value conversion cost during overload resolution. * Fix compile error. * cleanup. --------- Co-authored-by: Yong He --- tests/language-feature/overload-resolution.slang | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/language-feature/overload-resolution.slang (limited to 'tests') diff --git a/tests/language-feature/overload-resolution.slang b/tests/language-feature/overload-resolution.slang new file mode 100644 index 000000000..9c135137a --- /dev/null +++ b/tests/language-feature/overload-resolution.slang @@ -0,0 +1,45 @@ +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage compute -entry main +RWStructuredBuffer result; + +[ForceInline] +float myF(inout int a, int b) +{ + return a + b; +} + +[ForceInline] +float myF(inout uint a, uint b) +{ + return a - b; +} + +[ForceInline] +T myGenF(inout T a, T b) +{ + if (__isSignedInt()) + { + return a + b; + } + else + { + return a - b; + } +} +// CHECK: result{{.*}}[0{{U?}}] = 1 +// CHECK: result{{.*}}[1{{U?}}] = 4 +// CHECK: result{{.*}}[2{{U?}}] = 1 +// CHECK: result{{.*}}[3{{U?}}] = 4 +[numthreads(1,1,1)] +void main() +{ + int ic = 1; + uint a = 2; + result[0] = myF(a, ic); + + int b = 3; + uint uc = 1; + result[1] = myF(b, uc); + + result[2] = myGenF(a, ic); + result[3] = myGenF(b, uc); +} \ No newline at end of file -- cgit v1.2.3