2023-09-18 18:11:07 +00:00
|
|
|
// language: metal1.0
|
2021-05-03 04:18:35 +00:00
|
|
|
#include <metal_stdlib>
|
|
|
|
#include <simd/simd.h>
|
|
|
|
|
2022-02-21 21:22:54 +00:00
|
|
|
using metal::uint;
|
|
|
|
|
2021-05-03 04:18:35 +00:00
|
|
|
|
2021-08-27 22:44:57 +00:00
|
|
|
void switch_default_break(
|
|
|
|
int i
|
|
|
|
) {
|
|
|
|
switch(i) {
|
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void switch_case_break(
|
|
|
|
) {
|
|
|
|
switch(0) {
|
|
|
|
case 0: {
|
|
|
|
break;
|
|
|
|
}
|
2021-11-15 00:07:55 +00:00
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
2021-08-27 22:44:57 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop_switch_continue(
|
|
|
|
int x
|
|
|
|
) {
|
2024-09-16 19:56:58 +00:00
|
|
|
#define LOOP_IS_REACHABLE if (volatile bool unpredictable_jump_over_loop = true; unpredictable_jump_over_loop)
|
|
|
|
LOOP_IS_REACHABLE while(true) {
|
2021-08-27 22:44:57 +00:00
|
|
|
switch(x) {
|
|
|
|
case 1: {
|
|
|
|
continue;
|
|
|
|
}
|
2021-11-15 00:07:55 +00:00
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
2021-08-27 22:44:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-04-25 04:23:41 +00:00
|
|
|
void loop_switch_continue_nesting(
|
|
|
|
int x_1,
|
|
|
|
int y,
|
|
|
|
int z
|
|
|
|
) {
|
2024-09-16 19:56:58 +00:00
|
|
|
LOOP_IS_REACHABLE while(true) {
|
2024-04-25 04:23:41 +00:00
|
|
|
switch(x_1) {
|
|
|
|
case 1: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case 2: {
|
|
|
|
switch(y) {
|
|
|
|
case 1: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
default: {
|
2024-09-16 19:56:58 +00:00
|
|
|
LOOP_IS_REACHABLE while(true) {
|
2024-04-25 04:23:41 +00:00
|
|
|
switch(z) {
|
|
|
|
case 1: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch(y) {
|
|
|
|
default: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-09-16 19:56:58 +00:00
|
|
|
LOOP_IS_REACHABLE while(true) {
|
2024-04-25 04:23:41 +00:00
|
|
|
switch(y) {
|
|
|
|
case 1:
|
|
|
|
default: {
|
|
|
|
switch(z) {
|
|
|
|
default: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop_switch_omit_continue_variable_checks(
|
|
|
|
int x_2,
|
|
|
|
int y_1,
|
|
|
|
int z_1,
|
|
|
|
int w
|
|
|
|
) {
|
|
|
|
int pos_1 = 0;
|
2024-09-16 19:56:58 +00:00
|
|
|
LOOP_IS_REACHABLE while(true) {
|
2024-04-25 04:23:41 +00:00
|
|
|
switch(x_2) {
|
|
|
|
case 1: {
|
|
|
|
pos_1 = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-09-16 19:56:58 +00:00
|
|
|
LOOP_IS_REACHABLE while(true) {
|
2024-04-25 04:23:41 +00:00
|
|
|
switch(x_2) {
|
|
|
|
case 1: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: {
|
|
|
|
switch(y_1) {
|
|
|
|
case 1: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
switch(z_1) {
|
|
|
|
case 1: {
|
|
|
|
pos_1 = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-09 14:24:41 +00:00
|
|
|
struct main_Input {
|
2021-05-03 04:18:35 +00:00
|
|
|
};
|
2021-11-09 14:24:41 +00:00
|
|
|
kernel void main_(
|
2021-05-03 04:18:35 +00:00
|
|
|
metal::uint3 global_id [[thread_position_in_grid]]
|
|
|
|
) {
|
2022-04-29 19:31:06 +00:00
|
|
|
int pos = {};
|
2021-05-03 04:18:35 +00:00
|
|
|
metal::threadgroup_barrier(metal::mem_flags::mem_device);
|
|
|
|
metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup);
|
2021-08-23 02:30:22 +00:00
|
|
|
switch(1) {
|
|
|
|
default: {
|
|
|
|
pos = 1;
|
2021-10-26 17:31:54 +00:00
|
|
|
break;
|
2021-08-23 02:30:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
int _e4 = pos;
|
|
|
|
switch(_e4) {
|
2021-08-31 21:48:28 +00:00
|
|
|
case 1: {
|
|
|
|
pos = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: {
|
|
|
|
pos = 1;
|
|
|
|
break;
|
|
|
|
}
|
2022-11-15 13:31:21 +00:00
|
|
|
case 3:
|
2021-08-31 21:48:28 +00:00
|
|
|
case 4: {
|
2022-11-15 13:29:11 +00:00
|
|
|
pos = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 5: {
|
2022-05-14 14:46:08 +00:00
|
|
|
pos = 3;
|
2022-11-15 13:29:11 +00:00
|
|
|
break;
|
2021-08-31 21:48:28 +00:00
|
|
|
}
|
2022-11-15 13:31:21 +00:00
|
|
|
default:
|
2022-11-15 13:29:11 +00:00
|
|
|
case 6: {
|
2022-05-14 14:46:08 +00:00
|
|
|
pos = 4;
|
2021-10-26 17:31:54 +00:00
|
|
|
break;
|
2021-08-31 21:48:28 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-19 21:31:38 +00:00
|
|
|
switch(0u) {
|
|
|
|
case 0u: {
|
|
|
|
break;
|
|
|
|
}
|
2021-11-15 00:07:55 +00:00
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
2021-09-19 21:31:38 +00:00
|
|
|
}
|
2022-05-14 14:46:08 +00:00
|
|
|
int _e11 = pos;
|
|
|
|
switch(_e11) {
|
2021-08-23 02:30:22 +00:00
|
|
|
case 1: {
|
|
|
|
pos = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: {
|
|
|
|
pos = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case 3: {
|
|
|
|
pos = 2;
|
2022-11-15 13:29:11 +00:00
|
|
|
return;
|
2021-08-23 02:30:22 +00:00
|
|
|
}
|
|
|
|
case 4: {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
pos = 3;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-05-03 04:18:35 +00:00
|
|
|
}
|