mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-11 14:41:50 +00:00
tint: polyfill remainder to handle negative operands
Bug: tint:1802 Change-Id: Ie9baa045feda08523e5ca4f5ce94b6db7d4477e5 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119100 Commit-Queue: Antonio Maiorano <amaiorano@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
78583a14e6
commit
ec20758675
@@ -11,7 +11,12 @@ int tint_div(int lhs, int rhs) {
|
||||
}
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
return (lhs % (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs));
|
||||
const int rhs_or_one = (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs);
|
||||
if (any(((uint((lhs | rhs_or_one)) & 2147483648u) != 0u))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo(int maybe_zero) {
|
||||
|
||||
@@ -11,7 +11,12 @@ int tint_div(int lhs, int rhs) {
|
||||
}
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
return (lhs % (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs));
|
||||
const int rhs_or_one = (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs);
|
||||
if (any(((uint((lhs | rhs_or_one)) & 2147483648u) != 0u))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo(int maybe_zero) {
|
||||
|
||||
@@ -16,7 +16,12 @@ int tint_div(int lhs, int rhs) {
|
||||
}
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
return (lhs % (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
if (((uint((lhs | rhs_or_one)) & 2147483648u) != 0u)) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo(int maybe_zero) {
|
||||
|
||||
@@ -6,7 +6,12 @@ int tint_div(int lhs, int rhs) {
|
||||
}
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
return (lhs % select(rhs, 1, bool((rhs == 0) | bool((lhs == (-2147483647 - 1)) & (rhs == -1)))));
|
||||
int const rhs_or_one = select(rhs, 1, bool((rhs == 0) | bool((lhs == (-2147483647 - 1)) & (rhs == -1))));
|
||||
if (any(((uint((lhs | rhs_or_one)) & 2147483648u) != 0u))) {
|
||||
return as_type<int>((as_type<uint>(lhs) - as_type<uint>(as_type<int>((as_type<uint>((lhs / rhs_or_one)) * as_type<uint>(rhs_or_one))))));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo(int maybe_zero) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 62
|
||||
; Bound: 83
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
@@ -16,6 +16,8 @@
|
||||
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
|
||||
@@ -33,7 +35,14 @@
|
||||
%int_n2147483648 = OpConstant %int -2147483648
|
||||
%int_n1 = OpConstant %int -1
|
||||
%int_1 = OpConstant %int 1
|
||||
%40 = OpTypeFunction %void %int
|
||||
%_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
|
||||
%unused_entry_point = OpFunction %void None %9
|
||||
%12 = OpLabel
|
||||
OpReturn
|
||||
@@ -55,43 +64,64 @@
|
||||
%lhs_0 = OpFunctionParameter %int
|
||||
%rhs_0 = OpFunctionParameter %int
|
||||
%32 = OpLabel
|
||||
%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
|
||||
%39 = OpSRem %int %lhs_0 %33
|
||||
OpReturnValue %39
|
||||
%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
|
||||
OpFunctionEnd
|
||||
%foo = OpFunction %void None %40
|
||||
%foo = OpFunction %void None %61
|
||||
%maybe_zero = OpFunctionParameter %int
|
||||
%43 = OpLabel
|
||||
%45 = OpLoad %int %a
|
||||
%44 = OpFunctionCall %int %tint_div %45 %4
|
||||
OpStore %a %44
|
||||
%47 = OpLoad %int %a
|
||||
%46 = OpFunctionCall %int %tint_mod %47 %4
|
||||
OpStore %a %46
|
||||
%49 = OpLoad %int %a
|
||||
%48 = OpFunctionCall %int %tint_div %49 %maybe_zero
|
||||
OpStore %a %48
|
||||
%51 = OpLoad %int %a
|
||||
%50 = OpFunctionCall %int %tint_mod %51 %maybe_zero
|
||||
OpStore %a %50
|
||||
%52 = OpLoad %float %b
|
||||
%53 = OpFDiv %float %52 %8
|
||||
OpStore %b %53
|
||||
%54 = OpLoad %float %b
|
||||
%55 = OpFRem %float %54 %8
|
||||
OpStore %b %55
|
||||
%56 = OpLoad %float %b
|
||||
%57 = OpConvertSToF %float %maybe_zero
|
||||
%58 = OpFDiv %float %56 %57
|
||||
OpStore %b %58
|
||||
%59 = OpLoad %float %b
|
||||
%60 = OpConvertSToF %float %maybe_zero
|
||||
%61 = OpFRem %float %59 %60
|
||||
OpStore %b %61
|
||||
%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
|
||||
%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
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -6,7 +6,12 @@ void unused_entry_point() {
|
||||
RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
return (lhs % (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs));
|
||||
const int rhs_or_one = (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs);
|
||||
if (any(((uint((lhs | rhs_or_one)) & 2147483648u) != 0u))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
||||
@@ -6,7 +6,12 @@ void unused_entry_point() {
|
||||
RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
return (lhs % (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs));
|
||||
const int rhs_or_one = (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs);
|
||||
if (any(((uint((lhs | rhs_or_one)) & 2147483648u) != 0u))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
||||
@@ -13,7 +13,12 @@ layout(binding = 0, std430) buffer v_block_ssbo {
|
||||
} v;
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
return (lhs % (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
if (((uint((lhs | rhs_or_one)) & 2147483648u) != 0u)) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
||||
@@ -6,7 +6,12 @@ struct S {
|
||||
};
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
return (lhs % select(rhs, 1, bool((rhs == 0) | bool((lhs == (-2147483647 - 1)) & (rhs == -1)))));
|
||||
int const rhs_or_one = select(rhs, 1, bool((rhs == 0) | bool((lhs == (-2147483647 - 1)) & (rhs == -1))));
|
||||
if (any(((uint((lhs | rhs_or_one)) & 2147483648u) != 0u))) {
|
||||
return as_type<int>((as_type<uint>(lhs) - as_type<uint>(as_type<int>((as_type<uint>((lhs / rhs_or_one)) * as_type<uint>(rhs_or_one))))));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo(device S* const tint_symbol_1) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 37
|
||||
; Bound: 57
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
@@ -16,6 +16,8 @@
|
||||
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
|
||||
@@ -30,12 +32,18 @@
|
||||
%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
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int
|
||||
%int_2 = OpConstant %int 2
|
||||
@@ -47,21 +55,42 @@
|
||||
%lhs = OpFunctionParameter %int
|
||||
%rhs = OpFunctionParameter %int
|
||||
%14 = OpLabel
|
||||
%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
|
||||
%26 = OpSRem %int %lhs %15
|
||||
OpReturnValue %26
|
||||
%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
|
||||
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_mod %34 %int_2
|
||||
%36 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 %uint_0
|
||||
OpStore %36 %29
|
||||
%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
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -7,7 +7,12 @@ RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
int4 tint_mod(int4 lhs, int rhs) {
|
||||
const int4 r = int4((rhs).xxxx);
|
||||
return (lhs % (((r == (0).xxxx) | ((lhs == (-2147483648).xxxx) & (r == (-1).xxxx))) ? (1).xxxx : r));
|
||||
const int4 rhs_or_one = (((r == (0).xxxx) | ((lhs == (-2147483648).xxxx) & (r == (-1).xxxx))) ? (1).xxxx : r);
|
||||
if (any(((uint4((lhs | rhs_or_one)) & (2147483648u).xxxx) != (0u).xxxx))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
||||
@@ -7,7 +7,12 @@ RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
int4 tint_mod(int4 lhs, int rhs) {
|
||||
const int4 r = int4((rhs).xxxx);
|
||||
return (lhs % (((r == (0).xxxx) | ((lhs == (-2147483648).xxxx) & (r == (-1).xxxx))) ? (1).xxxx : r));
|
||||
const int4 rhs_or_one = (((r == (0).xxxx) | ((lhs == (-2147483648).xxxx) & (r == (-1).xxxx))) ? (1).xxxx : r);
|
||||
if (any(((uint4((lhs | rhs_or_one)) & (2147483648u).xxxx) != (0u).xxxx))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
||||
@@ -14,7 +14,12 @@ layout(binding = 0, std430) buffer v_block_ssbo {
|
||||
|
||||
ivec4 tint_mod(ivec4 lhs, int rhs) {
|
||||
ivec4 r = ivec4(rhs);
|
||||
return (lhs % mix(r, ivec4(1), bvec4(uvec4(equal(r, ivec4(0))) | uvec4(bvec4(uvec4(equal(lhs, ivec4(-2147483648))) & uvec4(equal(r, ivec4(-1))))))));
|
||||
ivec4 rhs_or_one = mix(r, ivec4(1), bvec4(uvec4(equal(r, ivec4(0))) | uvec4(bvec4(uvec4(equal(lhs, ivec4(-2147483648))) & uvec4(equal(r, ivec4(-1)))))));
|
||||
if (any(notEqual((uvec4((lhs | rhs_or_one)) & uvec4(2147483648u)), uvec4(0u)))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
||||
@@ -7,7 +7,12 @@ struct S {
|
||||
|
||||
int4 tint_mod(int4 lhs, int rhs) {
|
||||
int4 const r = int4(rhs);
|
||||
return (lhs % select(r, int4(1), ((r == int4(0)) | ((lhs == int4((-2147483647 - 1))) & (r == int4(-1))))));
|
||||
int4 const rhs_or_one = select(r, int4(1), ((r == int4(0)) | ((lhs == int4((-2147483647 - 1))) & (r == int4(-1)))));
|
||||
if (any(((uint4((lhs | rhs_or_one)) & uint4(2147483648u)) != uint4(0u)))) {
|
||||
return as_type<int4>((as_type<uint4>(lhs) - as_type<uint4>(as_type<int4>((as_type<uint4>((lhs / rhs_or_one)) * as_type<uint4>(rhs_or_one))))));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo(device S* const tint_symbol_1) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 43
|
||||
; Bound: 65
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
@@ -16,6 +16,8 @@
|
||||
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
|
||||
@@ -31,16 +33,24 @@
|
||||
%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
|
||||
%23 = OpConstantComposite %v4int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n2147483648
|
||||
%28 = OpConstantComposite %v4int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n2147483648
|
||||
%int_n1 = OpConstant %int -1
|
||||
%26 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1
|
||||
%31 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1
|
||||
%int_1 = OpConstant %int 1
|
||||
%31 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
|
||||
%36 = 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
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int
|
||||
%int_2 = OpConstant %int 2
|
||||
@@ -52,22 +62,44 @@
|
||||
%lhs = OpFunctionParameter %v4int
|
||||
%rhs = OpFunctionParameter %int
|
||||
%15 = OpLabel
|
||||
%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
|
||||
%32 = OpSRem %v4int %lhs %17
|
||||
OpReturnValue %32
|
||||
%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
|
||||
OpFunctionEnd
|
||||
%foo = OpFunction %void None %7
|
||||
%34 = OpLabel
|
||||
%39 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
|
||||
%40 = OpLoad %v4int %39
|
||||
%35 = OpFunctionCall %v4int %tint_mod %40 %int_2
|
||||
%42 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
|
||||
OpStore %42 %35
|
||||
%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
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -6,7 +6,12 @@ void unused_entry_point() {
|
||||
RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
int4 tint_mod(int4 lhs, int4 rhs) {
|
||||
return (lhs % (((rhs == (0).xxxx) | ((lhs == (-2147483648).xxxx) & (rhs == (-1).xxxx))) ? (1).xxxx : rhs));
|
||||
const int4 rhs_or_one = (((rhs == (0).xxxx) | ((lhs == (-2147483648).xxxx) & (rhs == (-1).xxxx))) ? (1).xxxx : rhs);
|
||||
if (any(((uint4((lhs | rhs_or_one)) & (2147483648u).xxxx) != (0u).xxxx))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
||||
@@ -6,7 +6,12 @@ void unused_entry_point() {
|
||||
RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
int4 tint_mod(int4 lhs, int4 rhs) {
|
||||
return (lhs % (((rhs == (0).xxxx) | ((lhs == (-2147483648).xxxx) & (rhs == (-1).xxxx))) ? (1).xxxx : rhs));
|
||||
const int4 rhs_or_one = (((rhs == (0).xxxx) | ((lhs == (-2147483648).xxxx) & (rhs == (-1).xxxx))) ? (1).xxxx : rhs);
|
||||
if (any(((uint4((lhs | rhs_or_one)) & (2147483648u).xxxx) != (0u).xxxx))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
||||
@@ -13,7 +13,12 @@ layout(binding = 0, std430) buffer v_block_ssbo {
|
||||
} v;
|
||||
|
||||
ivec4 tint_mod(ivec4 lhs, ivec4 rhs) {
|
||||
return (lhs % mix(rhs, ivec4(1), bvec4(uvec4(equal(rhs, ivec4(0))) | uvec4(bvec4(uvec4(equal(lhs, ivec4(-2147483648))) & uvec4(equal(rhs, ivec4(-1))))))));
|
||||
ivec4 rhs_or_one = mix(rhs, ivec4(1), bvec4(uvec4(equal(rhs, ivec4(0))) | uvec4(bvec4(uvec4(equal(lhs, ivec4(-2147483648))) & uvec4(equal(rhs, ivec4(-1)))))));
|
||||
if (any(notEqual((uvec4((lhs | rhs_or_one)) & uvec4(2147483648u)), uvec4(0u)))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
||||
@@ -6,7 +6,12 @@ struct S {
|
||||
};
|
||||
|
||||
int4 tint_mod(int4 lhs, int4 rhs) {
|
||||
return (lhs % select(rhs, int4(1), ((rhs == int4(0)) | ((lhs == int4((-2147483647 - 1))) & (rhs == int4(-1))))));
|
||||
int4 const rhs_or_one = select(rhs, int4(1), ((rhs == int4(0)) | ((lhs == int4((-2147483647 - 1))) & (rhs == int4(-1)))));
|
||||
if (any(((uint4((lhs | rhs_or_one)) & uint4(2147483648u)) != uint4(0u)))) {
|
||||
return as_type<int4>((as_type<uint4>(lhs) - as_type<uint4>(as_type<int4>((as_type<uint4>((lhs / rhs_or_one)) * as_type<uint4>(rhs_or_one))))));
|
||||
} else {
|
||||
return (lhs % rhs_or_one);
|
||||
}
|
||||
}
|
||||
|
||||
void foo(device S* const tint_symbol_1) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 43
|
||||
; Bound: 65
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
@@ -16,6 +16,8 @@
|
||||
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
|
||||
@@ -31,20 +33,28 @@
|
||||
%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
|
||||
%22 = OpConstantComposite %v4int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n2147483648
|
||||
%27 = OpConstantComposite %v4int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n2147483648
|
||||
%int_n1 = OpConstant %int -1
|
||||
%25 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1
|
||||
%30 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1
|
||||
%int_1 = OpConstant %int 1
|
||||
%30 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
|
||||
%35 = 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
|
||||
%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
|
||||
%63 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2
|
||||
%unused_entry_point = OpFunction %void None %7
|
||||
%10 = OpLabel
|
||||
OpReturn
|
||||
@@ -53,21 +63,43 @@
|
||||
%lhs = OpFunctionParameter %v4int
|
||||
%rhs = OpFunctionParameter %v4int
|
||||
%15 = OpLabel
|
||||
%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
|
||||
%31 = OpSRem %v4int %lhs %16
|
||||
OpReturnValue %31
|
||||
%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
|
||||
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_mod %39 %41
|
||||
%42 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
|
||||
OpStore %42 %34
|
||||
%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
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
Reference in New Issue
Block a user