| #include <metal_stdlib> | |
| using namespace metal; | |
| struct tint_module_vars_struct { | |
| threadgroup int* a; | |
| threadgroup int* b; | |
| }; | |
| struct tint_symbol_2 { | |
| int tint_symbol; | |
| int tint_symbol_1; | |
| }; | |
| void foo_inner(uint tint_local_index, tint_module_vars_struct tint_module_vars) { | |
| if ((tint_local_index < 1u)) { | |
| (*tint_module_vars.a) = 0; | |
| (*tint_module_vars.b) = 0; | |
| } | |
| (threadgroup_barrier(mem_flags::mem_threadgroup)); | |
| { | |
| uint2 tint_loop_idx = uint2(4294967295u); | |
| int i = 0; | |
| while(true) { | |
| if (all((tint_loop_idx == uint2(0u)))) { | |
| break; | |
| } | |
| int const v = i; | |
| (threadgroup_barrier(mem_flags::mem_threadgroup)); | |
| int const v_1 = (*tint_module_vars.a); | |
| (threadgroup_barrier(mem_flags::mem_threadgroup)); | |
| if ((v < v_1)) { | |
| } else { | |
| break; | |
| } | |
| { | |
| uint const tint_low_inc = (tint_loop_idx.x - 1u); | |
| tint_loop_idx.x = tint_low_inc; | |
| uint const tint_carry = uint((tint_low_inc == 4294967295u)); | |
| tint_loop_idx.y = (tint_loop_idx.y - tint_carry); | |
| int const v_2 = i; | |
| (threadgroup_barrier(mem_flags::mem_threadgroup)); | |
| int const v_3 = (*tint_module_vars.b); | |
| (threadgroup_barrier(mem_flags::mem_threadgroup)); | |
| i = as_type<int>((as_type<uint>(v_2) + as_type<uint>(v_3))); | |
| } | |
| } | |
| } | |
| } | |
| [[max_total_threads_per_threadgroup(1)]] | |
| kernel void foo(uint tint_local_index [[thread_index_in_threadgroup]], threadgroup tint_symbol_2* v_4 [[threadgroup(0)]]) { | |
| tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.a=(&(*v_4).tint_symbol), .b=(&(*v_4).tint_symbol_1)}; | |
| (foo_inner(tint_local_index, tint_module_vars)); | |
| } |