From d245c72f2a92a74ccda83f41758c1948ae5132d3 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 24 Aug 2022 10:56:53 -0700 Subject: Compiler time evaluation of all int and bool operators. (#2376) * Compiler time evaluation of all int and bool operators. * Fix linux compile error. * Fix. Co-authored-by: Yong He --- .../generics/generic-value-constant-folding.slang | 13 +++++++------ .../generic-value-constant-folding.slang.expected.txt | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'tests/language-feature') diff --git a/tests/language-feature/generics/generic-value-constant-folding.slang b/tests/language-feature/generics/generic-value-constant-folding.slang index 1d6781889..f7525e6fd 100644 --- a/tests/language-feature/generics/generic-value-constant-folding.slang +++ b/tests/language-feature/generics/generic-value-constant-folding.slang @@ -1,13 +1,13 @@ //TEST(compute):COMPARE_COMPUTE: -shaderobj -output-using-type struct PlusOne -{ - static const int value = v + 1; +{ + static const int value = v > 0? v + 1 : v - 1; } struct GetConst { - static const int value = (u+v)*(u+v) + PlusOne.value; + static const int value = (u/2+v)*(u+v) / PlusOne.value; int arr[value]; } @@ -19,7 +19,8 @@ void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) { int tid = dispatchThreadID.x; int inVal = tid; - int arr[GetConst<5,2>.value + 1]; - arr[0] = GetConst<5,3>.value + 1; - outputBuffer[tid] = arr[0]; + int arr[GetConst<5, 2>.value + 1]; + GetConst<5, 3> obj; + obj.arr[0] = GetConst<5, 3>.value + 1; + outputBuffer[tid] = obj.arr[0]; } diff --git a/tests/language-feature/generics/generic-value-constant-folding.slang.expected.txt b/tests/language-feature/generics/generic-value-constant-folding.slang.expected.txt index 2ba17a828..ebb66dc8d 100644 --- a/tests/language-feature/generics/generic-value-constant-folding.slang.expected.txt +++ b/tests/language-feature/generics/generic-value-constant-folding.slang.expected.txt @@ -1,5 +1,5 @@ type: int32_t -68 -68 -68 -68 +17 +17 +17 +17 \ No newline at end of file -- cgit v1.2.3