Antonio Maiorano d388bc9b36 Restore "MSL writer: make signed int overflow defined behaviour"
This reverts commit e33b0baa088146fc06881387157a92e19fcf5b7b.

Added tests/expressions/literals/intmin.wgsl test.

Bug: tint:124
Change-Id: I3d46f939ff20fa377ddb5fcb52f9afe728b8e430
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60441
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-07-30 18:59:06 +00:00

140 lines
3.5 KiB
Plaintext

#include <metal_stdlib>
using namespace metal;
struct buf1 {
/* 0x0000 */ packed_float2 injectionSwitch;
};
struct buf2 {
/* 0x0000 */ packed_float2 resolution;
};
struct doesNotMatter {
/* 0x0000 */ int x_compute_data[1];
};
struct tint_array_wrapper {
float arr[1];
};
void main_1(constant buf1& x_10, constant buf2& x_13, device doesNotMatter& x_15, thread uint3* const tint_symbol_2) {
tint_array_wrapper A = {};
int i = 0;
float4 value = 0.0f;
int m = 0;
int l = 0;
int n = 0;
A.arr[0] = 0.0f;
i = 0;
while (true) {
int const x_60 = i;
if ((x_60 < 50)) {
} else {
break;
}
int const x_63 = i;
if ((x_63 > 0)) {
float const x_68 = A.arr[0];
float const x_70 = A.arr[0];
A.arr[0] = (x_70 + x_68);
}
{
int const x_73 = i;
i = as_type<int>((as_type<uint>(x_73) + as_type<uint>(1)));
}
}
while (true) {
uint const x_80 = (*(tint_symbol_2)).x;
if ((x_80 < 100u)) {
value = float4(0.0f, 0.0f, 0.0f, 1.0f);
m = 0;
while (true) {
int const x_89 = m;
if ((x_89 < 1)) {
} else {
break;
}
l = 0;
while (true) {
int const x_96 = l;
if ((x_96 < 1)) {
} else {
break;
}
float const x_100 = x_10.injectionSwitch.x;
float const x_102 = x_10.injectionSwitch.y;
if ((x_100 > x_102)) {
return;
}
{
int const x_106 = l;
l = as_type<int>((as_type<uint>(x_106) + as_type<uint>(1)));
}
}
{
int const x_108 = m;
m = as_type<int>((as_type<uint>(x_108) + as_type<uint>(1)));
}
}
n = 0;
while (true) {
int const x_114 = n;
if ((x_114 < 1)) {
} else {
break;
}
float const x_118 = x_10.injectionSwitch.x;
float const x_120 = x_10.injectionSwitch.y;
if ((x_118 > x_120)) {
threadgroup_barrier(mem_flags::mem_threadgroup);
}
{
int const x_124 = n;
n = as_type<int>((as_type<uint>(x_124) + as_type<uint>(1)));
}
}
} else {
uint const x_127 = (*(tint_symbol_2)).x;
if ((x_127 < 120u)) {
float const x_133 = A.arr[0];
float const x_135 = x_13.resolution.x;
float const x_138 = A.arr[0];
float const x_140 = x_13.resolution.y;
value = float4((x_133 / x_135), (x_138 / x_140), 0.0f, 1.0f);
} else {
float const x_144 = x_10.injectionSwitch.x;
float const x_146 = x_10.injectionSwitch.y;
if ((x_144 > x_146)) {
{
if (false) {
} else {
break;
}
}
continue;
}
}
}
{
if (false) {
} else {
break;
}
}
}
float const x_151 = value.x;
x_15.x_compute_data[0] = int(x_151);
float const x_155 = value.y;
x_15.x_compute_data[1] = int(x_155);
float const x_159 = value.z;
x_15.x_compute_data[2] = int(x_159);
float const x_163 = value.w;
x_15.x_compute_data[3] = int(x_163);
return;
}
kernel void tint_symbol(uint3 gl_GlobalInvocationID_param [[thread_position_in_grid]], constant buf1& x_10 [[buffer(1)]], constant buf2& x_13 [[buffer(2)]], device doesNotMatter& x_15 [[buffer(0)]]) {
thread uint3 tint_symbol_3 = 0u;
tint_symbol_3 = gl_GlobalInvocationID_param;
main_1(x_10, x_13, x_15, &(tint_symbol_3));
return;
}