#include <metal_stdlib> | |
using namespace metal; | |
int tint_mod_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)); | |
int const v_3 = select(rhs, 1, bool((v_2 | uint(v_1)))); | |
return as_type<int>((as_type<uint>(lhs) - as_type<uint>(as_type<int>((as_type<uint>((lhs / v_3)) * as_type<uint>(v_3)))))); | |
} | |
kernel void f() { | |
int const a = 1; | |
int const b = 2; | |
int const r = tint_mod_i32(a, b); | |
} |