| 1 |
// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -std=hlsl202x -triple \ |
| 2 |
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ |
| 3 |
// RUN: -o - | FileCheck %s |
| 4 |
|
| 5 |
// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -std=hlsl202x -triple \ |
| 6 |
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ |
| 7 |
// RUN: -o - -fexperimental-new-constant-interpreter | FileCheck %s |
| 8 |
|
| 9 |
|
| 10 |
/// This test converts V to a 1-element vector and then .xx to a 2-element vector. |
| 11 |
// CHECK-LABEL: ToTwoInts |
| 12 |
// CHECK: [[splat:%.*]] = insertelement <1 x i32> poison, i32 {{.*}}, i64 0 |
| 13 |
// CHECK: [[vec2:%.*]] = shufflevector <1 x i32> [[splat]], <1 x i32> poison, <2 x i32> zeroinitializer |
| 14 |
// CHECK: ret <2 x i32> [[vec2]] |
| 15 |
int2 ToTwoInts(int V){ |
| 16 |
return V.xx; |
| 17 |
} |
| 18 |
|
| 19 |
export void fn() { |
| 20 |
// This compiling successfully verifies that the vector constant expression |
| 21 |
// gets truncated to an integer at compile time for instantiation. |
| 22 |
_Static_assert(((int)1.xxxx) + 0 == 1, "Woo!"); |
| 23 |
|
| 24 |
// This compiling successfully verifies that the vector constant expression |
| 25 |
// gets truncated to a float at compile time for instantiation. |
| 26 |
_Static_assert(((float)1.0.xxxx) + 0.0 == 1.0, "Woo!"); |
| 27 |
|
| 28 |
// This compiling successfully verifies that a vector can be truncated to a |
| 29 |
// smaller vector, then truncated to a float as a constant expression. |
| 30 |
_Static_assert(((float2)float4(6, 5, 4, 3)).x == 6, "Woo!"); |
| 31 |
} |
| 32 |
|
| 33 |
int4 test_D3DCOLORtoUBYTE4(float4 p1) { |
| 34 |
return D3DCOLORtoUBYTE4(p1); |
| 35 |
} |
| 36 |
|
| 37 |
int4 test_constant_inputs() { |
| 38 |
return D3DCOLORtoUBYTE4(float4(0, 11.11, -50.5, 100)); |
| 39 |
} |