diff --git a/src/tint/transform/remove_phonies.cc b/src/tint/transform/remove_phonies.cc index 1cac0b7690..7ba109ad44 100644 --- a/src/tint/transform/remove_phonies.cc +++ b/src/tint/transform/remove_phonies.cc @@ -97,7 +97,8 @@ void RemovePhonies::Run(CloneContext& ctx, const DataMap&, DataMap&) const { // Just skip. return ast::TraverseAction::Skip; } - if (call->Target()->IsAnyOf()) { + if (call->Target()->IsAnyOf() && + call->HasSideEffects()) { side_effects.push_back(expr); return ast::TraverseAction::Skip; } diff --git a/src/tint/transform/remove_phonies_test.cc b/src/tint/transform/remove_phonies_test.cc index 220f1db464..dc91b5a951 100644 --- a/src/tint/transform/remove_phonies_test.cc +++ b/src/tint/transform/remove_phonies_test.cc @@ -65,6 +65,8 @@ fn f() { _ = vec2(5.0); _ = vec3(6, 7, 8); _ = mat2x2(9.0, 10.0, 11.0, 12.0); + _ = atan2(1.0, 2.0); + _ = clamp(1.0, 2.0, 3.0); } )"; diff --git a/test/tint/bug/chromium/1341475.wgsl b/test/tint/bug/chromium/1341475.wgsl index 864442b17a..5d5aef68e7 100644 --- a/test/tint/bug/chromium/1341475.wgsl +++ b/test/tint/bug/chromium/1341475.wgsl @@ -1,4 +1,4 @@ @compute @workgroup_size(1) fn main() { - _ = mix(1.0, vec2(1.0).y, 1.0); + let a = mix(1.0, vec2(1.0).y, 1.0); } diff --git a/test/tint/bug/chromium/1341475.wgsl.expected.dxc.hlsl b/test/tint/bug/chromium/1341475.wgsl.expected.dxc.hlsl index 01c8800086..e897714728 100644 --- a/test/tint/bug/chromium/1341475.wgsl.expected.dxc.hlsl +++ b/test/tint/bug/chromium/1341475.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ [numthreads(1, 1, 1)] void main() { - lerp(1.0f, 1.0f, 1.0f); + const float a = lerp(1.0f, 1.0f, 1.0f); return; } diff --git a/test/tint/bug/chromium/1341475.wgsl.expected.fxc.hlsl b/test/tint/bug/chromium/1341475.wgsl.expected.fxc.hlsl index 01c8800086..e897714728 100644 --- a/test/tint/bug/chromium/1341475.wgsl.expected.fxc.hlsl +++ b/test/tint/bug/chromium/1341475.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ [numthreads(1, 1, 1)] void main() { - lerp(1.0f, 1.0f, 1.0f); + const float a = lerp(1.0f, 1.0f, 1.0f); return; } diff --git a/test/tint/bug/chromium/1341475.wgsl.expected.glsl b/test/tint/bug/chromium/1341475.wgsl.expected.glsl index f00984780a..641a2bde3e 100644 --- a/test/tint/bug/chromium/1341475.wgsl.expected.glsl +++ b/test/tint/bug/chromium/1341475.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void tint_symbol() { - mix(1.0f, 1.0f, 1.0f); + float a = mix(1.0f, 1.0f, 1.0f); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/bug/chromium/1341475.wgsl.expected.msl b/test/tint/bug/chromium/1341475.wgsl.expected.msl index 5e194ff887..4591847722 100644 --- a/test/tint/bug/chromium/1341475.wgsl.expected.msl +++ b/test/tint/bug/chromium/1341475.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; kernel void tint_symbol() { - mix(1.0f, 1.0f, 1.0f); + float const a = mix(1.0f, 1.0f, 1.0f); return; } diff --git a/test/tint/bug/chromium/1341475.wgsl.expected.wgsl b/test/tint/bug/chromium/1341475.wgsl.expected.wgsl index f77126b445..770d94d7bc 100644 --- a/test/tint/bug/chromium/1341475.wgsl.expected.wgsl +++ b/test/tint/bug/chromium/1341475.wgsl.expected.wgsl @@ -1,4 +1,4 @@ @compute @workgroup_size(1) fn main() { - _ = mix(1.0, vec2(1.0).y, 1.0); + let a = mix(1.0, vec2(1.0).y, 1.0); } diff --git a/test/tint/builtins/repeated_use.wgsl b/test/tint/builtins/repeated_use.wgsl index 026e183153..f1f1f0f5c4 100644 --- a/test/tint/builtins/repeated_use.wgsl +++ b/test/tint/builtins/repeated_use.wgsl @@ -2,19 +2,19 @@ // same builtin overload results in single helper being generated. @compute @workgroup_size(1) fn main() { - _ = degrees(vec4()); - _ = degrees(vec4(1.)); - _ = degrees(vec4(1., 2., 3., 4.)); + let a = degrees(vec4()); + let b = degrees(vec4(1.)); + let c = degrees(vec4(1., 2., 3., 4.)); - _ = degrees(vec3()); - _ = degrees(vec3(1.)); - _ = degrees(vec3(1., 2., 3.)); + let d = degrees(vec3()); + let e = degrees(vec3(1.)); + let f = degrees(vec3(1., 2., 3.)); - _ = degrees(vec2()); - _ = degrees(vec2(1.)); - _ = degrees(vec2(1., 2.)); + let g = degrees(vec2()); + let h = degrees(vec2(1.)); + let i = degrees(vec2(1., 2.)); - _ = degrees(1.); - _ = degrees(2.); - _ = degrees(3.); + let j = degrees(1.); + let k = degrees(2.); + let l = degrees(3.); } diff --git a/test/tint/builtins/repeated_use.wgsl.expected.dxc.hlsl b/test/tint/builtins/repeated_use.wgsl.expected.dxc.hlsl index 721724d053..bbf29d1edc 100644 --- a/test/tint/builtins/repeated_use.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/repeated_use.wgsl.expected.dxc.hlsl @@ -16,17 +16,17 @@ float tint_degrees_3(float param_0) { [numthreads(1, 1, 1)] void main() { - tint_degrees((0.0f).xxxx); - tint_degrees((1.0f).xxxx); - tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f)); - tint_degrees_1((0.0f).xxx); - tint_degrees_1((1.0f).xxx); - tint_degrees_1(float3(1.0f, 2.0f, 3.0f)); - tint_degrees_2((0.0f).xx); - tint_degrees_2((1.0f).xx); - tint_degrees_2(float2(1.0f, 2.0f)); - tint_degrees_3(1.0f); - tint_degrees_3(2.0f); - tint_degrees_3(3.0f); + const float4 a = tint_degrees((0.0f).xxxx); + const float4 b = tint_degrees((1.0f).xxxx); + const float4 c = tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f)); + const float3 d = tint_degrees_1((0.0f).xxx); + const float3 e = tint_degrees_1((1.0f).xxx); + const float3 f = tint_degrees_1(float3(1.0f, 2.0f, 3.0f)); + const float2 g = tint_degrees_2((0.0f).xx); + const float2 h = tint_degrees_2((1.0f).xx); + const float2 i = tint_degrees_2(float2(1.0f, 2.0f)); + const float j = tint_degrees_3(1.0f); + const float k = tint_degrees_3(2.0f); + const float l = tint_degrees_3(3.0f); return; } diff --git a/test/tint/builtins/repeated_use.wgsl.expected.fxc.hlsl b/test/tint/builtins/repeated_use.wgsl.expected.fxc.hlsl index 721724d053..bbf29d1edc 100644 --- a/test/tint/builtins/repeated_use.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/repeated_use.wgsl.expected.fxc.hlsl @@ -16,17 +16,17 @@ float tint_degrees_3(float param_0) { [numthreads(1, 1, 1)] void main() { - tint_degrees((0.0f).xxxx); - tint_degrees((1.0f).xxxx); - tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f)); - tint_degrees_1((0.0f).xxx); - tint_degrees_1((1.0f).xxx); - tint_degrees_1(float3(1.0f, 2.0f, 3.0f)); - tint_degrees_2((0.0f).xx); - tint_degrees_2((1.0f).xx); - tint_degrees_2(float2(1.0f, 2.0f)); - tint_degrees_3(1.0f); - tint_degrees_3(2.0f); - tint_degrees_3(3.0f); + const float4 a = tint_degrees((0.0f).xxxx); + const float4 b = tint_degrees((1.0f).xxxx); + const float4 c = tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f)); + const float3 d = tint_degrees_1((0.0f).xxx); + const float3 e = tint_degrees_1((1.0f).xxx); + const float3 f = tint_degrees_1(float3(1.0f, 2.0f, 3.0f)); + const float2 g = tint_degrees_2((0.0f).xx); + const float2 h = tint_degrees_2((1.0f).xx); + const float2 i = tint_degrees_2(float2(1.0f, 2.0f)); + const float j = tint_degrees_3(1.0f); + const float k = tint_degrees_3(2.0f); + const float l = tint_degrees_3(3.0f); return; } diff --git a/test/tint/builtins/repeated_use.wgsl.expected.glsl b/test/tint/builtins/repeated_use.wgsl.expected.glsl index f98ec2c4fd..fdd29e0245 100644 --- a/test/tint/builtins/repeated_use.wgsl.expected.glsl +++ b/test/tint/builtins/repeated_use.wgsl.expected.glsl @@ -18,18 +18,18 @@ float tint_degrees_3(float param_0) { void tint_symbol() { - tint_degrees(vec4(0.0f)); - tint_degrees(vec4(1.0f)); - tint_degrees(vec4(1.0f, 2.0f, 3.0f, 4.0f)); - tint_degrees_1(vec3(0.0f)); - tint_degrees_1(vec3(1.0f)); - tint_degrees_1(vec3(1.0f, 2.0f, 3.0f)); - tint_degrees_2(vec2(0.0f)); - tint_degrees_2(vec2(1.0f)); - tint_degrees_2(vec2(1.0f, 2.0f)); - tint_degrees_3(1.0f); - tint_degrees_3(2.0f); - tint_degrees_3(3.0f); + vec4 a = tint_degrees(vec4(0.0f)); + vec4 b = tint_degrees(vec4(1.0f)); + vec4 c = tint_degrees(vec4(1.0f, 2.0f, 3.0f, 4.0f)); + vec3 d = tint_degrees_1(vec3(0.0f)); + vec3 e = tint_degrees_1(vec3(1.0f)); + vec3 f = tint_degrees_1(vec3(1.0f, 2.0f, 3.0f)); + vec2 g = tint_degrees_2(vec2(0.0f)); + vec2 h = tint_degrees_2(vec2(1.0f)); + vec2 i = tint_degrees_2(vec2(1.0f, 2.0f)); + float j = tint_degrees_3(1.0f); + float k = tint_degrees_3(2.0f); + float l = tint_degrees_3(3.0f); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/builtins/repeated_use.wgsl.expected.msl b/test/tint/builtins/repeated_use.wgsl.expected.msl index 8be006ae95..c0ea4a3d75 100644 --- a/test/tint/builtins/repeated_use.wgsl.expected.msl +++ b/test/tint/builtins/repeated_use.wgsl.expected.msl @@ -19,18 +19,18 @@ float tint_degrees_3(float param_0) { } kernel void tint_symbol() { - tint_degrees(float4(0.0f)); - tint_degrees(float4(1.0f)); - tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f)); - tint_degrees_1(float3(0.0f)); - tint_degrees_1(float3(1.0f)); - tint_degrees_1(float3(1.0f, 2.0f, 3.0f)); - tint_degrees_2(float2(0.0f)); - tint_degrees_2(float2(1.0f)); - tint_degrees_2(float2(1.0f, 2.0f)); - tint_degrees_3(1.0f); - tint_degrees_3(2.0f); - tint_degrees_3(3.0f); + float4 const a = tint_degrees(float4(0.0f)); + float4 const b = tint_degrees(float4(1.0f)); + float4 const c = tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f)); + float3 const d = tint_degrees_1(float3(0.0f)); + float3 const e = tint_degrees_1(float3(1.0f)); + float3 const f = tint_degrees_1(float3(1.0f, 2.0f, 3.0f)); + float2 const g = tint_degrees_2(float2(0.0f)); + float2 const h = tint_degrees_2(float2(1.0f)); + float2 const i = tint_degrees_2(float2(1.0f, 2.0f)); + float const j = tint_degrees_3(1.0f); + float const k = tint_degrees_3(2.0f); + float const l = tint_degrees_3(3.0f); return; } diff --git a/test/tint/builtins/repeated_use.wgsl.expected.wgsl b/test/tint/builtins/repeated_use.wgsl.expected.wgsl index 7f848c6491..0af3aa2bf2 100644 --- a/test/tint/builtins/repeated_use.wgsl.expected.wgsl +++ b/test/tint/builtins/repeated_use.wgsl.expected.wgsl @@ -1,15 +1,15 @@ @compute @workgroup_size(1) fn main() { - _ = degrees(vec4()); - _ = degrees(vec4(1.0)); - _ = degrees(vec4(1.0, 2.0, 3.0, 4.0)); - _ = degrees(vec3()); - _ = degrees(vec3(1.0)); - _ = degrees(vec3(1.0, 2.0, 3.0)); - _ = degrees(vec2()); - _ = degrees(vec2(1.0)); - _ = degrees(vec2(1.0, 2.0)); - _ = degrees(1.0); - _ = degrees(2.0); - _ = degrees(3.0); + let a = degrees(vec4()); + let b = degrees(vec4(1.0)); + let c = degrees(vec4(1.0, 2.0, 3.0, 4.0)); + let d = degrees(vec3()); + let e = degrees(vec3(1.0)); + let f = degrees(vec3(1.0, 2.0, 3.0)); + let g = degrees(vec2()); + let h = degrees(vec2(1.0)); + let i = degrees(vec2(1.0, 2.0)); + let j = degrees(1.0); + let k = degrees(2.0); + let l = degrees(3.0); }