tint/transform/builtin_polyfill: Don't polyfill @const builtins
We don't want to replace builtins that are constant-expression
evaluated, as the replacement cannot be used as a constant expression.
Fixed: tint:1667
Change-Id: I554d9884fc41890247ee64b47a70621be5fcdbe5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107680
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/transform/builtin_polyfill.cc b/src/tint/transform/builtin_polyfill.cc
index e53dad7..8c8985f 100644
--- a/src/tint/transform/builtin_polyfill.cc
+++ b/src/tint/transform/builtin_polyfill.cc
@@ -569,6 +569,9 @@
for (auto* node : program->ASTNodes().Objects()) {
if (auto* call = sem.Get<sem::Call>(node)) {
if (auto* builtin = call->Target()->As<sem::Builtin>()) {
+ if (call->Stage() == sem::EvaluationStage::kConstant) {
+ continue; // Don't polyfill @const expressions
+ }
switch (builtin->Type()) {
case sem::BuiltinType::kAcosh:
if (builtins.acosh != Level::kNone) {
@@ -653,6 +656,9 @@
State s{ctx, builtins};
if (auto* call = s.sem.Get<sem::Call>(expr)) {
if (auto* builtin = call->Target()->As<sem::Builtin>()) {
+ if (call->Stage() == sem::EvaluationStage::kConstant) {
+ return nullptr; // Don't polyfill @const expressions
+ }
Symbol polyfill;
switch (builtin->Type()) {
case sem::BuiltinType::kAcosh:
diff --git a/src/tint/transform/builtin_polyfill_test.cc b/src/tint/transform/builtin_polyfill_test.cc
index dc76eb0..2a62910 100644
--- a/src/tint/transform/builtin_polyfill_test.cc
+++ b/src/tint/transform/builtin_polyfill_test.cc
@@ -55,20 +55,37 @@
TEST_F(BuiltinPolyfillTest, ShouldRunAcosh) {
auto* src = R"(
fn f() {
- acosh(1.0);
+ let v = 1.0;
+ acosh(v);
}
)";
EXPECT_FALSE(ShouldRun<BuiltinPolyfill>(src));
EXPECT_FALSE(ShouldRun<BuiltinPolyfill>(src, polyfillAcosh(Level::kNone)));
- EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillAcosh(Level::kClampParameters)));
+ EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillAcosh(Level::kRangeCheck)));
EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillAcosh(Level::kFull)));
}
+// TODO(crbug.com/tint/1581): Enable once `acosh` is implemented as @const
+TEST_F(BuiltinPolyfillTest, DISABLED_Acosh_ConstantExpression) {
+ auto* src = R"(
+fn f() {
+ let r : f32 = acosh(1.0);
+}
+)";
+
+ auto* expect = src;
+
+ auto got = Run<BuiltinPolyfill>(src, polyfillAcosh(Level::kFull));
+
+ EXPECT_EQ(expect, str(got));
+}
+
TEST_F(BuiltinPolyfillTest, Acosh_Full_f32) {
auto* src = R"(
fn f() {
- let r : f32 = acosh(1234);
+ let v = 1.0;
+ let r : f32 = acosh(v);
}
)";
@@ -78,7 +95,8 @@
}
fn f() {
- let r : f32 = tint_acosh(1234);
+ let v = 1.0;
+ let r : f32 = tint_acosh(v);
}
)";
@@ -90,7 +108,8 @@
TEST_F(BuiltinPolyfillTest, Acosh_Full_vec3_f32) {
auto* src = R"(
fn f() {
- let r : vec3<f32> = acosh(vec3<f32>(1234));
+ let v = 1.0;
+ let r : vec3<f32> = acosh(vec3<f32>(v));
}
)";
@@ -100,7 +119,8 @@
}
fn f() {
- let r : vec3<f32> = tint_acosh(vec3<f32>(1234));
+ let v = 1.0;
+ let r : vec3<f32> = tint_acosh(vec3<f32>(v));
}
)";
@@ -112,7 +132,8 @@
TEST_F(BuiltinPolyfillTest, Acosh_Range_f32) {
auto* src = R"(
fn f() {
- let r : f32 = acosh(1234);
+ let v = 1.0;
+ let r : f32 = acosh(v);
}
)";
@@ -122,7 +143,8 @@
}
fn f() {
- let r : f32 = tint_acosh(1234);
+ let v = 1.0;
+ let r : f32 = tint_acosh(v);
}
)";
@@ -134,7 +156,8 @@
TEST_F(BuiltinPolyfillTest, Acosh_Range_vec3_f32) {
auto* src = R"(
fn f() {
- let r : vec3<f32> = acosh(vec3<f32>(1234));
+ let v = 1.0;
+ let r : vec3<f32> = acosh(vec3<f32>(v));
}
)";
@@ -144,7 +167,8 @@
}
fn f() {
- let r : vec3<f32> = tint_acosh(vec3<f32>(1234));
+ let v = 1.0;
+ let r : vec3<f32> = tint_acosh(vec3<f32>(v));
}
)";
@@ -167,7 +191,8 @@
TEST_F(BuiltinPolyfillTest, ShouldRunAsinh) {
auto* src = R"(
fn f() {
- asinh(1.0f);
+ let v = 1.0;
+ asinh(v);
}
)";
@@ -175,10 +200,25 @@
EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillSinh()));
}
+TEST_F(BuiltinPolyfillTest, Asinh_ConstantExpression) {
+ auto* src = R"(
+fn f() {
+ let r : f32 = asinh(1.0);
+}
+)";
+
+ auto* expect = src;
+
+ auto got = Run<BuiltinPolyfill>(src, polyfillSinh());
+
+ EXPECT_EQ(expect, str(got));
+}
+
TEST_F(BuiltinPolyfillTest, Asinh_f32) {
auto* src = R"(
fn f() {
- let r : f32 = asinh(1234f);
+ let v = 1.0;
+ let r : f32 = asinh(v);
}
)";
@@ -188,7 +228,8 @@
}
fn f() {
- let r : f32 = tint_sinh(1234.0f);
+ let v = 1.0;
+ let r : f32 = tint_sinh(v);
}
)";
@@ -200,7 +241,8 @@
TEST_F(BuiltinPolyfillTest, Asinh_vec3_f32) {
auto* src = R"(
fn f() {
- let r : vec3<f32> = asinh(vec3<f32>(1234f));
+ let v = 1.0;
+ let r : vec3<f32> = asinh(vec3<f32>(v));
}
)";
@@ -210,7 +252,8 @@
}
fn f() {
- let r : vec3<f32> = tint_sinh(vec3<f32>(1234.0f));
+ let v = 1.0;
+ let r : vec3<f32> = tint_sinh(vec3<f32>(v));
}
)";
@@ -233,20 +276,37 @@
TEST_F(BuiltinPolyfillTest, ShouldRunAtanh) {
auto* src = R"(
fn f() {
- atanh(0.9f);
+ let v = 1.0;
+ atanh(v);
}
)";
EXPECT_FALSE(ShouldRun<BuiltinPolyfill>(src));
EXPECT_FALSE(ShouldRun<BuiltinPolyfill>(src, polyfillAtanh(Level::kNone)));
- EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillAtanh(Level::kClampParameters)));
+ EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillAtanh(Level::kRangeCheck)));
EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillAtanh(Level::kFull)));
}
+// TODO(crbug.com/tint/1581): Enable once `atanh` is implemented as @const
+TEST_F(BuiltinPolyfillTest, DISABLED_Atanh_ConstantExpression) {
+ auto* src = R"(
+fn f() {
+ let r : f32 = atanh(1.23);
+}
+)";
+
+ auto* expect = src;
+
+ auto got = Run<BuiltinPolyfill>(src, polyfillAtanh(Level::kFull));
+
+ EXPECT_EQ(expect, str(got));
+}
+
TEST_F(BuiltinPolyfillTest, Atanh_Full_f32) {
auto* src = R"(
fn f() {
- let r : f32 = atanh(0f);
+ let v = 1.0;
+ let r : f32 = atanh(v);
}
)";
@@ -256,7 +316,8 @@
}
fn f() {
- let r : f32 = tint_atanh(0.0f);
+ let v = 1.0;
+ let r : f32 = tint_atanh(v);
}
)";
@@ -268,7 +329,8 @@
TEST_F(BuiltinPolyfillTest, Atanh_Full_vec3_f32) {
auto* src = R"(
fn f() {
- let r : vec3<f32> = atanh(vec3<f32>(0f));
+ let v = 1.0;
+ let r : vec3<f32> = atanh(vec3<f32>(v));
}
)";
@@ -278,7 +340,8 @@
}
fn f() {
- let r : vec3<f32> = tint_atanh(vec3<f32>(0.0f));
+ let v = 1.0;
+ let r : vec3<f32> = tint_atanh(vec3<f32>(v));
}
)";
@@ -290,7 +353,8 @@
TEST_F(BuiltinPolyfillTest, Atanh_Range_f32) {
auto* src = R"(
fn f() {
- let r : f32 = atanh(0f);
+ let v = 1.0;
+ let r : f32 = atanh(v);
}
)";
@@ -300,7 +364,8 @@
}
fn f() {
- let r : f32 = tint_atanh(0.0f);
+ let v = 1.0;
+ let r : f32 = tint_atanh(v);
}
)";
@@ -312,7 +377,8 @@
TEST_F(BuiltinPolyfillTest, Atanh_Range_vec3_f32) {
auto* src = R"(
fn f() {
- let r : vec3<f32> = atanh(vec3<f32>(0f));
+ let v = 1.0;
+ let r : vec3<f32> = atanh(vec3<f32>(v));
}
)";
@@ -322,7 +388,8 @@
}
fn f() {
- let r : vec3<f32> = tint_atanh(vec3<f32>(0.0f));
+ let v = 1.0;
+ let r : vec3<f32> = tint_atanh(vec3<f32>(v));
}
)";
@@ -345,7 +412,8 @@
TEST_F(BuiltinPolyfillTest, ShouldRunCountLeadingZeros) {
auto* src = R"(
fn f() {
- countLeadingZeros(0xf);
+ let v = 15;
+ countLeadingZeros(v);
}
)";
@@ -353,10 +421,26 @@
EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillCountLeadingZeros()));
}
+// TODO(crbug.com/tint/1581): Enable once `countLeadingZeros` is implemented as @const
+TEST_F(BuiltinPolyfillTest, DISABLED_CountLeadingZeros_ConstantExpression) {
+ auto* src = R"(
+fn f() {
+ let r : i32 = countLeadingZeros(15i);
+}
+)";
+
+ auto* expect = src;
+
+ auto got = Run<BuiltinPolyfill>(src, polyfillCountLeadingZeros());
+
+ EXPECT_EQ(expect, str(got));
+}
+
TEST_F(BuiltinPolyfillTest, CountLeadingZeros_i32) {
auto* src = R"(
fn f() {
- let r : i32 = countLeadingZeros(15);
+ let v = 15i;
+ let r : i32 = countLeadingZeros(v);
}
)";
@@ -377,7 +461,8 @@
}
fn f() {
- let r : i32 = tint_count_leading_zeros(15);
+ let v = 15i;
+ let r : i32 = tint_count_leading_zeros(v);
}
)";
@@ -389,7 +474,8 @@
TEST_F(BuiltinPolyfillTest, CountLeadingZeros_u32) {
auto* src = R"(
fn f() {
- let r : u32 = countLeadingZeros(15u);
+ let v = 15u;
+ let r : u32 = countLeadingZeros(v);
}
)";
@@ -410,7 +496,8 @@
}
fn f() {
- let r : u32 = tint_count_leading_zeros(15u);
+ let v = 15u;
+ let r : u32 = tint_count_leading_zeros(v);
}
)";
@@ -422,7 +509,8 @@
TEST_F(BuiltinPolyfillTest, CountLeadingZeros_vec3_i32) {
auto* src = R"(
fn f() {
- let r : vec3<i32> = countLeadingZeros(vec3<i32>(15));
+ let v = 15i;
+ let r : vec3<i32> = countLeadingZeros(vec3<i32>(v));
}
)";
@@ -443,7 +531,8 @@
}
fn f() {
- let r : vec3<i32> = tint_count_leading_zeros(vec3<i32>(15));
+ let v = 15i;
+ let r : vec3<i32> = tint_count_leading_zeros(vec3<i32>(v));
}
)";
@@ -455,7 +544,8 @@
TEST_F(BuiltinPolyfillTest, CountLeadingZeros_vec3_u32) {
auto* src = R"(
fn f() {
- let r : vec3<u32> = countLeadingZeros(vec3<u32>(15u));
+ let v = 15u;
+ let r : vec3<u32> = countLeadingZeros(vec3<u32>(v));
}
)";
@@ -476,7 +566,8 @@
}
fn f() {
- let r : vec3<u32> = tint_count_leading_zeros(vec3<u32>(15u));
+ let v = 15u;
+ let r : vec3<u32> = tint_count_leading_zeros(vec3<u32>(v));
}
)";
@@ -499,7 +590,8 @@
TEST_F(BuiltinPolyfillTest, ShouldRunCountTrailingZeros) {
auto* src = R"(
fn f() {
- countTrailingZeros(0xf);
+ let v = 15;
+ countTrailingZeros(v);
}
)";
@@ -507,10 +599,26 @@
EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillCountTrailingZeros()));
}
+// TODO(crbug.com/tint/1581): Enable once `countTrailingZeros` is implemented as @const
+TEST_F(BuiltinPolyfillTest, DISABLED_CountTrailingZeros_ConstantExpression) {
+ auto* src = R"(
+fn f() {
+ let r : i32 = countTrailingZeros(15i);
+}
+)";
+
+ auto* expect = src;
+
+ auto got = Run<BuiltinPolyfill>(src, polyfillCountTrailingZeros());
+
+ EXPECT_EQ(expect, str(got));
+}
+
TEST_F(BuiltinPolyfillTest, CountTrailingZeros_i32) {
auto* src = R"(
fn f() {
- let r : i32 = countTrailingZeros(15);
+ let v = 15i;
+ let r : i32 = countTrailingZeros(v);
}
)";
@@ -531,7 +639,8 @@
}
fn f() {
- let r : i32 = tint_count_trailing_zeros(15);
+ let v = 15i;
+ let r : i32 = tint_count_trailing_zeros(v);
}
)";
@@ -543,7 +652,8 @@
TEST_F(BuiltinPolyfillTest, CountTrailingZeros_u32) {
auto* src = R"(
fn f() {
- let r : u32 = countTrailingZeros(15u);
+ let v = 15u;
+ let r : u32 = countTrailingZeros(v);
}
)";
@@ -564,7 +674,8 @@
}
fn f() {
- let r : u32 = tint_count_trailing_zeros(15u);
+ let v = 15u;
+ let r : u32 = tint_count_trailing_zeros(v);
}
)";
@@ -576,7 +687,8 @@
TEST_F(BuiltinPolyfillTest, CountTrailingZeros_vec3_i32) {
auto* src = R"(
fn f() {
- let r : vec3<i32> = countTrailingZeros(vec3<i32>(15));
+ let v = 15i;
+ let r : vec3<i32> = countTrailingZeros(vec3<i32>(v));
}
)";
@@ -597,7 +709,8 @@
}
fn f() {
- let r : vec3<i32> = tint_count_trailing_zeros(vec3<i32>(15));
+ let v = 15i;
+ let r : vec3<i32> = tint_count_trailing_zeros(vec3<i32>(v));
}
)";
@@ -609,7 +722,8 @@
TEST_F(BuiltinPolyfillTest, CountTrailingZeros_vec3_u32) {
auto* src = R"(
fn f() {
- let r : vec3<u32> = countTrailingZeros(vec3<u32>(15u));
+ let v = 15u;
+ let r : vec3<u32> = countTrailingZeros(vec3<u32>(v));
}
)";
@@ -630,7 +744,8 @@
}
fn f() {
- let r : vec3<u32> = tint_count_trailing_zeros(vec3<u32>(15u));
+ let v = 15u;
+ let r : vec3<u32> = tint_count_trailing_zeros(vec3<u32>(v));
}
)";
@@ -653,7 +768,8 @@
TEST_F(BuiltinPolyfillTest, ShouldRunExtractBits) {
auto* src = R"(
fn f() {
- extractBits(1234, 5u, 6u);
+ let v = 1234i;
+ extractBits(v, 5u, 6u);
}
)";
@@ -663,10 +779,25 @@
EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillExtractBits(Level::kFull)));
}
+TEST_F(BuiltinPolyfillTest, ExtractBits_ConstantExpression) {
+ auto* src = R"(
+fn f() {
+ let r : i32 = countTrailingZeros(15i);
+}
+)";
+
+ auto* expect = src;
+
+ auto got = Run<BuiltinPolyfill>(src, polyfillExtractBits(Level::kFull));
+
+ EXPECT_EQ(expect, str(got));
+}
+
TEST_F(BuiltinPolyfillTest, ExtractBits_Full_i32) {
auto* src = R"(
fn f() {
- let r : i32 = extractBits(1234, 5u, 6u);
+ let v = 1234i;
+ let r : i32 = extractBits(v, 5u, 6u);
}
)";
@@ -680,7 +811,8 @@
}
fn f() {
- let r : i32 = tint_extract_bits(1234, 5u, 6u);
+ let v = 1234i;
+ let r : i32 = tint_extract_bits(v, 5u, 6u);
}
)";
@@ -692,7 +824,8 @@
TEST_F(BuiltinPolyfillTest, ExtractBits_Full_u32) {
auto* src = R"(
fn f() {
- let r : u32 = extractBits(1234u, 5u, 6u);
+ let v = 1234u;
+ let r : u32 = extractBits(v, 5u, 6u);
}
)";
@@ -706,7 +839,8 @@
}
fn f() {
- let r : u32 = tint_extract_bits(1234u, 5u, 6u);
+ let v = 1234u;
+ let r : u32 = tint_extract_bits(v, 5u, 6u);
}
)";
@@ -718,7 +852,8 @@
TEST_F(BuiltinPolyfillTest, ExtractBits_Full_vec3_i32) {
auto* src = R"(
fn f() {
- let r : vec3<i32> = extractBits(vec3<i32>(1234), 5u, 6u);
+ let v = 1234i;
+ let r : vec3<i32> = extractBits(vec3<i32>(v), 5u, 6u);
}
)";
@@ -732,7 +867,8 @@
}
fn f() {
- let r : vec3<i32> = tint_extract_bits(vec3<i32>(1234), 5u, 6u);
+ let v = 1234i;
+ let r : vec3<i32> = tint_extract_bits(vec3<i32>(v), 5u, 6u);
}
)";
@@ -744,7 +880,8 @@
TEST_F(BuiltinPolyfillTest, ExtractBits_Full_vec3_u32) {
auto* src = R"(
fn f() {
- let r : vec3<u32> = extractBits(vec3<u32>(1234u), 5u, 6u);
+ let v = 1234u;
+ let r : vec3<u32> = extractBits(vec3<u32>(v), 5u, 6u);
}
)";
@@ -758,7 +895,8 @@
}
fn f() {
- let r : vec3<u32> = tint_extract_bits(vec3<u32>(1234u), 5u, 6u);
+ let v = 1234u;
+ let r : vec3<u32> = tint_extract_bits(vec3<u32>(v), 5u, 6u);
}
)";
@@ -770,7 +908,8 @@
TEST_F(BuiltinPolyfillTest, ExtractBits_Clamp_i32) {
auto* src = R"(
fn f() {
- let r : i32 = extractBits(1234, 5u, 6u);
+ let v = 1234i;
+ let r : i32 = extractBits(v, 5u, 6u);
}
)";
@@ -782,7 +921,8 @@
}
fn f() {
- let r : i32 = tint_extract_bits(1234, 5u, 6u);
+ let v = 1234i;
+ let r : i32 = tint_extract_bits(v, 5u, 6u);
}
)";
@@ -794,7 +934,8 @@
TEST_F(BuiltinPolyfillTest, ExtractBits_Clamp_u32) {
auto* src = R"(
fn f() {
- let r : u32 = extractBits(1234u, 5u, 6u);
+ let v = 1234u;
+ let r : u32 = extractBits(v, 5u, 6u);
}
)";
@@ -806,7 +947,8 @@
}
fn f() {
- let r : u32 = tint_extract_bits(1234u, 5u, 6u);
+ let v = 1234u;
+ let r : u32 = tint_extract_bits(v, 5u, 6u);
}
)";
@@ -818,7 +960,8 @@
TEST_F(BuiltinPolyfillTest, ExtractBits_Clamp_vec3_i32) {
auto* src = R"(
fn f() {
- let r : vec3<i32> = extractBits(vec3<i32>(1234), 5u, 6u);
+ let v = 1234i;
+ let r : vec3<i32> = extractBits(vec3<i32>(v), 5u, 6u);
}
)";
@@ -830,7 +973,8 @@
}
fn f() {
- let r : vec3<i32> = tint_extract_bits(vec3<i32>(1234), 5u, 6u);
+ let v = 1234i;
+ let r : vec3<i32> = tint_extract_bits(vec3<i32>(v), 5u, 6u);
}
)";
@@ -842,7 +986,8 @@
TEST_F(BuiltinPolyfillTest, ExtractBits_Clamp_vec3_u32) {
auto* src = R"(
fn f() {
- let r : vec3<u32> = extractBits(vec3<u32>(1234u), 5u, 6u);
+ let v = 1234u;
+ let r : vec3<u32> = extractBits(vec3<u32>(v), 5u, 6u);
}
)";
@@ -854,7 +999,8 @@
}
fn f() {
- let r : vec3<u32> = tint_extract_bits(vec3<u32>(1234u), 5u, 6u);
+ let v = 1234u;
+ let r : vec3<u32> = tint_extract_bits(vec3<u32>(v), 5u, 6u);
}
)";
@@ -877,7 +1023,8 @@
TEST_F(BuiltinPolyfillTest, ShouldRunFirstLeadingBit) {
auto* src = R"(
fn f() {
- firstLeadingBit(0xf);
+ let v = 15i;
+ firstLeadingBit(v);
}
)";
@@ -885,10 +1032,26 @@
EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillFirstLeadingBit()));
}
+// TODO(crbug.com/tint/1581): Enable once `firstLeadingBit` is implemented as @const
+TEST_F(BuiltinPolyfillTest, DISABLED_FirstLeadingBit_ConstantExpression) {
+ auto* src = R"(
+fn f() {
+ let r : i32 = firstLeadingBit(15i);
+}
+)";
+
+ auto* expect = src;
+
+ auto got = Run<BuiltinPolyfill>(src, polyfillFirstLeadingBit());
+
+ EXPECT_EQ(expect, str(got));
+}
+
TEST_F(BuiltinPolyfillTest, FirstLeadingBit_i32) {
auto* src = R"(
fn f() {
- let r : i32 = firstLeadingBit(15);
+ let v = 15i;
+ let r : i32 = firstLeadingBit(v);
}
)";
@@ -909,7 +1072,8 @@
}
fn f() {
- let r : i32 = tint_first_leading_bit(15);
+ let v = 15i;
+ let r : i32 = tint_first_leading_bit(v);
}
)";
@@ -921,7 +1085,8 @@
TEST_F(BuiltinPolyfillTest, FirstLeadingBit_u32) {
auto* src = R"(
fn f() {
- let r : u32 = firstLeadingBit(15u);
+ let v = 15u;
+ let r : u32 = firstLeadingBit(v);
}
)";
@@ -942,7 +1107,8 @@
}
fn f() {
- let r : u32 = tint_first_leading_bit(15u);
+ let v = 15u;
+ let r : u32 = tint_first_leading_bit(v);
}
)";
@@ -954,7 +1120,8 @@
TEST_F(BuiltinPolyfillTest, FirstLeadingBit_vec3_i32) {
auto* src = R"(
fn f() {
- let r : vec3<i32> = firstLeadingBit(vec3<i32>(15));
+ let v = 15i;
+ let r : vec3<i32> = firstLeadingBit(vec3<i32>(v));
}
)";
@@ -975,7 +1142,8 @@
}
fn f() {
- let r : vec3<i32> = tint_first_leading_bit(vec3<i32>(15));
+ let v = 15i;
+ let r : vec3<i32> = tint_first_leading_bit(vec3<i32>(v));
}
)";
@@ -987,7 +1155,8 @@
TEST_F(BuiltinPolyfillTest, FirstLeadingBit_vec3_u32) {
auto* src = R"(
fn f() {
- let r : vec3<u32> = firstLeadingBit(vec3<u32>(15u));
+ let v = 15u;
+ let r : vec3<u32> = firstLeadingBit(vec3<u32>(v));
}
)";
@@ -1008,7 +1177,8 @@
}
fn f() {
- let r : vec3<u32> = tint_first_leading_bit(vec3<u32>(15u));
+ let v = 15u;
+ let r : vec3<u32> = tint_first_leading_bit(vec3<u32>(v));
}
)";
@@ -1031,7 +1201,8 @@
TEST_F(BuiltinPolyfillTest, ShouldRunFirstTrailingBit) {
auto* src = R"(
fn f() {
- firstTrailingBit(0xf);
+ let v = 15i;
+ firstTrailingBit(v);
}
)";
@@ -1039,10 +1210,26 @@
EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillFirstTrailingBit()));
}
+// TODO(crbug.com/tint/1581): Enable once `firstTrailingBit` is implemented as @const
+TEST_F(BuiltinPolyfillTest, DISABLED_FirstTrailingBit_ConstantExpression) {
+ auto* src = R"(
+fn f() {
+ let r : i32 = firstTrailingBit(15i);
+}
+)";
+
+ auto* expect = src;
+
+ auto got = Run<BuiltinPolyfill>(src, polyfillFirstTrailingBit());
+
+ EXPECT_EQ(expect, str(got));
+}
+
TEST_F(BuiltinPolyfillTest, FirstTrailingBit_i32) {
auto* src = R"(
fn f() {
- let r : i32 = firstTrailingBit(15);
+ let v = 15i;
+ let r : i32 = firstTrailingBit(v);
}
)";
@@ -1063,7 +1250,8 @@
}
fn f() {
- let r : i32 = tint_first_trailing_bit(15);
+ let v = 15i;
+ let r : i32 = tint_first_trailing_bit(v);
}
)";
@@ -1075,7 +1263,8 @@
TEST_F(BuiltinPolyfillTest, FirstTrailingBit_u32) {
auto* src = R"(
fn f() {
- let r : u32 = firstTrailingBit(15u);
+ let v = 15u;
+ let r : u32 = firstTrailingBit(v);
}
)";
@@ -1096,7 +1285,8 @@
}
fn f() {
- let r : u32 = tint_first_trailing_bit(15u);
+ let v = 15u;
+ let r : u32 = tint_first_trailing_bit(v);
}
)";
@@ -1108,7 +1298,8 @@
TEST_F(BuiltinPolyfillTest, FirstTrailingBit_vec3_i32) {
auto* src = R"(
fn f() {
- let r : vec3<i32> = firstTrailingBit(vec3<i32>(15));
+ let v = 15i;
+ let r : vec3<i32> = firstTrailingBit(vec3<i32>(v));
}
)";
@@ -1129,7 +1320,8 @@
}
fn f() {
- let r : vec3<i32> = tint_first_trailing_bit(vec3<i32>(15));
+ let v = 15i;
+ let r : vec3<i32> = tint_first_trailing_bit(vec3<i32>(v));
}
)";
@@ -1141,7 +1333,8 @@
TEST_F(BuiltinPolyfillTest, FirstTrailingBit_vec3_u32) {
auto* src = R"(
fn f() {
- let r : vec3<u32> = firstTrailingBit(vec3<u32>(15u));
+ let v = 15u;
+ let r : vec3<u32> = firstTrailingBit(vec3<u32>(v));
}
)";
@@ -1162,7 +1355,8 @@
}
fn f() {
- let r : vec3<u32> = tint_first_trailing_bit(vec3<u32>(15u));
+ let v = 15u;
+ let r : vec3<u32> = tint_first_trailing_bit(vec3<u32>(v));
}
)";
@@ -1185,7 +1379,8 @@
TEST_F(BuiltinPolyfillTest, ShouldRunInsertBits) {
auto* src = R"(
fn f() {
- insertBits(1234, 5678, 5u, 6u);
+ let v = 1234i;
+ insertBits(v, 5678, 5u, 6u);
}
)";
@@ -1195,13 +1390,29 @@
EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillInsertBits(Level::kFull)));
}
-TEST_F(BuiltinPolyfillTest, InsertBits_Full_i32) {
+// TODO(crbug.com/tint/1581): Enable once `insertBits` is implemented as @const
+TEST_F(BuiltinPolyfillTest, DISABLED_InsertBits_ConstantExpression) {
auto* src = R"(
fn f() {
let r : i32 = insertBits(1234, 5678, 5u, 6u);
}
)";
+ auto* expect = src;
+
+ auto got = Run<BuiltinPolyfill>(src, polyfillInsertBits(Level::kFull));
+
+ EXPECT_EQ(expect, str(got));
+}
+
+TEST_F(BuiltinPolyfillTest, InsertBits_Full_i32) {
+ auto* src = R"(
+fn f() {
+ let v = 1234i;
+ let r : i32 = insertBits(v, 5678, 5u, 6u);
+}
+)";
+
auto* expect = R"(
fn tint_insert_bits(v : i32, n : i32, offset : u32, count : u32) -> i32 {
let s = min(offset, 32u);
@@ -1211,7 +1422,8 @@
}
fn f() {
- let r : i32 = tint_insert_bits(1234, 5678, 5u, 6u);
+ let v = 1234i;
+ let r : i32 = tint_insert_bits(v, 5678, 5u, 6u);
}
)";
@@ -1223,7 +1435,8 @@
TEST_F(BuiltinPolyfillTest, InsertBits_Full_u32) {
auto* src = R"(
fn f() {
- let r : u32 = insertBits(1234u, 5678u, 5u, 6u);
+ let v = 1234u;
+ let r : u32 = insertBits(v, 5678u, 5u, 6u);
}
)";
@@ -1236,7 +1449,8 @@
}
fn f() {
- let r : u32 = tint_insert_bits(1234u, 5678u, 5u, 6u);
+ let v = 1234u;
+ let r : u32 = tint_insert_bits(v, 5678u, 5u, 6u);
}
)";
@@ -1248,7 +1462,8 @@
TEST_F(BuiltinPolyfillTest, InsertBits_Full_vec3_i32) {
auto* src = R"(
fn f() {
- let r : vec3<i32> = insertBits(vec3<i32>(1234), vec3<i32>(5678), 5u, 6u);
+ let v = 1234i;
+ let r : vec3<i32> = insertBits(vec3<i32>(v), vec3<i32>(5678), 5u, 6u);
}
)";
@@ -1261,7 +1476,8 @@
}
fn f() {
- let r : vec3<i32> = tint_insert_bits(vec3<i32>(1234), vec3<i32>(5678), 5u, 6u);
+ let v = 1234i;
+ let r : vec3<i32> = tint_insert_bits(vec3<i32>(v), vec3<i32>(5678), 5u, 6u);
}
)";
@@ -1273,7 +1489,8 @@
TEST_F(BuiltinPolyfillTest, InsertBits_Full_vec3_u32) {
auto* src = R"(
fn f() {
- let r : vec3<u32> = insertBits(vec3<u32>(1234u), vec3<u32>(5678u), 5u, 6u);
+ let v = 1234u;
+ let r : vec3<u32> = insertBits(vec3<u32>(v), vec3<u32>(5678u), 5u, 6u);
}
)";
@@ -1286,7 +1503,8 @@
}
fn f() {
- let r : vec3<u32> = tint_insert_bits(vec3<u32>(1234u), vec3<u32>(5678u), 5u, 6u);
+ let v = 1234u;
+ let r : vec3<u32> = tint_insert_bits(vec3<u32>(v), vec3<u32>(5678u), 5u, 6u);
}
)";
@@ -1298,7 +1516,8 @@
TEST_F(BuiltinPolyfillTest, InsertBits_Clamp_i32) {
auto* src = R"(
fn f() {
- let r : i32 = insertBits(1234, 5678, 5u, 6u);
+ let v = 1234i;
+ let r : i32 = insertBits(v, 5678, 5u, 6u);
}
)";
@@ -1310,7 +1529,8 @@
}
fn f() {
- let r : i32 = tint_insert_bits(1234, 5678, 5u, 6u);
+ let v = 1234i;
+ let r : i32 = tint_insert_bits(v, 5678, 5u, 6u);
}
)";
@@ -1322,7 +1542,8 @@
TEST_F(BuiltinPolyfillTest, InsertBits_Clamp_u32) {
auto* src = R"(
fn f() {
- let r : u32 = insertBits(1234u, 5678u, 5u, 6u);
+ let v = 1234u;
+ let r : u32 = insertBits(v, 5678u, 5u, 6u);
}
)";
@@ -1334,7 +1555,8 @@
}
fn f() {
- let r : u32 = tint_insert_bits(1234u, 5678u, 5u, 6u);
+ let v = 1234u;
+ let r : u32 = tint_insert_bits(v, 5678u, 5u, 6u);
}
)";
@@ -1346,7 +1568,8 @@
TEST_F(BuiltinPolyfillTest, InsertBits_Clamp_vec3_i32) {
auto* src = R"(
fn f() {
- let r : vec3<i32> = insertBits(vec3<i32>(1234), vec3<i32>(5678), 5u, 6u);
+ let v = 1234i;
+ let r : vec3<i32> = insertBits(vec3<i32>(v), vec3<i32>(5678), 5u, 6u);
}
)";
@@ -1358,7 +1581,8 @@
}
fn f() {
- let r : vec3<i32> = tint_insert_bits(vec3<i32>(1234), vec3<i32>(5678), 5u, 6u);
+ let v = 1234i;
+ let r : vec3<i32> = tint_insert_bits(vec3<i32>(v), vec3<i32>(5678), 5u, 6u);
}
)";
@@ -1370,7 +1594,8 @@
TEST_F(BuiltinPolyfillTest, InsertBits_Clamp_vec3_u32) {
auto* src = R"(
fn f() {
- let r : vec3<u32> = insertBits(vec3<u32>(1234u), vec3<u32>(5678u), 5u, 6u);
+ let v = 1234u;
+ let r : vec3<u32> = insertBits(vec3<u32>(v), vec3<u32>(5678u), 5u, 6u);
}
)";
@@ -1382,7 +1607,8 @@
}
fn f() {
- let r : vec3<u32> = tint_insert_bits(vec3<u32>(1234u), vec3<u32>(5678u), 5u, 6u);
+ let v = 1234u;
+ let r : vec3<u32> = tint_insert_bits(vec3<u32>(v), vec3<u32>(5678u), 5u, 6u);
}
)";
@@ -1405,7 +1631,8 @@
TEST_F(BuiltinPolyfillTest, ShouldRunSaturate) {
auto* src = R"(
fn f() {
- saturate(0.5);
+ let v = 0.5f;
+ saturate(v);
}
)";
@@ -1413,10 +1640,25 @@
EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillSaturate()));
}
+TEST_F(BuiltinPolyfillTest, Saturate_ConstantExpression) {
+ auto* src = R"(
+fn f() {
+ let r : f32 = saturate(0.5);
+}
+)";
+
+ auto* expect = src;
+
+ auto got = Run<BuiltinPolyfill>(src, polyfillSaturate());
+
+ EXPECT_EQ(expect, str(got));
+}
+
TEST_F(BuiltinPolyfillTest, Saturate_f32) {
auto* src = R"(
fn f() {
- let r : f32 = saturate(0.5f);
+ let v = 0.5f;
+ let r : f32 = saturate(v);
}
)";
@@ -1426,7 +1668,8 @@
}
fn f() {
- let r : f32 = tint_saturate(0.5f);
+ let v = 0.5f;
+ let r : f32 = tint_saturate(v);
}
)";
@@ -1440,7 +1683,8 @@
enable f16;
fn f() {
- let r : f16 = saturate(0.5h);
+ let v = 0.5h;
+ let r : f16 = saturate(v);
}
)";
@@ -1452,7 +1696,8 @@
}
fn f() {
- let r : f16 = tint_saturate(0.5h);
+ let v = 0.5h;
+ let r : f16 = tint_saturate(v);
}
)";
@@ -1464,7 +1709,8 @@
TEST_F(BuiltinPolyfillTest, Saturate_vec3_f32) {
auto* src = R"(
fn f() {
- let r : vec3<f32> = saturate(vec3<f32>(0.5f));
+ let v = 0.5f;
+ let r : vec3<f32> = saturate(vec3<f32>(v));
}
)";
@@ -1474,7 +1720,8 @@
}
fn f() {
- let r : vec3<f32> = tint_saturate(vec3<f32>(0.5f));
+ let v = 0.5f;
+ let r : vec3<f32> = tint_saturate(vec3<f32>(v));
}
)";
@@ -1488,7 +1735,8 @@
enable f16;
fn f() {
- let r : vec3<f16> = saturate(vec3<f16>(0.5h));
+ let v = 0.5h;
+ let r : vec3<f16> = saturate(vec3<f16>(v));
}
)";
@@ -1500,7 +1748,8 @@
}
fn f() {
- let r : vec3<f16> = tint_saturate(vec3<f16>(0.5h));
+ let v = 0.5h;
+ let r : vec3<f16> = tint_saturate(vec3<f16>(v));
}
)";
diff --git a/test/tint/builtins/gen/literal/asinh/157447.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/asinh/157447.wgsl.expected.dxc.hlsl
index 5979747..ea3d30b 100644
--- a/test/tint/builtins/gen/literal/asinh/157447.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/asinh/157447.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-float tint_sinh(float x) {
- return log((x + sqrt(((x * x) + 1.0f))));
-}
-
void asinh_157447() {
- float res = tint_sinh(1.0f);
+ float res = 0.881373584f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/asinh/157447.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/asinh/157447.wgsl.expected.fxc.hlsl
index 5979747..ea3d30b 100644
--- a/test/tint/builtins/gen/literal/asinh/157447.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/asinh/157447.wgsl.expected.fxc.hlsl
@@ -1,9 +1,5 @@
-float tint_sinh(float x) {
- return log((x + sqrt(((x * x) + 1.0f))));
-}
-
void asinh_157447() {
- float res = tint_sinh(1.0f);
+ float res = 0.881373584f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/asinh/2265ee.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/asinh/2265ee.wgsl.expected.dxc.hlsl
index e5eaaee..42281c9 100644
--- a/test/tint/builtins/gen/literal/asinh/2265ee.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/asinh/2265ee.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-float3 tint_sinh(float3 x) {
- return log((x + sqrt(((x * x) + 1.0f))));
-}
-
void asinh_2265ee() {
- float3 res = tint_sinh((1.0f).xxx);
+ float3 res = (0.881373584f).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/asinh/2265ee.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/asinh/2265ee.wgsl.expected.fxc.hlsl
index e5eaaee..42281c9 100644
--- a/test/tint/builtins/gen/literal/asinh/2265ee.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/asinh/2265ee.wgsl.expected.fxc.hlsl
@@ -1,9 +1,5 @@
-float3 tint_sinh(float3 x) {
- return log((x + sqrt(((x * x) + 1.0f))));
-}
-
void asinh_2265ee() {
- float3 res = tint_sinh((1.0f).xxx);
+ float3 res = (0.881373584f).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/asinh/468a48.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/asinh/468a48.wgsl.expected.dxc.hlsl
index 7080041..895988b 100644
--- a/test/tint/builtins/gen/literal/asinh/468a48.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/asinh/468a48.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-float16_t tint_sinh(float16_t x) {
- return log((x + sqrt(((x * x) + float16_t(1.0h)))));
-}
-
void asinh_468a48() {
- float16_t res = tint_sinh(float16_t(0.0h));
+ float16_t res = float16_t(0.0h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/asinh/4a2226.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/asinh/4a2226.wgsl.expected.dxc.hlsl
index 09e6588..bd77bf3 100644
--- a/test/tint/builtins/gen/literal/asinh/4a2226.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/asinh/4a2226.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-float2 tint_sinh(float2 x) {
- return log((x + sqrt(((x * x) + 1.0f))));
-}
-
void asinh_4a2226() {
- float2 res = tint_sinh((1.0f).xx);
+ float2 res = (0.881373584f).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/asinh/4a2226.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/asinh/4a2226.wgsl.expected.fxc.hlsl
index 09e6588..bd77bf3 100644
--- a/test/tint/builtins/gen/literal/asinh/4a2226.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/asinh/4a2226.wgsl.expected.fxc.hlsl
@@ -1,9 +1,5 @@
-float2 tint_sinh(float2 x) {
- return log((x + sqrt(((x * x) + 1.0f))));
-}
-
void asinh_4a2226() {
- float2 res = tint_sinh((1.0f).xx);
+ float2 res = (0.881373584f).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/asinh/8d2e51.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/asinh/8d2e51.wgsl.expected.dxc.hlsl
index b7a3794..38dbc99 100644
--- a/test/tint/builtins/gen/literal/asinh/8d2e51.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/asinh/8d2e51.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-float4 tint_sinh(float4 x) {
- return log((x + sqrt(((x * x) + 1.0f))));
-}
-
void asinh_8d2e51() {
- float4 res = tint_sinh((1.0f).xxxx);
+ float4 res = (0.881373584f).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/asinh/8d2e51.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/asinh/8d2e51.wgsl.expected.fxc.hlsl
index b7a3794..38dbc99 100644
--- a/test/tint/builtins/gen/literal/asinh/8d2e51.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/asinh/8d2e51.wgsl.expected.fxc.hlsl
@@ -1,9 +1,5 @@
-float4 tint_sinh(float4 x) {
- return log((x + sqrt(((x * x) + 1.0f))));
-}
-
void asinh_8d2e51() {
- float4 res = tint_sinh((1.0f).xxxx);
+ float4 res = (0.881373584f).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/asinh/95ab2b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/asinh/95ab2b.wgsl.expected.dxc.hlsl
index 05818ab..a429606 100644
--- a/test/tint/builtins/gen/literal/asinh/95ab2b.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/asinh/95ab2b.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-vector<float16_t, 4> tint_sinh(vector<float16_t, 4> x) {
- return log((x + sqrt(((x * x) + float16_t(1.0h)))));
-}
-
void asinh_95ab2b() {
- vector<float16_t, 4> res = tint_sinh((float16_t(0.0h)).xxxx);
+ vector<float16_t, 4> res = (float16_t(0.0h)).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/asinh/ad8f8b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/asinh/ad8f8b.wgsl.expected.dxc.hlsl
index 3a87d2d..fa23693 100644
--- a/test/tint/builtins/gen/literal/asinh/ad8f8b.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/asinh/ad8f8b.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-vector<float16_t, 2> tint_sinh(vector<float16_t, 2> x) {
- return log((x + sqrt(((x * x) + float16_t(1.0h)))));
-}
-
void asinh_ad8f8b() {
- vector<float16_t, 2> res = tint_sinh((float16_t(0.0h)).xx);
+ vector<float16_t, 2> res = (float16_t(0.0h)).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/asinh/fb5e8c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/asinh/fb5e8c.wgsl.expected.dxc.hlsl
index 920c90e..30cea25 100644
--- a/test/tint/builtins/gen/literal/asinh/fb5e8c.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/asinh/fb5e8c.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-vector<float16_t, 3> tint_sinh(vector<float16_t, 3> x) {
- return log((x + sqrt(((x * x) + float16_t(1.0h)))));
-}
-
void asinh_fb5e8c() {
- vector<float16_t, 3> res = tint_sinh((float16_t(0.0h)).xxx);
+ vector<float16_t, 3> res = (float16_t(0.0h)).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.dxc.hlsl
index 9359293..2aacc1c 100644
--- a/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-float3 tint_atanh(float3 x) {
- return (log(((1.0f + x) / (1.0f - x))) * 0.5f);
-}
-
void atanh_440cca() {
- float3 res = tint_atanh((0.5f).xxx);
+ float3 res = (0.549306154f).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.fxc.hlsl
index 9359293..2aacc1c 100644
--- a/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.fxc.hlsl
@@ -1,9 +1,5 @@
-float3 tint_atanh(float3 x) {
- return (log(((1.0f + x) / (1.0f - x))) * 0.5f);
-}
-
void atanh_440cca() {
- float3 res = tint_atanh((0.5f).xxx);
+ float3 res = (0.549306154f).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.glsl b/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.glsl
index ec207ee..babebf4 100644
--- a/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.glsl
@@ -1,11 +1,7 @@
#version 310 es
-vec3 tint_atanh(vec3 x) {
- return mix(atanh(x), vec3(0.0f), greaterThanEqual(x, vec3(1.0f)));
-}
-
void atanh_440cca() {
- vec3 res = tint_atanh(vec3(0.5f));
+ vec3 res = vec3(0.549306154f);
}
vec4 vertex_main() {
@@ -24,12 +20,8 @@
#version 310 es
precision mediump float;
-vec3 tint_atanh(vec3 x) {
- return mix(atanh(x), vec3(0.0f), greaterThanEqual(x, vec3(1.0f)));
-}
-
void atanh_440cca() {
- vec3 res = tint_atanh(vec3(0.5f));
+ vec3 res = vec3(0.549306154f);
}
void fragment_main() {
@@ -42,12 +34,8 @@
}
#version 310 es
-vec3 tint_atanh(vec3 x) {
- return mix(atanh(x), vec3(0.0f), greaterThanEqual(x, vec3(1.0f)));
-}
-
void atanh_440cca() {
- vec3 res = tint_atanh(vec3(0.5f));
+ vec3 res = vec3(0.549306154f);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.msl b/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.msl
index 929e177..203e734 100644
--- a/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.msl
@@ -1,12 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-float3 tint_atanh(float3 x) {
- return select(atanh(x), float3(0.0f), (x >= float3(1.0f)));
-}
-
void atanh_440cca() {
- float3 res = tint_atanh(float3(0.5f));
+ float3 res = float3(0.549306154f);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.spvasm
index a0b1acc..540ebee 100644
--- a/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/atanh/440cca.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 45
+; Bound: 33
; Schema: 0
OpCapability Shader
- %22 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,8 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_atanh "tint_atanh"
- OpName %x "x"
OpName %atanh_440cca "atanh_440cca"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,53 +28,40 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
- %v3float = OpTypeVector %float 3
- %9 = OpTypeFunction %v3float %v3float
- %float_1 = OpConstant %float 1
- %16 = OpConstantComposite %v3float %float_1 %float_1 %float_1
- %bool = OpTypeBool
- %v3bool = OpTypeVector %bool 3
- %20 = OpConstantNull %v3float
%void = OpTypeVoid
- %23 = OpTypeFunction %void
- %float_0_5 = OpConstant %float 0.5
- %29 = OpConstantComposite %v3float %float_0_5 %float_0_5 %float_0_5
+ %9 = OpTypeFunction %void
+ %v3float = OpTypeVector %float 3
+%float_0_549306154 = OpConstant %float 0.549306154
+ %15 = OpConstantComposite %v3float %float_0_549306154 %float_0_549306154 %float_0_549306154
%_ptr_Function_v3float = OpTypePointer Function %v3float
- %32 = OpTypeFunction %v4float
- %tint_atanh = OpFunction %v3float None %9
- %x = OpFunctionParameter %v3float
- %13 = OpLabel
- %17 = OpFOrdGreaterThanEqual %v3bool %x %16
- %21 = OpExtInst %v3float %22 Atanh %x
- %14 = OpSelect %v3float %17 %20 %21
- OpReturnValue %14
- OpFunctionEnd
-%atanh_440cca = OpFunction %void None %23
- %26 = OpLabel
- %res = OpVariable %_ptr_Function_v3float Function %20
- %27 = OpFunctionCall %v3float %tint_atanh %29
- OpStore %res %27
+ %18 = OpConstantNull %v3float
+ %19 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%atanh_440cca = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v3float Function %18
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %32
- %34 = OpLabel
- %35 = OpFunctionCall %void %atanh_440cca
+%vertex_main_inner = OpFunction %v4float None %19
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %atanh_440cca
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %23
- %37 = OpLabel
- %38 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %38
+%vertex_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %25
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %23
- %40 = OpLabel
- %41 = OpFunctionCall %void %atanh_440cca
+%fragment_main = OpFunction %void None %9
+ %28 = OpLabel
+ %29 = OpFunctionCall %void %atanh_440cca
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %23
- %43 = OpLabel
- %44 = OpFunctionCall %void %atanh_440cca
+%compute_main = OpFunction %void None %9
+ %31 = OpLabel
+ %32 = OpFunctionCall %void %atanh_440cca
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.dxc.hlsl
index 38fb4b6..1ab4777 100644
--- a/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-vector<float16_t, 2> tint_atanh(vector<float16_t, 2> x) {
- return (log(((float16_t(1.0h) + x) / (float16_t(1.0h) - x))) * float16_t(0.5h));
-}
-
void atanh_5bf88d() {
- vector<float16_t, 2> res = tint_atanh((float16_t(0.0h)).xx);
+ vector<float16_t, 2> res = (float16_t(0.0h)).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.glsl b/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.glsl
index 76ddf57..17a23e6 100644
--- a/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.glsl
@@ -1,12 +1,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-f16vec2 tint_atanh(f16vec2 x) {
- return mix(atanh(x), f16vec2(0.0hf), greaterThanEqual(x, f16vec2(1.0hf)));
-}
-
void atanh_5bf88d() {
- f16vec2 res = tint_atanh(f16vec2(0.0hf));
+ f16vec2 res = f16vec2(0.0hf);
}
vec4 vertex_main() {
@@ -26,12 +22,8 @@
#extension GL_AMD_gpu_shader_half_float : require
precision mediump float;
-f16vec2 tint_atanh(f16vec2 x) {
- return mix(atanh(x), f16vec2(0.0hf), greaterThanEqual(x, f16vec2(1.0hf)));
-}
-
void atanh_5bf88d() {
- f16vec2 res = tint_atanh(f16vec2(0.0hf));
+ f16vec2 res = f16vec2(0.0hf);
}
void fragment_main() {
@@ -45,12 +37,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-f16vec2 tint_atanh(f16vec2 x) {
- return mix(atanh(x), f16vec2(0.0hf), greaterThanEqual(x, f16vec2(1.0hf)));
-}
-
void atanh_5bf88d() {
- f16vec2 res = tint_atanh(f16vec2(0.0hf));
+ f16vec2 res = f16vec2(0.0hf);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.msl b/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.msl
index 3b4f0b3..eb31ae2 100644
--- a/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.msl
@@ -1,12 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-half2 tint_atanh(half2 x) {
- return select(atanh(x), half2(0.0h), (x >= half2(1.0h)));
-}
-
void atanh_5bf88d() {
- half2 res = tint_atanh(half2(0.0h));
+ half2 res = half2(0.0h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.spvasm
index d87c640..e89e54e 100644
--- a/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/atanh/5bf88d.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 45
+; Bound: 32
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %23 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -17,8 +16,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_atanh "tint_atanh"
- OpName %x "x"
OpName %atanh_5bf88d "atanh_5bf88d"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -35,53 +32,39 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
- %9 = OpTypeFunction %v2half %v2half
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %17 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0
- %bool = OpTypeBool
- %v2bool = OpTypeVector %bool 2
- %21 = OpConstantNull %v2half
- %void = OpTypeVoid
- %24 = OpTypeFunction %void
+ %15 = OpConstantNull %v2half
%_ptr_Function_v2half = OpTypePointer Function %v2half
- %31 = OpTypeFunction %v4float
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
- %tint_atanh = OpFunction %v2half None %9
- %x = OpFunctionParameter %v2half
- %14 = OpLabel
- %18 = OpFOrdGreaterThanEqual %v2bool %x %17
- %22 = OpExtInst %v2half %23 Atanh %x
- %15 = OpSelect %v2half %18 %21 %22
- OpReturnValue %15
- OpFunctionEnd
-%atanh_5bf88d = OpFunction %void None %24
- %27 = OpLabel
- %res = OpVariable %_ptr_Function_v2half Function %21
- %28 = OpFunctionCall %v2half %tint_atanh %21
- OpStore %res %28
+%atanh_5bf88d = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v2half Function %15
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %31
- %33 = OpLabel
- %34 = OpFunctionCall %void %atanh_5bf88d
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %atanh_5bf88d
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %24
- %36 = OpLabel
- %37 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %37
+%vertex_main = OpFunction %void None %9
+ %23 = OpLabel
+ %24 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %24
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %24
- %40 = OpLabel
- %41 = OpFunctionCall %void %atanh_5bf88d
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %atanh_5bf88d
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %24
- %43 = OpLabel
- %44 = OpFunctionCall %void %atanh_5bf88d
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %atanh_5bf88d
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.dxc.hlsl
index eb5bf96..1b3ce0a 100644
--- a/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-float tint_atanh(float x) {
- return (log(((1.0f + x) / (1.0f - x))) * 0.5f);
-}
-
void atanh_7997d8() {
- float res = tint_atanh(0.5f);
+ float res = 0.549306154f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.fxc.hlsl
index eb5bf96..1b3ce0a 100644
--- a/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.fxc.hlsl
@@ -1,9 +1,5 @@
-float tint_atanh(float x) {
- return (log(((1.0f + x) / (1.0f - x))) * 0.5f);
-}
-
void atanh_7997d8() {
- float res = tint_atanh(0.5f);
+ float res = 0.549306154f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.glsl b/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.glsl
index 6a74200..df17e4d 100644
--- a/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.glsl
@@ -1,11 +1,7 @@
#version 310 es
-float tint_atanh(float x) {
- return ((x >= 1.0f) ? 0.0f : atanh(x));
-}
-
void atanh_7997d8() {
- float res = tint_atanh(0.5f);
+ float res = 0.549306154f;
}
vec4 vertex_main() {
@@ -24,12 +20,8 @@
#version 310 es
precision mediump float;
-float tint_atanh(float x) {
- return ((x >= 1.0f) ? 0.0f : atanh(x));
-}
-
void atanh_7997d8() {
- float res = tint_atanh(0.5f);
+ float res = 0.549306154f;
}
void fragment_main() {
@@ -42,12 +34,8 @@
}
#version 310 es
-float tint_atanh(float x) {
- return ((x >= 1.0f) ? 0.0f : atanh(x));
-}
-
void atanh_7997d8() {
- float res = tint_atanh(0.5f);
+ float res = 0.549306154f;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.msl b/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.msl
index 147d54a..4e41260 100644
--- a/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.msl
@@ -1,12 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-float tint_atanh(float x) {
- return select(atanh(x), 0.0f, (x >= 1.0f));
-}
-
void atanh_7997d8() {
- float res = tint_atanh(0.5f);
+ float res = 0.549306154f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.spvasm
index 8274b37..7bde138 100644
--- a/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/atanh/7997d8.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 40
+; Bound: 30
; Schema: 0
OpCapability Shader
- %18 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,8 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_atanh "tint_atanh"
- OpName %x "x"
OpName %atanh_7997d8 "atanh_7997d8"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,48 +28,37 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
- %9 = OpTypeFunction %float %float
- %float_1 = OpConstant %float 1
- %bool = OpTypeBool
%void = OpTypeVoid
- %19 = OpTypeFunction %void
- %float_0_5 = OpConstant %float 0.5
+ %9 = OpTypeFunction %void
+%float_0_549306154 = OpConstant %float 0.549306154
%_ptr_Function_float = OpTypePointer Function %float
- %27 = OpTypeFunction %v4float
- %tint_atanh = OpFunction %float None %9
- %x = OpFunctionParameter %float
+ %16 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%atanh_7997d8 = OpFunction %void None %9
%12 = OpLabel
- %15 = OpFOrdGreaterThanEqual %bool %x %float_1
- %17 = OpExtInst %float %18 Atanh %x
- %13 = OpSelect %float %15 %8 %17
- OpReturnValue %13
- OpFunctionEnd
-%atanh_7997d8 = OpFunction %void None %19
- %22 = OpLabel
%res = OpVariable %_ptr_Function_float Function %8
- %23 = OpFunctionCall %float %tint_atanh %float_0_5
- OpStore %res %23
+ OpStore %res %float_0_549306154
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %27
- %29 = OpLabel
- %30 = OpFunctionCall %void %atanh_7997d8
+%vertex_main_inner = OpFunction %v4float None %16
+ %18 = OpLabel
+ %19 = OpFunctionCall %void %atanh_7997d8
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %19
- %32 = OpLabel
- %33 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %33
+%vertex_main = OpFunction %void None %9
+ %21 = OpLabel
+ %22 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %22
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %19
- %35 = OpLabel
- %36 = OpFunctionCall %void %atanh_7997d8
+%fragment_main = OpFunction %void None %9
+ %25 = OpLabel
+ %26 = OpFunctionCall %void %atanh_7997d8
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %19
- %38 = OpLabel
- %39 = OpFunctionCall %void %atanh_7997d8
+%compute_main = OpFunction %void None %9
+ %28 = OpLabel
+ %29 = OpFunctionCall %void %atanh_7997d8
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.dxc.hlsl
index 4342cb0..88aa1bd 100644
--- a/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-float2 tint_atanh(float2 x) {
- return (log(((1.0f + x) / (1.0f - x))) * 0.5f);
-}
-
void atanh_c0e634() {
- float2 res = tint_atanh((0.5f).xx);
+ float2 res = (0.549306154f).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.fxc.hlsl
index 4342cb0..88aa1bd 100644
--- a/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.fxc.hlsl
@@ -1,9 +1,5 @@
-float2 tint_atanh(float2 x) {
- return (log(((1.0f + x) / (1.0f - x))) * 0.5f);
-}
-
void atanh_c0e634() {
- float2 res = tint_atanh((0.5f).xx);
+ float2 res = (0.549306154f).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.glsl b/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.glsl
index 1e9ca1a..9b5babf 100644
--- a/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.glsl
@@ -1,11 +1,7 @@
#version 310 es
-vec2 tint_atanh(vec2 x) {
- return mix(atanh(x), vec2(0.0f), greaterThanEqual(x, vec2(1.0f)));
-}
-
void atanh_c0e634() {
- vec2 res = tint_atanh(vec2(0.5f));
+ vec2 res = vec2(0.549306154f);
}
vec4 vertex_main() {
@@ -24,12 +20,8 @@
#version 310 es
precision mediump float;
-vec2 tint_atanh(vec2 x) {
- return mix(atanh(x), vec2(0.0f), greaterThanEqual(x, vec2(1.0f)));
-}
-
void atanh_c0e634() {
- vec2 res = tint_atanh(vec2(0.5f));
+ vec2 res = vec2(0.549306154f);
}
void fragment_main() {
@@ -42,12 +34,8 @@
}
#version 310 es
-vec2 tint_atanh(vec2 x) {
- return mix(atanh(x), vec2(0.0f), greaterThanEqual(x, vec2(1.0f)));
-}
-
void atanh_c0e634() {
- vec2 res = tint_atanh(vec2(0.5f));
+ vec2 res = vec2(0.549306154f);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.msl b/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.msl
index bc96c02..631c14f 100644
--- a/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.msl
@@ -1,12 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-float2 tint_atanh(float2 x) {
- return select(atanh(x), float2(0.0f), (x >= float2(1.0f)));
-}
-
void atanh_c0e634() {
- float2 res = tint_atanh(float2(0.5f));
+ float2 res = float2(0.549306154f);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.spvasm
index 5fea132..28434f1 100644
--- a/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/atanh/c0e634.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 45
+; Bound: 33
; Schema: 0
OpCapability Shader
- %22 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,8 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_atanh "tint_atanh"
- OpName %x "x"
OpName %atanh_c0e634 "atanh_c0e634"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,53 +28,40 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
- %v2float = OpTypeVector %float 2
- %9 = OpTypeFunction %v2float %v2float
- %float_1 = OpConstant %float 1
- %16 = OpConstantComposite %v2float %float_1 %float_1
- %bool = OpTypeBool
- %v2bool = OpTypeVector %bool 2
- %20 = OpConstantNull %v2float
%void = OpTypeVoid
- %23 = OpTypeFunction %void
- %float_0_5 = OpConstant %float 0.5
- %29 = OpConstantComposite %v2float %float_0_5 %float_0_5
+ %9 = OpTypeFunction %void
+ %v2float = OpTypeVector %float 2
+%float_0_549306154 = OpConstant %float 0.549306154
+ %15 = OpConstantComposite %v2float %float_0_549306154 %float_0_549306154
%_ptr_Function_v2float = OpTypePointer Function %v2float
- %32 = OpTypeFunction %v4float
- %tint_atanh = OpFunction %v2float None %9
- %x = OpFunctionParameter %v2float
- %13 = OpLabel
- %17 = OpFOrdGreaterThanEqual %v2bool %x %16
- %21 = OpExtInst %v2float %22 Atanh %x
- %14 = OpSelect %v2float %17 %20 %21
- OpReturnValue %14
- OpFunctionEnd
-%atanh_c0e634 = OpFunction %void None %23
- %26 = OpLabel
- %res = OpVariable %_ptr_Function_v2float Function %20
- %27 = OpFunctionCall %v2float %tint_atanh %29
- OpStore %res %27
+ %18 = OpConstantNull %v2float
+ %19 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%atanh_c0e634 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v2float Function %18
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %32
- %34 = OpLabel
- %35 = OpFunctionCall %void %atanh_c0e634
+%vertex_main_inner = OpFunction %v4float None %19
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %atanh_c0e634
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %23
- %37 = OpLabel
- %38 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %38
+%vertex_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %25
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %23
- %40 = OpLabel
- %41 = OpFunctionCall %void %atanh_c0e634
+%fragment_main = OpFunction %void None %9
+ %28 = OpLabel
+ %29 = OpFunctionCall %void %atanh_c0e634
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %23
- %43 = OpLabel
- %44 = OpFunctionCall %void %atanh_c0e634
+%compute_main = OpFunction %void None %9
+ %31 = OpLabel
+ %32 = OpFunctionCall %void %atanh_c0e634
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.dxc.hlsl
index 1b3c054..d4b3294 100644
--- a/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-float16_t tint_atanh(float16_t x) {
- return (log(((float16_t(1.0h) + x) / (float16_t(1.0h) - x))) * float16_t(0.5h));
-}
-
void atanh_d2d8cd() {
- float16_t res = tint_atanh(float16_t(0.0h));
+ float16_t res = float16_t(0.0h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.glsl b/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.glsl
index 3077ea8..2164d93 100644
--- a/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.glsl
@@ -1,12 +1,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-float16_t tint_atanh(float16_t x) {
- return ((x >= 1.0hf) ? 0.0hf : atanh(x));
-}
-
void atanh_d2d8cd() {
- float16_t res = tint_atanh(0.0hf);
+ float16_t res = 0.0hf;
}
vec4 vertex_main() {
@@ -26,12 +22,8 @@
#extension GL_AMD_gpu_shader_half_float : require
precision mediump float;
-float16_t tint_atanh(float16_t x) {
- return ((x >= 1.0hf) ? 0.0hf : atanh(x));
-}
-
void atanh_d2d8cd() {
- float16_t res = tint_atanh(0.0hf);
+ float16_t res = 0.0hf;
}
void fragment_main() {
@@ -45,12 +37,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-float16_t tint_atanh(float16_t x) {
- return ((x >= 1.0hf) ? 0.0hf : atanh(x));
-}
-
void atanh_d2d8cd() {
- float16_t res = tint_atanh(0.0hf);
+ float16_t res = 0.0hf;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.msl b/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.msl
index 80f097f..8d4995a 100644
--- a/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.msl
@@ -1,12 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-half tint_atanh(half x) {
- return select(atanh(x), 0.0h, (x >= 1.0h));
-}
-
void atanh_d2d8cd() {
- half res = tint_atanh(0.0h);
+ half res = 0.0h;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.spvasm
index 82b8e8b..343a043 100644
--- a/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/atanh/d2d8cd.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 42
+; Bound: 31
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %20 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -17,8 +16,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_atanh "tint_atanh"
- OpName %x "x"
OpName %atanh_d2d8cd "atanh_d2d8cd"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -35,50 +32,38 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
- %half = OpTypeFloat 16
- %9 = OpTypeFunction %half %half
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %bool = OpTypeBool
- %18 = OpConstantNull %half
%void = OpTypeVoid
- %21 = OpTypeFunction %void
+ %9 = OpTypeFunction %void
+ %half = OpTypeFloat 16
+ %14 = OpConstantNull %half
%_ptr_Function_half = OpTypePointer Function %half
- %28 = OpTypeFunction %v4float
+ %17 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
- %tint_atanh = OpFunction %half None %9
- %x = OpFunctionParameter %half
- %13 = OpLabel
- %16 = OpFOrdGreaterThanEqual %bool %x %half_0x1p_0
- %19 = OpExtInst %half %20 Atanh %x
- %14 = OpSelect %half %16 %18 %19
- OpReturnValue %14
- OpFunctionEnd
-%atanh_d2d8cd = OpFunction %void None %21
- %24 = OpLabel
- %res = OpVariable %_ptr_Function_half Function %18
- %25 = OpFunctionCall %half %tint_atanh %18
- OpStore %res %25
+%atanh_d2d8cd = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_half Function %14
+ OpStore %res %14
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %28
- %30 = OpLabel
- %31 = OpFunctionCall %void %atanh_d2d8cd
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %atanh_d2d8cd
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %21
- %33 = OpLabel
- %34 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %34
+%vertex_main = OpFunction %void None %9
+ %22 = OpLabel
+ %23 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %23
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %21
- %37 = OpLabel
- %38 = OpFunctionCall %void %atanh_d2d8cd
+%fragment_main = OpFunction %void None %9
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %atanh_d2d8cd
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %21
- %40 = OpLabel
- %41 = OpFunctionCall %void %atanh_d2d8cd
+%compute_main = OpFunction %void None %9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %atanh_d2d8cd
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.dxc.hlsl
index ecec215..f3ac16c 100644
--- a/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-vector<float16_t, 4> tint_atanh(vector<float16_t, 4> x) {
- return (log(((float16_t(1.0h) + x) / (float16_t(1.0h) - x))) * float16_t(0.5h));
-}
-
void atanh_e3b450() {
- vector<float16_t, 4> res = tint_atanh((float16_t(0.0h)).xxxx);
+ vector<float16_t, 4> res = (float16_t(0.0h)).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.glsl b/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.glsl
index 32a26fc..73f8e70 100644
--- a/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.glsl
@@ -1,12 +1,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-f16vec4 tint_atanh(f16vec4 x) {
- return mix(atanh(x), f16vec4(0.0hf), greaterThanEqual(x, f16vec4(1.0hf)));
-}
-
void atanh_e3b450() {
- f16vec4 res = tint_atanh(f16vec4(0.0hf));
+ f16vec4 res = f16vec4(0.0hf);
}
vec4 vertex_main() {
@@ -26,12 +22,8 @@
#extension GL_AMD_gpu_shader_half_float : require
precision mediump float;
-f16vec4 tint_atanh(f16vec4 x) {
- return mix(atanh(x), f16vec4(0.0hf), greaterThanEqual(x, f16vec4(1.0hf)));
-}
-
void atanh_e3b450() {
- f16vec4 res = tint_atanh(f16vec4(0.0hf));
+ f16vec4 res = f16vec4(0.0hf);
}
void fragment_main() {
@@ -45,12 +37,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-f16vec4 tint_atanh(f16vec4 x) {
- return mix(atanh(x), f16vec4(0.0hf), greaterThanEqual(x, f16vec4(1.0hf)));
-}
-
void atanh_e3b450() {
- f16vec4 res = tint_atanh(f16vec4(0.0hf));
+ f16vec4 res = f16vec4(0.0hf);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.msl b/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.msl
index 8528cf7..b659da6 100644
--- a/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.msl
@@ -1,12 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-half4 tint_atanh(half4 x) {
- return select(atanh(x), half4(0.0h), (x >= half4(1.0h)));
-}
-
void atanh_e3b450() {
- half4 res = tint_atanh(half4(0.0h));
+ half4 res = half4(0.0h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.spvasm
index 7aba5f8..64e46bd 100644
--- a/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/atanh/e3b450.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 45
+; Bound: 32
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %23 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -17,8 +16,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_atanh "tint_atanh"
- OpName %x "x"
OpName %atanh_e3b450 "atanh_e3b450"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -35,53 +32,39 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
%half = OpTypeFloat 16
%v4half = OpTypeVector %half 4
- %9 = OpTypeFunction %v4half %v4half
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %17 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
- %bool = OpTypeBool
- %v4bool = OpTypeVector %bool 4
- %21 = OpConstantNull %v4half
- %void = OpTypeVoid
- %24 = OpTypeFunction %void
+ %15 = OpConstantNull %v4half
%_ptr_Function_v4half = OpTypePointer Function %v4half
- %31 = OpTypeFunction %v4float
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
- %tint_atanh = OpFunction %v4half None %9
- %x = OpFunctionParameter %v4half
- %14 = OpLabel
- %18 = OpFOrdGreaterThanEqual %v4bool %x %17
- %22 = OpExtInst %v4half %23 Atanh %x
- %15 = OpSelect %v4half %18 %21 %22
- OpReturnValue %15
- OpFunctionEnd
-%atanh_e3b450 = OpFunction %void None %24
- %27 = OpLabel
- %res = OpVariable %_ptr_Function_v4half Function %21
- %28 = OpFunctionCall %v4half %tint_atanh %21
- OpStore %res %28
+%atanh_e3b450 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v4half Function %15
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %31
- %33 = OpLabel
- %34 = OpFunctionCall %void %atanh_e3b450
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %atanh_e3b450
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %24
- %36 = OpLabel
- %37 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %37
+%vertex_main = OpFunction %void None %9
+ %23 = OpLabel
+ %24 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %24
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %24
- %40 = OpLabel
- %41 = OpFunctionCall %void %atanh_e3b450
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %atanh_e3b450
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %24
- %43 = OpLabel
- %44 = OpFunctionCall %void %atanh_e3b450
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %atanh_e3b450
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.dxc.hlsl
index 0b739c0..fc6fa46 100644
--- a/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-vector<float16_t, 3> tint_atanh(vector<float16_t, 3> x) {
- return (log(((float16_t(1.0h) + x) / (float16_t(1.0h) - x))) * float16_t(0.5h));
-}
-
void atanh_ec4b06() {
- vector<float16_t, 3> res = tint_atanh((float16_t(0.0h)).xxx);
+ vector<float16_t, 3> res = (float16_t(0.0h)).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.glsl b/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.glsl
index 6c8e11b..fc48649 100644
--- a/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.glsl
@@ -1,12 +1,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-f16vec3 tint_atanh(f16vec3 x) {
- return mix(atanh(x), f16vec3(0.0hf), greaterThanEqual(x, f16vec3(1.0hf)));
-}
-
void atanh_ec4b06() {
- f16vec3 res = tint_atanh(f16vec3(0.0hf));
+ f16vec3 res = f16vec3(0.0hf);
}
vec4 vertex_main() {
@@ -26,12 +22,8 @@
#extension GL_AMD_gpu_shader_half_float : require
precision mediump float;
-f16vec3 tint_atanh(f16vec3 x) {
- return mix(atanh(x), f16vec3(0.0hf), greaterThanEqual(x, f16vec3(1.0hf)));
-}
-
void atanh_ec4b06() {
- f16vec3 res = tint_atanh(f16vec3(0.0hf));
+ f16vec3 res = f16vec3(0.0hf);
}
void fragment_main() {
@@ -45,12 +37,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-f16vec3 tint_atanh(f16vec3 x) {
- return mix(atanh(x), f16vec3(0.0hf), greaterThanEqual(x, f16vec3(1.0hf)));
-}
-
void atanh_ec4b06() {
- f16vec3 res = tint_atanh(f16vec3(0.0hf));
+ f16vec3 res = f16vec3(0.0hf);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.msl b/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.msl
index e42af54..1290948 100644
--- a/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.msl
@@ -1,12 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-half3 tint_atanh(half3 x) {
- return select(atanh(x), half3(0.0h), (x >= half3(1.0h)));
-}
-
void atanh_ec4b06() {
- half3 res = tint_atanh(half3(0.0h));
+ half3 res = half3(0.0h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.spvasm
index f8bdc5c..49e6e5a 100644
--- a/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/atanh/ec4b06.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 45
+; Bound: 32
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %23 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -17,8 +16,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_atanh "tint_atanh"
- OpName %x "x"
OpName %atanh_ec4b06 "atanh_ec4b06"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -35,53 +32,39 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
- %9 = OpTypeFunction %v3half %v3half
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %17 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
- %bool = OpTypeBool
- %v3bool = OpTypeVector %bool 3
- %21 = OpConstantNull %v3half
- %void = OpTypeVoid
- %24 = OpTypeFunction %void
+ %15 = OpConstantNull %v3half
%_ptr_Function_v3half = OpTypePointer Function %v3half
- %31 = OpTypeFunction %v4float
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
- %tint_atanh = OpFunction %v3half None %9
- %x = OpFunctionParameter %v3half
- %14 = OpLabel
- %18 = OpFOrdGreaterThanEqual %v3bool %x %17
- %22 = OpExtInst %v3half %23 Atanh %x
- %15 = OpSelect %v3half %18 %21 %22
- OpReturnValue %15
- OpFunctionEnd
-%atanh_ec4b06 = OpFunction %void None %24
- %27 = OpLabel
- %res = OpVariable %_ptr_Function_v3half Function %21
- %28 = OpFunctionCall %v3half %tint_atanh %21
- OpStore %res %28
+%atanh_ec4b06 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v3half Function %15
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %31
- %33 = OpLabel
- %34 = OpFunctionCall %void %atanh_ec4b06
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %atanh_ec4b06
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %24
- %36 = OpLabel
- %37 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %37
+%vertex_main = OpFunction %void None %9
+ %23 = OpLabel
+ %24 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %24
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %24
- %40 = OpLabel
- %41 = OpFunctionCall %void %atanh_ec4b06
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %atanh_ec4b06
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %24
- %43 = OpLabel
- %44 = OpFunctionCall %void %atanh_ec4b06
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %atanh_ec4b06
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.dxc.hlsl
index 8fa4615..ae5ce9c 100644
--- a/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.dxc.hlsl
@@ -1,9 +1,5 @@
-float4 tint_atanh(float4 x) {
- return (log(((1.0f + x) / (1.0f - x))) * 0.5f);
-}
-
void atanh_f3e01b() {
- float4 res = tint_atanh((0.5f).xxxx);
+ float4 res = (0.549306154f).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.fxc.hlsl
index 8fa4615..ae5ce9c 100644
--- a/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.fxc.hlsl
@@ -1,9 +1,5 @@
-float4 tint_atanh(float4 x) {
- return (log(((1.0f + x) / (1.0f - x))) * 0.5f);
-}
-
void atanh_f3e01b() {
- float4 res = tint_atanh((0.5f).xxxx);
+ float4 res = (0.549306154f).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.glsl
index e86a88f..882eea2 100644
--- a/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.glsl
@@ -1,11 +1,7 @@
#version 310 es
-vec4 tint_atanh(vec4 x) {
- return mix(atanh(x), vec4(0.0f), greaterThanEqual(x, vec4(1.0f)));
-}
-
void atanh_f3e01b() {
- vec4 res = tint_atanh(vec4(0.5f));
+ vec4 res = vec4(0.549306154f);
}
vec4 vertex_main() {
@@ -24,12 +20,8 @@
#version 310 es
precision mediump float;
-vec4 tint_atanh(vec4 x) {
- return mix(atanh(x), vec4(0.0f), greaterThanEqual(x, vec4(1.0f)));
-}
-
void atanh_f3e01b() {
- vec4 res = tint_atanh(vec4(0.5f));
+ vec4 res = vec4(0.549306154f);
}
void fragment_main() {
@@ -42,12 +34,8 @@
}
#version 310 es
-vec4 tint_atanh(vec4 x) {
- return mix(atanh(x), vec4(0.0f), greaterThanEqual(x, vec4(1.0f)));
-}
-
void atanh_f3e01b() {
- vec4 res = tint_atanh(vec4(0.5f));
+ vec4 res = vec4(0.549306154f);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.msl b/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.msl
index ea83ed2..2b04fe0 100644
--- a/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.msl
@@ -1,12 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-float4 tint_atanh(float4 x) {
- return select(atanh(x), float4(0.0f), (x >= float4(1.0f)));
-}
-
void atanh_f3e01b() {
- float4 res = tint_atanh(float4(0.5f));
+ float4 res = float4(0.549306154f);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.spvasm
index c0daec0..2335ace 100644
--- a/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/atanh/f3e01b.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 43
+; Bound: 31
; Schema: 0
OpCapability Shader
- %20 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,8 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_atanh "tint_atanh"
- OpName %x "x"
OpName %atanh_f3e01b "atanh_f3e01b"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,51 +28,38 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
- %9 = OpTypeFunction %v4float %v4float
- %float_1 = OpConstant %float 1
- %15 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
- %bool = OpTypeBool
- %v4bool = OpTypeVector %bool 4
%void = OpTypeVoid
- %21 = OpTypeFunction %void
- %float_0_5 = OpConstant %float 0.5
- %27 = OpConstantComposite %v4float %float_0_5 %float_0_5 %float_0_5 %float_0_5
+ %9 = OpTypeFunction %void
+%float_0_549306154 = OpConstant %float 0.549306154
+ %14 = OpConstantComposite %v4float %float_0_549306154 %float_0_549306154 %float_0_549306154 %float_0_549306154
%_ptr_Function_v4float = OpTypePointer Function %v4float
- %30 = OpTypeFunction %v4float
- %tint_atanh = OpFunction %v4float None %9
- %x = OpFunctionParameter %v4float
+ %17 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%atanh_f3e01b = OpFunction %void None %9
%12 = OpLabel
- %16 = OpFOrdGreaterThanEqual %v4bool %x %15
- %19 = OpExtInst %v4float %20 Atanh %x
- %13 = OpSelect %v4float %16 %5 %19
- OpReturnValue %13
- OpFunctionEnd
-%atanh_f3e01b = OpFunction %void None %21
- %24 = OpLabel
%res = OpVariable %_ptr_Function_v4float Function %5
- %25 = OpFunctionCall %v4float %tint_atanh %27
- OpStore %res %25
+ OpStore %res %14
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %30
- %32 = OpLabel
- %33 = OpFunctionCall %void %atanh_f3e01b
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %atanh_f3e01b
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %21
- %35 = OpLabel
- %36 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %36
+%vertex_main = OpFunction %void None %9
+ %22 = OpLabel
+ %23 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %23
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %21
- %38 = OpLabel
- %39 = OpFunctionCall %void %atanh_f3e01b
+%fragment_main = OpFunction %void None %9
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %atanh_f3e01b
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %21
- %41 = OpLabel
- %42 = OpFunctionCall %void %atanh_f3e01b
+%compute_main = OpFunction %void None %9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %atanh_f3e01b
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.glsl
index 99d917d..c0a87bf 100644
--- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.glsl
@@ -1,11 +1,7 @@
#version 310 es
-float tint_saturate(float v) {
- return clamp(v, 0.0f, 1.0f);
-}
-
void saturate_270da5() {
- float res = tint_saturate(2.0f);
+ float res = 1.0f;
}
vec4 vertex_main() {
@@ -24,12 +20,8 @@
#version 310 es
precision mediump float;
-float tint_saturate(float v) {
- return clamp(v, 0.0f, 1.0f);
-}
-
void saturate_270da5() {
- float res = tint_saturate(2.0f);
+ float res = 1.0f;
}
void fragment_main() {
@@ -42,12 +34,8 @@
}
#version 310 es
-float tint_saturate(float v) {
- return clamp(v, 0.0f, 1.0f);
-}
-
void saturate_270da5() {
- float res = tint_saturate(2.0f);
+ float res = 1.0f;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.spvasm
index 47550a2..323b571 100644
--- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 37
+; Bound: 29
; Schema: 0
OpCapability Shader
- %14 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,8 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_saturate "tint_saturate"
- OpName %v "v"
OpName %saturate_270da5 "saturate_270da5"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,45 +28,36 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
- %9 = OpTypeFunction %float %float
- %float_1 = OpConstant %float 1
%void = OpTypeVoid
- %16 = OpTypeFunction %void
- %float_2 = OpConstant %float 2
+ %9 = OpTypeFunction %void
+ %float_1 = OpConstant %float 1
%_ptr_Function_float = OpTypePointer Function %float
- %24 = OpTypeFunction %v4float
-%tint_saturate = OpFunction %float None %9
- %v = OpFunctionParameter %float
+ %16 = OpTypeFunction %v4float
+%saturate_270da5 = OpFunction %void None %9
%12 = OpLabel
- %13 = OpExtInst %float %14 NClamp %v %8 %float_1
- OpReturnValue %13
- OpFunctionEnd
-%saturate_270da5 = OpFunction %void None %16
- %19 = OpLabel
%res = OpVariable %_ptr_Function_float Function %8
- %20 = OpFunctionCall %float %tint_saturate %float_2
- OpStore %res %20
+ OpStore %res %float_1
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %24
- %26 = OpLabel
- %27 = OpFunctionCall %void %saturate_270da5
+%vertex_main_inner = OpFunction %v4float None %16
+ %18 = OpLabel
+ %19 = OpFunctionCall %void %saturate_270da5
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %16
- %29 = OpLabel
- %30 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %30
+%vertex_main = OpFunction %void None %9
+ %21 = OpLabel
+ %22 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %22
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %16
- %32 = OpLabel
- %33 = OpFunctionCall %void %saturate_270da5
+%fragment_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %saturate_270da5
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %16
- %35 = OpLabel
- %36 = OpFunctionCall %void %saturate_270da5
+%compute_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %saturate_270da5
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.glsl
index 41d59bd..683f6d0 100644
--- a/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.glsl
@@ -1,12 +1,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-f16vec3 tint_saturate(f16vec3 v) {
- return clamp(v, f16vec3(0.0hf), f16vec3(1.0hf));
-}
-
void saturate_462535() {
- f16vec3 res = tint_saturate(f16vec3(0.0hf));
+ f16vec3 res = f16vec3(0.0hf);
}
vec4 vertex_main() {
@@ -26,12 +22,8 @@
#extension GL_AMD_gpu_shader_half_float : require
precision mediump float;
-f16vec3 tint_saturate(f16vec3 v) {
- return clamp(v, f16vec3(0.0hf), f16vec3(1.0hf));
-}
-
void saturate_462535() {
- f16vec3 res = tint_saturate(f16vec3(0.0hf));
+ f16vec3 res = f16vec3(0.0hf);
}
void fragment_main() {
@@ -45,12 +37,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-f16vec3 tint_saturate(f16vec3 v) {
- return clamp(v, f16vec3(0.0hf), f16vec3(1.0hf));
-}
-
void saturate_462535() {
- f16vec3 res = tint_saturate(f16vec3(0.0hf));
+ f16vec3 res = f16vec3(0.0hf);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.spvasm
index 70b0d51..dfa8ca2 100644
--- a/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 41
+; Bound: 32
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %16 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -17,8 +16,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_saturate "tint_saturate"
- OpName %v "v"
OpName %saturate_462535 "saturate_462535"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -35,49 +32,39 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
- %9 = OpTypeFunction %v3half %v3half
- %17 = OpConstantNull %v3half
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %19 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
- %void = OpTypeVoid
- %20 = OpTypeFunction %void
+ %15 = OpConstantNull %v3half
%_ptr_Function_v3half = OpTypePointer Function %v3half
- %27 = OpTypeFunction %v4float
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_saturate = OpFunction %v3half None %9
- %v = OpFunctionParameter %v3half
- %14 = OpLabel
- %15 = OpExtInst %v3half %16 NClamp %v %17 %19
- OpReturnValue %15
- OpFunctionEnd
-%saturate_462535 = OpFunction %void None %20
- %23 = OpLabel
- %res = OpVariable %_ptr_Function_v3half Function %17
- %24 = OpFunctionCall %v3half %tint_saturate %17
- OpStore %res %24
+%saturate_462535 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v3half Function %15
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %27
- %29 = OpLabel
- %30 = OpFunctionCall %void %saturate_462535
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %saturate_462535
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %20
- %32 = OpLabel
- %33 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %33
+%vertex_main = OpFunction %void None %9
+ %23 = OpLabel
+ %24 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %24
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %20
- %36 = OpLabel
- %37 = OpFunctionCall %void %saturate_462535
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %saturate_462535
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %20
- %39 = OpLabel
- %40 = OpFunctionCall %void %saturate_462535
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %saturate_462535
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.glsl
index 8b4840e..a4d1fe9 100644
--- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.glsl
@@ -1,11 +1,7 @@
#version 310 es
-vec2 tint_saturate(vec2 v) {
- return clamp(v, vec2(0.0f), vec2(1.0f));
-}
-
void saturate_51567f() {
- vec2 res = tint_saturate(vec2(2.0f));
+ vec2 res = vec2(1.0f);
}
vec4 vertex_main() {
@@ -24,12 +20,8 @@
#version 310 es
precision mediump float;
-vec2 tint_saturate(vec2 v) {
- return clamp(v, vec2(0.0f), vec2(1.0f));
-}
-
void saturate_51567f() {
- vec2 res = tint_saturate(vec2(2.0f));
+ vec2 res = vec2(1.0f);
}
void fragment_main() {
@@ -42,12 +34,8 @@
}
#version 310 es
-vec2 tint_saturate(vec2 v) {
- return clamp(v, vec2(0.0f), vec2(1.0f));
-}
-
void saturate_51567f() {
- vec2 res = tint_saturate(vec2(2.0f));
+ vec2 res = vec2(1.0f);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.spvasm
index 563368c..0528cb2 100644
--- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 41
+; Bound: 32
; Schema: 0
OpCapability Shader
- %15 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,8 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_saturate "tint_saturate"
- OpName %v "v"
OpName %saturate_51567f "saturate_51567f"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,49 +28,39 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
- %v2float = OpTypeVector %float 2
- %9 = OpTypeFunction %v2float %v2float
- %16 = OpConstantNull %v2float
- %float_1 = OpConstant %float 1
- %18 = OpConstantComposite %v2float %float_1 %float_1
%void = OpTypeVoid
- %19 = OpTypeFunction %void
- %float_2 = OpConstant %float 2
- %25 = OpConstantComposite %v2float %float_2 %float_2
+ %9 = OpTypeFunction %void
+ %v2float = OpTypeVector %float 2
+ %float_1 = OpConstant %float 1
+ %15 = OpConstantComposite %v2float %float_1 %float_1
%_ptr_Function_v2float = OpTypePointer Function %v2float
- %28 = OpTypeFunction %v4float
-%tint_saturate = OpFunction %v2float None %9
- %v = OpFunctionParameter %v2float
- %13 = OpLabel
- %14 = OpExtInst %v2float %15 NClamp %v %16 %18
- OpReturnValue %14
- OpFunctionEnd
-%saturate_51567f = OpFunction %void None %19
- %22 = OpLabel
- %res = OpVariable %_ptr_Function_v2float Function %16
- %23 = OpFunctionCall %v2float %tint_saturate %25
- OpStore %res %23
+ %18 = OpConstantNull %v2float
+ %19 = OpTypeFunction %v4float
+%saturate_51567f = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v2float Function %18
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %28
- %30 = OpLabel
- %31 = OpFunctionCall %void %saturate_51567f
+%vertex_main_inner = OpFunction %v4float None %19
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %saturate_51567f
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %19
- %33 = OpLabel
- %34 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %34
+%vertex_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %25
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %19
- %36 = OpLabel
- %37 = OpFunctionCall %void %saturate_51567f
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %saturate_51567f
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %19
- %39 = OpLabel
- %40 = OpFunctionCall %void %saturate_51567f
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %saturate_51567f
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.glsl
index c5ca265..cf6681e 100644
--- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.glsl
@@ -1,11 +1,7 @@
#version 310 es
-vec3 tint_saturate(vec3 v) {
- return clamp(v, vec3(0.0f), vec3(1.0f));
-}
-
void saturate_6bcddf() {
- vec3 res = tint_saturate(vec3(2.0f));
+ vec3 res = vec3(1.0f);
}
vec4 vertex_main() {
@@ -24,12 +20,8 @@
#version 310 es
precision mediump float;
-vec3 tint_saturate(vec3 v) {
- return clamp(v, vec3(0.0f), vec3(1.0f));
-}
-
void saturate_6bcddf() {
- vec3 res = tint_saturate(vec3(2.0f));
+ vec3 res = vec3(1.0f);
}
void fragment_main() {
@@ -42,12 +34,8 @@
}
#version 310 es
-vec3 tint_saturate(vec3 v) {
- return clamp(v, vec3(0.0f), vec3(1.0f));
-}
-
void saturate_6bcddf() {
- vec3 res = tint_saturate(vec3(2.0f));
+ vec3 res = vec3(1.0f);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.spvasm
index 5559bd2..ea1db97 100644
--- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 41
+; Bound: 32
; Schema: 0
OpCapability Shader
- %15 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,8 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_saturate "tint_saturate"
- OpName %v "v"
OpName %saturate_6bcddf "saturate_6bcddf"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,49 +28,39 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
- %v3float = OpTypeVector %float 3
- %9 = OpTypeFunction %v3float %v3float
- %16 = OpConstantNull %v3float
- %float_1 = OpConstant %float 1
- %18 = OpConstantComposite %v3float %float_1 %float_1 %float_1
%void = OpTypeVoid
- %19 = OpTypeFunction %void
- %float_2 = OpConstant %float 2
- %25 = OpConstantComposite %v3float %float_2 %float_2 %float_2
+ %9 = OpTypeFunction %void
+ %v3float = OpTypeVector %float 3
+ %float_1 = OpConstant %float 1
+ %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1
%_ptr_Function_v3float = OpTypePointer Function %v3float
- %28 = OpTypeFunction %v4float
-%tint_saturate = OpFunction %v3float None %9
- %v = OpFunctionParameter %v3float
- %13 = OpLabel
- %14 = OpExtInst %v3float %15 NClamp %v %16 %18
- OpReturnValue %14
- OpFunctionEnd
-%saturate_6bcddf = OpFunction %void None %19
- %22 = OpLabel
- %res = OpVariable %_ptr_Function_v3float Function %16
- %23 = OpFunctionCall %v3float %tint_saturate %25
- OpStore %res %23
+ %18 = OpConstantNull %v3float
+ %19 = OpTypeFunction %v4float
+%saturate_6bcddf = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v3float Function %18
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %28
- %30 = OpLabel
- %31 = OpFunctionCall %void %saturate_6bcddf
+%vertex_main_inner = OpFunction %v4float None %19
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %saturate_6bcddf
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %19
- %33 = OpLabel
- %34 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %34
+%vertex_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %25
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %19
- %36 = OpLabel
- %37 = OpFunctionCall %void %saturate_6bcddf
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %saturate_6bcddf
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %19
- %39 = OpLabel
- %40 = OpFunctionCall %void %saturate_6bcddf
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %saturate_6bcddf
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.glsl
index 5ef994c..6324359 100644
--- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.glsl
@@ -1,11 +1,7 @@
#version 310 es
-vec4 tint_saturate(vec4 v) {
- return clamp(v, vec4(0.0f), vec4(1.0f));
-}
-
void saturate_a5b571() {
- vec4 res = tint_saturate(vec4(2.0f));
+ vec4 res = vec4(1.0f);
}
vec4 vertex_main() {
@@ -24,12 +20,8 @@
#version 310 es
precision mediump float;
-vec4 tint_saturate(vec4 v) {
- return clamp(v, vec4(0.0f), vec4(1.0f));
-}
-
void saturate_a5b571() {
- vec4 res = tint_saturate(vec4(2.0f));
+ vec4 res = vec4(1.0f);
}
void fragment_main() {
@@ -42,12 +34,8 @@
}
#version 310 es
-vec4 tint_saturate(vec4 v) {
- return clamp(v, vec4(0.0f), vec4(1.0f));
-}
-
void saturate_a5b571() {
- vec4 res = tint_saturate(vec4(2.0f));
+ vec4 res = vec4(1.0f);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.spvasm
index cc9e8d8..ce06562 100644
--- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 39
+; Bound: 30
; Schema: 0
OpCapability Shader
- %14 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,8 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_saturate "tint_saturate"
- OpName %v "v"
OpName %saturate_a5b571 "saturate_a5b571"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,47 +28,37 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
- %9 = OpTypeFunction %v4float %v4float
- %float_1 = OpConstant %float 1
- %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%void = OpTypeVoid
- %17 = OpTypeFunction %void
- %float_2 = OpConstant %float 2
- %23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
+ %9 = OpTypeFunction %void
+ %float_1 = OpConstant %float 1
+ %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Function_v4float = OpTypePointer Function %v4float
- %26 = OpTypeFunction %v4float
-%tint_saturate = OpFunction %v4float None %9
- %v = OpFunctionParameter %v4float
+ %17 = OpTypeFunction %v4float
+%saturate_a5b571 = OpFunction %void None %9
%12 = OpLabel
- %13 = OpExtInst %v4float %14 NClamp %v %5 %16
- OpReturnValue %13
- OpFunctionEnd
-%saturate_a5b571 = OpFunction %void None %17
- %20 = OpLabel
%res = OpVariable %_ptr_Function_v4float Function %5
- %21 = OpFunctionCall %v4float %tint_saturate %23
- OpStore %res %21
+ OpStore %res %14
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %26
- %28 = OpLabel
- %29 = OpFunctionCall %void %saturate_a5b571
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %saturate_a5b571
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %17
- %31 = OpLabel
- %32 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %32
+%vertex_main = OpFunction %void None %9
+ %22 = OpLabel
+ %23 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %23
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %17
- %34 = OpLabel
- %35 = OpFunctionCall %void %saturate_a5b571
+%fragment_main = OpFunction %void None %9
+ %25 = OpLabel
+ %26 = OpFunctionCall %void %saturate_a5b571
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %17
- %37 = OpLabel
- %38 = OpFunctionCall %void %saturate_a5b571
+%compute_main = OpFunction %void None %9
+ %28 = OpLabel
+ %29 = OpFunctionCall %void %saturate_a5b571
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.glsl
index 8a515ae..821559f 100644
--- a/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.glsl
@@ -1,12 +1,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-f16vec2 tint_saturate(f16vec2 v) {
- return clamp(v, f16vec2(0.0hf), f16vec2(1.0hf));
-}
-
void saturate_cd2028() {
- f16vec2 res = tint_saturate(f16vec2(0.0hf));
+ f16vec2 res = f16vec2(0.0hf);
}
vec4 vertex_main() {
@@ -26,12 +22,8 @@
#extension GL_AMD_gpu_shader_half_float : require
precision mediump float;
-f16vec2 tint_saturate(f16vec2 v) {
- return clamp(v, f16vec2(0.0hf), f16vec2(1.0hf));
-}
-
void saturate_cd2028() {
- f16vec2 res = tint_saturate(f16vec2(0.0hf));
+ f16vec2 res = f16vec2(0.0hf);
}
void fragment_main() {
@@ -45,12 +37,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-f16vec2 tint_saturate(f16vec2 v) {
- return clamp(v, f16vec2(0.0hf), f16vec2(1.0hf));
-}
-
void saturate_cd2028() {
- f16vec2 res = tint_saturate(f16vec2(0.0hf));
+ f16vec2 res = f16vec2(0.0hf);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.spvasm
index 14788ee..d1d24df 100644
--- a/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 41
+; Bound: 32
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %16 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -17,8 +16,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_saturate "tint_saturate"
- OpName %v "v"
OpName %saturate_cd2028 "saturate_cd2028"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -35,49 +32,39 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
- %9 = OpTypeFunction %v2half %v2half
- %17 = OpConstantNull %v2half
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %19 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0
- %void = OpTypeVoid
- %20 = OpTypeFunction %void
+ %15 = OpConstantNull %v2half
%_ptr_Function_v2half = OpTypePointer Function %v2half
- %27 = OpTypeFunction %v4float
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_saturate = OpFunction %v2half None %9
- %v = OpFunctionParameter %v2half
- %14 = OpLabel
- %15 = OpExtInst %v2half %16 NClamp %v %17 %19
- OpReturnValue %15
- OpFunctionEnd
-%saturate_cd2028 = OpFunction %void None %20
- %23 = OpLabel
- %res = OpVariable %_ptr_Function_v2half Function %17
- %24 = OpFunctionCall %v2half %tint_saturate %17
- OpStore %res %24
+%saturate_cd2028 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v2half Function %15
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %27
- %29 = OpLabel
- %30 = OpFunctionCall %void %saturate_cd2028
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %saturate_cd2028
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %20
- %32 = OpLabel
- %33 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %33
+%vertex_main = OpFunction %void None %9
+ %23 = OpLabel
+ %24 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %24
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %20
- %36 = OpLabel
- %37 = OpFunctionCall %void %saturate_cd2028
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %saturate_cd2028
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %20
- %39 = OpLabel
- %40 = OpFunctionCall %void %saturate_cd2028
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %saturate_cd2028
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.glsl
index 32ac928..96296a0 100644
--- a/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.glsl
@@ -1,12 +1,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-f16vec4 tint_saturate(f16vec4 v) {
- return clamp(v, f16vec4(0.0hf), f16vec4(1.0hf));
-}
-
void saturate_dcde71() {
- f16vec4 res = tint_saturate(f16vec4(0.0hf));
+ f16vec4 res = f16vec4(0.0hf);
}
vec4 vertex_main() {
@@ -26,12 +22,8 @@
#extension GL_AMD_gpu_shader_half_float : require
precision mediump float;
-f16vec4 tint_saturate(f16vec4 v) {
- return clamp(v, f16vec4(0.0hf), f16vec4(1.0hf));
-}
-
void saturate_dcde71() {
- f16vec4 res = tint_saturate(f16vec4(0.0hf));
+ f16vec4 res = f16vec4(0.0hf);
}
void fragment_main() {
@@ -45,12 +37,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-f16vec4 tint_saturate(f16vec4 v) {
- return clamp(v, f16vec4(0.0hf), f16vec4(1.0hf));
-}
-
void saturate_dcde71() {
- f16vec4 res = tint_saturate(f16vec4(0.0hf));
+ f16vec4 res = f16vec4(0.0hf);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.spvasm
index 3589db3..c2fbd4a 100644
--- a/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 41
+; Bound: 32
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %16 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -17,8 +16,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_saturate "tint_saturate"
- OpName %v "v"
OpName %saturate_dcde71 "saturate_dcde71"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -35,49 +32,39 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
%half = OpTypeFloat 16
%v4half = OpTypeVector %half 4
- %9 = OpTypeFunction %v4half %v4half
- %17 = OpConstantNull %v4half
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %19 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
- %void = OpTypeVoid
- %20 = OpTypeFunction %void
+ %15 = OpConstantNull %v4half
%_ptr_Function_v4half = OpTypePointer Function %v4half
- %27 = OpTypeFunction %v4float
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_saturate = OpFunction %v4half None %9
- %v = OpFunctionParameter %v4half
- %14 = OpLabel
- %15 = OpExtInst %v4half %16 NClamp %v %17 %19
- OpReturnValue %15
- OpFunctionEnd
-%saturate_dcde71 = OpFunction %void None %20
- %23 = OpLabel
- %res = OpVariable %_ptr_Function_v4half Function %17
- %24 = OpFunctionCall %v4half %tint_saturate %17
- OpStore %res %24
+%saturate_dcde71 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v4half Function %15
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %27
- %29 = OpLabel
- %30 = OpFunctionCall %void %saturate_dcde71
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %saturate_dcde71
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %20
- %32 = OpLabel
- %33 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %33
+%vertex_main = OpFunction %void None %9
+ %23 = OpLabel
+ %24 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %24
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %20
- %36 = OpLabel
- %37 = OpFunctionCall %void %saturate_dcde71
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %saturate_dcde71
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %20
- %39 = OpLabel
- %40 = OpFunctionCall %void %saturate_dcde71
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %saturate_dcde71
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.glsl
index f144f91..4aab0f3 100644
--- a/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.glsl
@@ -1,12 +1,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-float16_t tint_saturate(float16_t v) {
- return clamp(v, 0.0hf, 1.0hf);
-}
-
void saturate_e8df56() {
- float16_t res = tint_saturate(0.0hf);
+ float16_t res = 0.0hf;
}
vec4 vertex_main() {
@@ -26,12 +22,8 @@
#extension GL_AMD_gpu_shader_half_float : require
precision mediump float;
-float16_t tint_saturate(float16_t v) {
- return clamp(v, 0.0hf, 1.0hf);
-}
-
void saturate_e8df56() {
- float16_t res = tint_saturate(0.0hf);
+ float16_t res = 0.0hf;
}
void fragment_main() {
@@ -45,12 +37,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
-float16_t tint_saturate(float16_t v) {
- return clamp(v, 0.0hf, 1.0hf);
-}
-
void saturate_e8df56() {
- float16_t res = tint_saturate(0.0hf);
+ float16_t res = 0.0hf;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.spvasm
index e71aca8..846ff53 100644
--- a/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 39
+; Bound: 31
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %15 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -17,8 +16,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_saturate "tint_saturate"
- OpName %v "v"
OpName %saturate_e8df56 "saturate_e8df56"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -35,47 +32,38 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
- %half = OpTypeFloat 16
- %9 = OpTypeFunction %half %half
- %16 = OpConstantNull %half
-%half_0x1p_0 = OpConstant %half 0x1p+0
%void = OpTypeVoid
- %18 = OpTypeFunction %void
+ %9 = OpTypeFunction %void
+ %half = OpTypeFloat 16
+ %14 = OpConstantNull %half
%_ptr_Function_half = OpTypePointer Function %half
- %25 = OpTypeFunction %v4float
+ %17 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_saturate = OpFunction %half None %9
- %v = OpFunctionParameter %half
- %13 = OpLabel
- %14 = OpExtInst %half %15 NClamp %v %16 %half_0x1p_0
- OpReturnValue %14
- OpFunctionEnd
-%saturate_e8df56 = OpFunction %void None %18
- %21 = OpLabel
- %res = OpVariable %_ptr_Function_half Function %16
- %22 = OpFunctionCall %half %tint_saturate %16
- OpStore %res %22
+%saturate_e8df56 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_half Function %14
+ OpStore %res %14
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %25
- %27 = OpLabel
- %28 = OpFunctionCall %void %saturate_e8df56
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %saturate_e8df56
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %18
- %30 = OpLabel
- %31 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %31
+%vertex_main = OpFunction %void None %9
+ %22 = OpLabel
+ %23 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %23
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %18
- %34 = OpLabel
- %35 = OpFunctionCall %void %saturate_e8df56
+%fragment_main = OpFunction %void None %9
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %saturate_e8df56
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %18
- %37 = OpLabel
- %38 = OpFunctionCall %void %saturate_e8df56
+%compute_main = OpFunction %void None %9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %saturate_e8df56
OpReturn
OpFunctionEnd