#include <metal_stdlib> | |
using namespace metal; | |
int tint_div_i32(int lhs, int rhs) { | |
uint const v = uint((lhs == (-2147483647 - 1))); | |
bool const v_1 = bool((v & uint((rhs == -1)))); | |
uint const v_2 = uint((rhs == 0)); | |
return (lhs / select(rhs, 1, bool((v_2 | uint(v_1))))); | |
} | |
kernel void f() { | |
int const a = 1; | |
int const b = 2; | |
int const r = tint_div_i32(a, b); | |
} |