Move tint::transform::Robustness to a santizier transform
There's no good reason for this to be public.
Move it into the writers, and expose a 'disable_robustness' option to
turn it off. This can be expanded to hold more fine-grain control in the
future.
Change-Id: I6ea6e54a27b2ae0fbcba5fdf45539063045cc15a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122203
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.spvasm b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.spvasm
index 6764152..c7ab06b 100644
--- a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.spvasm
+++ b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 83
+; Bound: 76
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -16,8 +16,6 @@
OpName %tint_mod "tint_mod"
OpName %lhs_0 "lhs"
OpName %rhs_0 "rhs"
- OpName %tint_return_flag "tint_return_flag"
- OpName %tint_return_value "tint_return_value"
OpName %foo "foo"
OpName %maybe_zero "maybe_zero"
%int = OpTypeInt 32 1
@@ -35,14 +33,10 @@
%int_n2147483648 = OpConstant %int -2147483648
%int_n1 = OpConstant %int -1
%int_1 = OpConstant %int 1
-%_ptr_Function_bool = OpTypePointer Function %bool
- %35 = OpConstantNull %bool
-%_ptr_Function_int = OpTypePointer Function %int
%uint = OpTypeInt 32 0
%uint_2147483648 = OpConstant %uint 2147483648
- %50 = OpConstantNull %uint
- %true = OpConstantTrue %bool
- %61 = OpTypeFunction %void %int
+ %45 = OpConstantNull %uint
+ %54 = OpTypeFunction %void %int
%unused_entry_point = OpFunction %void None %9
%12 = OpLabel
OpReturn
@@ -64,64 +58,57 @@
%lhs_0 = OpFunctionParameter %int
%rhs_0 = OpFunctionParameter %int
%32 = OpLabel
-%tint_return_flag = OpVariable %_ptr_Function_bool Function %35
-%tint_return_value = OpVariable %_ptr_Function_int Function %4
- %39 = OpIEqual %bool %rhs_0 %4
- %40 = OpIEqual %bool %lhs_0 %int_n2147483648
- %41 = OpIEqual %bool %rhs_0 %int_n1
- %42 = OpLogicalAnd %bool %40 %41
- %43 = OpLogicalOr %bool %39 %42
- %38 = OpSelect %int %43 %int_1 %rhs_0
- %47 = OpBitwiseOr %int %lhs_0 %38
- %45 = OpBitcast %uint %47
- %49 = OpBitwiseAnd %uint %45 %uint_2147483648
- %51 = OpINotEqual %bool %49 %50
- OpSelectionMerge %52 None
- OpBranchConditional %51 %53 %54
- %53 = OpLabel
- OpStore %tint_return_flag %true
- %56 = OpSDiv %int %lhs_0 %38
- %57 = OpIMul %int %56 %38
- %58 = OpISub %int %lhs_0 %57
- OpStore %tint_return_value %58
- OpBranch %52
- %54 = OpLabel
- OpStore %tint_return_flag %true
- %59 = OpSRem %int %lhs_0 %38
- OpStore %tint_return_value %59
- OpBranch %52
- %52 = OpLabel
- %60 = OpLoad %int %tint_return_value
- OpReturnValue %60
+ %34 = OpIEqual %bool %rhs_0 %4
+ %35 = OpIEqual %bool %lhs_0 %int_n2147483648
+ %36 = OpIEqual %bool %rhs_0 %int_n1
+ %37 = OpLogicalAnd %bool %35 %36
+ %38 = OpLogicalOr %bool %34 %37
+ %33 = OpSelect %int %38 %int_1 %rhs_0
+ %42 = OpBitwiseOr %int %lhs_0 %33
+ %40 = OpBitcast %uint %42
+ %44 = OpBitwiseAnd %uint %40 %uint_2147483648
+ %46 = OpINotEqual %bool %44 %45
+ OpSelectionMerge %47 None
+ OpBranchConditional %46 %48 %49
+ %48 = OpLabel
+ %50 = OpSDiv %int %lhs_0 %33
+ %51 = OpIMul %int %50 %33
+ %52 = OpISub %int %lhs_0 %51
+ OpReturnValue %52
+ %49 = OpLabel
+ %53 = OpSRem %int %lhs_0 %33
+ OpReturnValue %53
+ %47 = OpLabel
+ OpReturnValue %4
OpFunctionEnd
- %foo = OpFunction %void None %61
+ %foo = OpFunction %void None %54
%maybe_zero = OpFunctionParameter %int
- %64 = OpLabel
- %66 = OpLoad %int %a
- %65 = OpFunctionCall %int %tint_div %66 %4
- OpStore %a %65
- %68 = OpLoad %int %a
- %67 = OpFunctionCall %int %tint_mod %68 %4
- OpStore %a %67
- %70 = OpLoad %int %a
- %69 = OpFunctionCall %int %tint_div %70 %maybe_zero
- OpStore %a %69
- %72 = OpLoad %int %a
- %71 = OpFunctionCall %int %tint_mod %72 %maybe_zero
- OpStore %a %71
+ %57 = OpLabel
+ %59 = OpLoad %int %a
+ %58 = OpFunctionCall %int %tint_div %59 %4
+ OpStore %a %58
+ %61 = OpLoad %int %a
+ %60 = OpFunctionCall %int %tint_mod %61 %4
+ OpStore %a %60
+ %63 = OpLoad %int %a
+ %62 = OpFunctionCall %int %tint_div %63 %maybe_zero
+ OpStore %a %62
+ %65 = OpLoad %int %a
+ %64 = OpFunctionCall %int %tint_mod %65 %maybe_zero
+ OpStore %a %64
+ %66 = OpLoad %float %b
+ %67 = OpFDiv %float %66 %8
+ OpStore %b %67
+ %68 = OpLoad %float %b
+ %69 = OpFRem %float %68 %8
+ OpStore %b %69
+ %70 = OpLoad %float %b
+ %71 = OpConvertSToF %float %maybe_zero
+ %72 = OpFDiv %float %70 %71
+ OpStore %b %72
%73 = OpLoad %float %b
- %74 = OpFDiv %float %73 %8
- OpStore %b %74
- %75 = OpLoad %float %b
- %76 = OpFRem %float %75 %8
- OpStore %b %76
- %77 = OpLoad %float %b
- %78 = OpConvertSToF %float %maybe_zero
- %79 = OpFDiv %float %77 %78
- OpStore %b %79
- %80 = OpLoad %float %b
- %81 = OpConvertSToF %float %maybe_zero
- %82 = OpFRem %float %80 %81
- OpStore %b %82
+ %74 = OpConvertSToF %float %maybe_zero
+ %75 = OpFRem %float %73 %74
+ OpStore %b %75
OpReturn
OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.dxc.hlsl b/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.dxc.hlsl
index 9616780..503f0e7 100644
--- a/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.dxc.hlsl
+++ b/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.dxc.hlsl
@@ -10,6 +10,5 @@
}
void foo() {
- const int tint_symbol = tint_div(asint(v.Load(0u)), 2);
- v.Store(0u, asuint(tint_symbol));
+ v.Store(0u, asuint(tint_div(asint(v.Load(0u)), 2)));
}
diff --git a/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.fxc.hlsl b/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.fxc.hlsl
index 9616780..503f0e7 100644
--- a/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.fxc.hlsl
+++ b/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.fxc.hlsl
@@ -10,6 +10,5 @@
}
void foo() {
- const int tint_symbol = tint_div(asint(v.Load(0u)), 2);
- v.Store(0u, asuint(tint_symbol));
+ v.Store(0u, asuint(tint_div(asint(v.Load(0u)), 2)));
}
diff --git a/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.glsl b/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.glsl
index 822f89b..81ef9d0 100644
--- a/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.glsl
+++ b/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.glsl
@@ -17,7 +17,6 @@
}
void foo() {
- int tint_symbol = tint_div(v.inner.a, 2);
- v.inner.a = tint_symbol;
+ v.inner.a = tint_div(v.inner.a, 2);
}
diff --git a/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.msl b/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.msl
index c839ac0..03a9f2c 100644
--- a/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.msl
+++ b/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.msl
@@ -9,8 +9,7 @@
return (lhs / select(rhs, 1, bool((rhs == 0) | bool((lhs == (-2147483647 - 1)) & (rhs == -1)))));
}
-void foo(device S* const tint_symbol_1) {
- int const tint_symbol = tint_div((*(tint_symbol_1)).a, 2);
- (*(tint_symbol_1)).a = tint_symbol;
+void foo(device S* const tint_symbol) {
+ (*(tint_symbol)).a = tint_div((*(tint_symbol)).a, 2);
}
diff --git a/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.spvasm
index e1c28b2..00b456a 100644
--- a/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.spvasm
+++ b/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.spvasm
@@ -58,10 +58,10 @@
OpFunctionEnd
%foo = OpFunction %void None %6
%28 = OpLabel
- %33 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 %uint_0
- %34 = OpLoad %int %33
- %29 = OpFunctionCall %int %tint_div %34 %int_2
- %36 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 %uint_0
- OpStore %36 %29
+ %32 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 %uint_0
+ %34 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 %uint_0
+ %35 = OpLoad %int %34
+ %33 = OpFunctionCall %int %tint_div %35 %int_2
+ OpStore %32 %33
OpReturn
OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.dxc.hlsl b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.dxc.hlsl
index 40a0419..a51a03f 100644
--- a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.dxc.hlsl
+++ b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.dxc.hlsl
@@ -15,6 +15,5 @@
}
void foo() {
- const int tint_symbol = tint_mod(asint(v.Load(0u)), 2);
- v.Store(0u, asuint(tint_symbol));
+ v.Store(0u, asuint(tint_mod(asint(v.Load(0u)), 2)));
}
diff --git a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.fxc.hlsl b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.fxc.hlsl
index 40a0419..a51a03f 100644
--- a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.fxc.hlsl
+++ b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.fxc.hlsl
@@ -15,6 +15,5 @@
}
void foo() {
- const int tint_symbol = tint_mod(asint(v.Load(0u)), 2);
- v.Store(0u, asuint(tint_symbol));
+ v.Store(0u, asuint(tint_mod(asint(v.Load(0u)), 2)));
}
diff --git a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.glsl b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.glsl
index 1b27070..1ebe67e 100644
--- a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.glsl
+++ b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.glsl
@@ -22,7 +22,6 @@
}
void foo() {
- int tint_symbol = tint_mod(v.inner.a, 2);
- v.inner.a = tint_symbol;
+ v.inner.a = tint_mod(v.inner.a, 2);
}
diff --git a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.msl b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.msl
index 42772ee..1241632 100644
--- a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.msl
+++ b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.msl
@@ -14,8 +14,7 @@
}
}
-void foo(device S* const tint_symbol_1) {
- int const tint_symbol = tint_mod((*(tint_symbol_1)).a, 2);
- (*(tint_symbol_1)).a = tint_symbol;
+void foo(device S* const tint_symbol) {
+ (*(tint_symbol)).a = tint_mod((*(tint_symbol)).a, 2);
}
diff --git a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.spvasm
index 5df8f97..3bbb8ba 100644
--- a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.spvasm
+++ b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 57
+; Bound: 50
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -16,8 +16,6 @@
OpName %tint_mod "tint_mod"
OpName %lhs "lhs"
OpName %rhs "rhs"
- OpName %tint_return_flag "tint_return_flag"
- OpName %tint_return_value "tint_return_value"
OpName %foo "foo"
OpDecorate %v_block Block
OpMemberDecorate %v_block 0 Offset 0
@@ -32,18 +30,14 @@
%void = OpTypeVoid
%6 = OpTypeFunction %void
%10 = OpTypeFunction %int %int %int
+ %16 = OpConstantNull %int
%bool = OpTypeBool
-%_ptr_Function_bool = OpTypePointer Function %bool
- %18 = OpConstantNull %bool
-%_ptr_Function_int = OpTypePointer Function %int
- %21 = OpConstantNull %int
%int_n2147483648 = OpConstant %int -2147483648
%int_n1 = OpConstant %int -1
%int_1 = OpConstant %int 1
%uint = OpTypeInt 32 0
%uint_2147483648 = OpConstant %uint 2147483648
- %37 = OpConstantNull %uint
- %true = OpConstantTrue %bool
+ %32 = OpConstantNull %uint
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int
%int_2 = OpConstant %int 2
@@ -55,42 +49,35 @@
%lhs = OpFunctionParameter %int
%rhs = OpFunctionParameter %int
%14 = OpLabel
-%tint_return_flag = OpVariable %_ptr_Function_bool Function %18
-%tint_return_value = OpVariable %_ptr_Function_int Function %21
- %23 = OpIEqual %bool %rhs %21
- %25 = OpIEqual %bool %lhs %int_n2147483648
- %27 = OpIEqual %bool %rhs %int_n1
- %28 = OpLogicalAnd %bool %25 %27
- %29 = OpLogicalOr %bool %23 %28
- %22 = OpSelect %int %29 %int_1 %rhs
- %34 = OpBitwiseOr %int %lhs %22
- %32 = OpBitcast %uint %34
- %36 = OpBitwiseAnd %uint %32 %uint_2147483648
- %38 = OpINotEqual %bool %36 %37
- OpSelectionMerge %39 None
- OpBranchConditional %38 %40 %41
- %40 = OpLabel
- OpStore %tint_return_flag %true
- %43 = OpSDiv %int %lhs %22
- %44 = OpIMul %int %43 %22
- %45 = OpISub %int %lhs %44
- OpStore %tint_return_value %45
- OpBranch %39
- %41 = OpLabel
- OpStore %tint_return_flag %true
- %46 = OpSRem %int %lhs %22
- OpStore %tint_return_value %46
- OpBranch %39
- %39 = OpLabel
- %47 = OpLoad %int %tint_return_value
- OpReturnValue %47
+ %17 = OpIEqual %bool %rhs %16
+ %20 = OpIEqual %bool %lhs %int_n2147483648
+ %22 = OpIEqual %bool %rhs %int_n1
+ %23 = OpLogicalAnd %bool %20 %22
+ %24 = OpLogicalOr %bool %17 %23
+ %15 = OpSelect %int %24 %int_1 %rhs
+ %29 = OpBitwiseOr %int %lhs %15
+ %27 = OpBitcast %uint %29
+ %31 = OpBitwiseAnd %uint %27 %uint_2147483648
+ %33 = OpINotEqual %bool %31 %32
+ OpSelectionMerge %34 None
+ OpBranchConditional %33 %35 %36
+ %35 = OpLabel
+ %37 = OpSDiv %int %lhs %15
+ %38 = OpIMul %int %37 %15
+ %39 = OpISub %int %lhs %38
+ OpReturnValue %39
+ %36 = OpLabel
+ %40 = OpSRem %int %lhs %15
+ OpReturnValue %40
+ %34 = OpLabel
+ OpReturnValue %16
OpFunctionEnd
%foo = OpFunction %void None %6
- %49 = OpLabel
- %53 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 %uint_0
- %54 = OpLoad %int %53
- %50 = OpFunctionCall %int %tint_mod %54 %int_2
- %56 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 %uint_0
- OpStore %56 %50
+ %42 = OpLabel
+ %45 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 %uint_0
+ %47 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 %uint_0
+ %48 = OpLoad %int %47
+ %46 = OpFunctionCall %int %tint_mod %48 %int_2
+ OpStore %45 %46
OpReturn
OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.dxc.hlsl b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.dxc.hlsl
index c2ffedc..1c1e04c 100644
--- a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.dxc.hlsl
+++ b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.dxc.hlsl
@@ -10,6 +10,5 @@
}
void foo() {
- const int4 tint_symbol = tint_div(asint(v.Load4(0u)), (2).xxxx);
- v.Store4(0u, asuint(tint_symbol));
+ v.Store4(0u, asuint(tint_div(asint(v.Load4(0u)), (2).xxxx)));
}
diff --git a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.fxc.hlsl b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.fxc.hlsl
index c2ffedc..1c1e04c 100644
--- a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.fxc.hlsl
+++ b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.fxc.hlsl
@@ -10,6 +10,5 @@
}
void foo() {
- const int4 tint_symbol = tint_div(asint(v.Load4(0u)), (2).xxxx);
- v.Store4(0u, asuint(tint_symbol));
+ v.Store4(0u, asuint(tint_div(asint(v.Load4(0u)), (2).xxxx)));
}
diff --git a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.glsl b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.glsl
index daea9b2..1c33d31 100644
--- a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.glsl
+++ b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.glsl
@@ -17,7 +17,6 @@
}
void foo() {
- ivec4 tint_symbol = tint_div(v.inner.a, ivec4(2));
- v.inner.a = tint_symbol;
+ v.inner.a = tint_div(v.inner.a, ivec4(2));
}
diff --git a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.msl b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.msl
index f0dd095..db0e4ff 100644
--- a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.msl
+++ b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.msl
@@ -9,8 +9,7 @@
return (lhs / select(rhs, int4(1), ((rhs == int4(0)) | ((lhs == int4((-2147483647 - 1))) & (rhs == int4(-1))))));
}
-void foo(device S* const tint_symbol_1) {
- int4 const tint_symbol = tint_div((*(tint_symbol_1)).a, int4(2));
- (*(tint_symbol_1)).a = tint_symbol;
+void foo(device S* const tint_symbol) {
+ (*(tint_symbol)).a = tint_div((*(tint_symbol)).a, int4(2));
}
diff --git a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.spvasm
index cfca72a..f4ac117 100644
--- a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.spvasm
+++ b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.spvasm
@@ -44,7 +44,7 @@
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int
%int_2 = OpConstant %int 2
- %41 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2
+ %42 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2
%unused_entry_point = OpFunction %void None %7
%10 = OpLabel
OpReturn
@@ -64,10 +64,10 @@
OpFunctionEnd
%foo = OpFunction %void None %7
%33 = OpLabel
- %38 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
- %39 = OpLoad %v4int %38
- %34 = OpFunctionCall %v4int %tint_div %39 %41
- %42 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
- OpStore %42 %34
+ %37 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
+ %39 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
+ %40 = OpLoad %v4int %39
+ %38 = OpFunctionCall %v4int %tint_div %40 %42
+ OpStore %37 %38
OpReturn
OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.dxc.hlsl b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.dxc.hlsl
index ea80753..fd35f96 100644
--- a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.dxc.hlsl
+++ b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.dxc.hlsl
@@ -16,6 +16,5 @@
}
void foo() {
- const int4 tint_symbol = tint_mod(asint(v.Load4(0u)), 2);
- v.Store4(0u, asuint(tint_symbol));
+ v.Store4(0u, asuint(tint_mod(asint(v.Load4(0u)), 2)));
}
diff --git a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.fxc.hlsl b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.fxc.hlsl
index ea80753..fd35f96 100644
--- a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.fxc.hlsl
+++ b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.fxc.hlsl
@@ -16,6 +16,5 @@
}
void foo() {
- const int4 tint_symbol = tint_mod(asint(v.Load4(0u)), 2);
- v.Store4(0u, asuint(tint_symbol));
+ v.Store4(0u, asuint(tint_mod(asint(v.Load4(0u)), 2)));
}
diff --git a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.glsl b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.glsl
index b650cfb..da6ab72 100644
--- a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.glsl
+++ b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.glsl
@@ -23,7 +23,6 @@
}
void foo() {
- ivec4 tint_symbol = tint_mod(v.inner.a, 2);
- v.inner.a = tint_symbol;
+ v.inner.a = tint_mod(v.inner.a, 2);
}
diff --git a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.msl b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.msl
index e0a82eb..afe37d6 100644
--- a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.msl
+++ b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.msl
@@ -15,8 +15,7 @@
}
}
-void foo(device S* const tint_symbol_1) {
- int4 const tint_symbol = tint_mod((*(tint_symbol_1)).a, 2);
- (*(tint_symbol_1)).a = tint_symbol;
+void foo(device S* const tint_symbol) {
+ (*(tint_symbol)).a = tint_mod((*(tint_symbol)).a, 2);
}
diff --git a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.spvasm
index 52b59dd..c3a7acd 100644
--- a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.spvasm
+++ b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 65
+; Bound: 58
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -16,8 +16,6 @@
OpName %tint_mod "tint_mod"
OpName %lhs "lhs"
OpName %rhs "rhs"
- OpName %tint_return_flag "tint_return_flag"
- OpName %tint_return_value "tint_return_value"
OpName %foo "foo"
OpDecorate %v_block Block
OpMemberDecorate %v_block 0 Offset 0
@@ -33,24 +31,20 @@
%void = OpTypeVoid
%7 = OpTypeFunction %void
%11 = OpTypeFunction %v4int %v4int %int
+ %18 = OpConstantNull %v4int
%bool = OpTypeBool
-%_ptr_Function_bool = OpTypePointer Function %bool
- %19 = OpConstantNull %bool
-%_ptr_Function_v4int = OpTypePointer Function %v4int
- %22 = OpConstantNull %v4int
%v4bool = OpTypeVector %bool 4
%int_n2147483648 = OpConstant %int -2147483648
- %28 = OpConstantComposite %v4int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n2147483648
+ %23 = OpConstantComposite %v4int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n2147483648
%int_n1 = OpConstant %int -1
- %31 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1
+ %26 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1
%int_1 = OpConstant %int 1
- %36 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
+ %31 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
%uint = OpTypeInt 32 0
%v4uint = OpTypeVector %uint 4
%uint_2147483648 = OpConstant %uint 2147483648
- %43 = OpConstantComposite %v4uint %uint_2147483648 %uint_2147483648 %uint_2147483648 %uint_2147483648
- %45 = OpConstantNull %v4uint
- %true = OpConstantTrue %bool
+ %38 = OpConstantComposite %v4uint %uint_2147483648 %uint_2147483648 %uint_2147483648 %uint_2147483648
+ %40 = OpConstantNull %v4uint
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int
%int_2 = OpConstant %int 2
@@ -62,44 +56,37 @@
%lhs = OpFunctionParameter %v4int
%rhs = OpFunctionParameter %int
%15 = OpLabel
-%tint_return_flag = OpVariable %_ptr_Function_bool Function %19
-%tint_return_value = OpVariable %_ptr_Function_v4int Function %22
- %23 = OpCompositeConstruct %v4int %rhs %rhs %rhs %rhs
- %25 = OpIEqual %v4bool %23 %22
- %29 = OpIEqual %v4bool %lhs %28
- %32 = OpIEqual %v4bool %23 %31
- %33 = OpLogicalAnd %v4bool %29 %32
- %34 = OpLogicalOr %v4bool %25 %33
- %24 = OpSelect %v4int %34 %36 %23
- %41 = OpBitwiseOr %v4int %lhs %24
- %38 = OpBitcast %v4uint %41
- %44 = OpBitwiseAnd %v4uint %38 %43
- %46 = OpINotEqual %v4bool %44 %45
- %37 = OpAny %bool %46
- OpSelectionMerge %47 None
- OpBranchConditional %37 %48 %49
- %48 = OpLabel
- OpStore %tint_return_flag %true
- %51 = OpSDiv %v4int %lhs %24
- %52 = OpIMul %v4int %51 %24
- %53 = OpISub %v4int %lhs %52
- OpStore %tint_return_value %53
- OpBranch %47
- %49 = OpLabel
- OpStore %tint_return_flag %true
- %54 = OpSRem %v4int %lhs %24
- OpStore %tint_return_value %54
- OpBranch %47
- %47 = OpLabel
- %55 = OpLoad %v4int %tint_return_value
- OpReturnValue %55
+ %16 = OpCompositeConstruct %v4int %rhs %rhs %rhs %rhs
+ %19 = OpIEqual %v4bool %16 %18
+ %24 = OpIEqual %v4bool %lhs %23
+ %27 = OpIEqual %v4bool %16 %26
+ %28 = OpLogicalAnd %v4bool %24 %27
+ %29 = OpLogicalOr %v4bool %19 %28
+ %17 = OpSelect %v4int %29 %31 %16
+ %36 = OpBitwiseOr %v4int %lhs %17
+ %33 = OpBitcast %v4uint %36
+ %39 = OpBitwiseAnd %v4uint %33 %38
+ %41 = OpINotEqual %v4bool %39 %40
+ %32 = OpAny %bool %41
+ OpSelectionMerge %42 None
+ OpBranchConditional %32 %43 %44
+ %43 = OpLabel
+ %45 = OpSDiv %v4int %lhs %17
+ %46 = OpIMul %v4int %45 %17
+ %47 = OpISub %v4int %lhs %46
+ OpReturnValue %47
+ %44 = OpLabel
+ %48 = OpSRem %v4int %lhs %17
+ OpReturnValue %48
+ %42 = OpLabel
+ OpReturnValue %18
OpFunctionEnd
%foo = OpFunction %void None %7
- %57 = OpLabel
- %61 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
- %62 = OpLoad %v4int %61
- %58 = OpFunctionCall %v4int %tint_mod %62 %int_2
- %64 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
- OpStore %64 %58
+ %50 = OpLabel
+ %53 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
+ %55 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
+ %56 = OpLoad %v4int %55
+ %54 = OpFunctionCall %v4int %tint_mod %56 %int_2
+ OpStore %53 %54
OpReturn
OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.dxc.hlsl b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.dxc.hlsl
index 051500d..4d6414d 100644
--- a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.dxc.hlsl
+++ b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.dxc.hlsl
@@ -15,6 +15,5 @@
}
void foo() {
- const int4 tint_symbol = tint_mod(asint(v.Load4(0u)), (2).xxxx);
- v.Store4(0u, asuint(tint_symbol));
+ v.Store4(0u, asuint(tint_mod(asint(v.Load4(0u)), (2).xxxx)));
}
diff --git a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.fxc.hlsl b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.fxc.hlsl
index 051500d..4d6414d 100644
--- a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.fxc.hlsl
+++ b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.fxc.hlsl
@@ -15,6 +15,5 @@
}
void foo() {
- const int4 tint_symbol = tint_mod(asint(v.Load4(0u)), (2).xxxx);
- v.Store4(0u, asuint(tint_symbol));
+ v.Store4(0u, asuint(tint_mod(asint(v.Load4(0u)), (2).xxxx)));
}
diff --git a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.glsl b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.glsl
index b7ed4cc..a4bd3e6 100644
--- a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.glsl
+++ b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.glsl
@@ -22,7 +22,6 @@
}
void foo() {
- ivec4 tint_symbol = tint_mod(v.inner.a, ivec4(2));
- v.inner.a = tint_symbol;
+ v.inner.a = tint_mod(v.inner.a, ivec4(2));
}
diff --git a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.msl b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.msl
index fc61333..16b6968 100644
--- a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.msl
+++ b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.msl
@@ -14,8 +14,7 @@
}
}
-void foo(device S* const tint_symbol_1) {
- int4 const tint_symbol = tint_mod((*(tint_symbol_1)).a, int4(2));
- (*(tint_symbol_1)).a = tint_symbol;
+void foo(device S* const tint_symbol) {
+ (*(tint_symbol)).a = tint_mod((*(tint_symbol)).a, int4(2));
}
diff --git a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.spvasm
index 3ac6525..180eebd 100644
--- a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.spvasm
+++ b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 65
+; Bound: 58
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -16,8 +16,6 @@
OpName %tint_mod "tint_mod"
OpName %lhs "lhs"
OpName %rhs "rhs"
- OpName %tint_return_flag "tint_return_flag"
- OpName %tint_return_value "tint_return_value"
OpName %foo "foo"
OpDecorate %v_block Block
OpMemberDecorate %v_block 0 Offset 0
@@ -33,28 +31,24 @@
%void = OpTypeVoid
%7 = OpTypeFunction %void
%11 = OpTypeFunction %v4int %v4int %v4int
+ %17 = OpConstantNull %v4int
%bool = OpTypeBool
-%_ptr_Function_bool = OpTypePointer Function %bool
- %19 = OpConstantNull %bool
-%_ptr_Function_v4int = OpTypePointer Function %v4int
- %22 = OpConstantNull %v4int
%v4bool = OpTypeVector %bool 4
%int_n2147483648 = OpConstant %int -2147483648
- %27 = OpConstantComposite %v4int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n2147483648
+ %22 = OpConstantComposite %v4int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n2147483648
%int_n1 = OpConstant %int -1
- %30 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1
+ %25 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1
%int_1 = OpConstant %int 1
- %35 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
+ %30 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
%uint = OpTypeInt 32 0
%v4uint = OpTypeVector %uint 4
%uint_2147483648 = OpConstant %uint 2147483648
- %42 = OpConstantComposite %v4uint %uint_2147483648 %uint_2147483648 %uint_2147483648 %uint_2147483648
- %44 = OpConstantNull %v4uint
- %true = OpConstantTrue %bool
+ %37 = OpConstantComposite %v4uint %uint_2147483648 %uint_2147483648 %uint_2147483648 %uint_2147483648
+ %39 = OpConstantNull %v4uint
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int
%int_2 = OpConstant %int 2
- %63 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2
+ %57 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2
%unused_entry_point = OpFunction %void None %7
%10 = OpLabel
OpReturn
@@ -63,43 +57,36 @@
%lhs = OpFunctionParameter %v4int
%rhs = OpFunctionParameter %v4int
%15 = OpLabel
-%tint_return_flag = OpVariable %_ptr_Function_bool Function %19
-%tint_return_value = OpVariable %_ptr_Function_v4int Function %22
- %24 = OpIEqual %v4bool %rhs %22
- %28 = OpIEqual %v4bool %lhs %27
- %31 = OpIEqual %v4bool %rhs %30
- %32 = OpLogicalAnd %v4bool %28 %31
- %33 = OpLogicalOr %v4bool %24 %32
- %23 = OpSelect %v4int %33 %35 %rhs
- %40 = OpBitwiseOr %v4int %lhs %23
- %37 = OpBitcast %v4uint %40
- %43 = OpBitwiseAnd %v4uint %37 %42
- %45 = OpINotEqual %v4bool %43 %44
- %36 = OpAny %bool %45
- OpSelectionMerge %46 None
- OpBranchConditional %36 %47 %48
- %47 = OpLabel
- OpStore %tint_return_flag %true
- %50 = OpSDiv %v4int %lhs %23
- %51 = OpIMul %v4int %50 %23
- %52 = OpISub %v4int %lhs %51
- OpStore %tint_return_value %52
- OpBranch %46
- %48 = OpLabel
- OpStore %tint_return_flag %true
- %53 = OpSRem %v4int %lhs %23
- OpStore %tint_return_value %53
- OpBranch %46
- %46 = OpLabel
- %54 = OpLoad %v4int %tint_return_value
- OpReturnValue %54
+ %18 = OpIEqual %v4bool %rhs %17
+ %23 = OpIEqual %v4bool %lhs %22
+ %26 = OpIEqual %v4bool %rhs %25
+ %27 = OpLogicalAnd %v4bool %23 %26
+ %28 = OpLogicalOr %v4bool %18 %27
+ %16 = OpSelect %v4int %28 %30 %rhs
+ %35 = OpBitwiseOr %v4int %lhs %16
+ %32 = OpBitcast %v4uint %35
+ %38 = OpBitwiseAnd %v4uint %32 %37
+ %40 = OpINotEqual %v4bool %38 %39
+ %31 = OpAny %bool %40
+ OpSelectionMerge %41 None
+ OpBranchConditional %31 %42 %43
+ %42 = OpLabel
+ %44 = OpSDiv %v4int %lhs %16
+ %45 = OpIMul %v4int %44 %16
+ %46 = OpISub %v4int %lhs %45
+ OpReturnValue %46
+ %43 = OpLabel
+ %47 = OpSRem %v4int %lhs %16
+ OpReturnValue %47
+ %41 = OpLabel
+ OpReturnValue %17
OpFunctionEnd
%foo = OpFunction %void None %7
- %56 = OpLabel
- %60 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
- %61 = OpLoad %v4int %60
- %57 = OpFunctionCall %v4int %tint_mod %61 %63
- %64 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
- OpStore %64 %57
+ %49 = OpLabel
+ %52 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
+ %54 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
+ %55 = OpLoad %v4int %54
+ %53 = OpFunctionCall %v4int %tint_mod %55 %57
+ OpStore %52 %53
OpReturn
OpFunctionEnd