icmp_branch_signed_long.c (844B)
1 /* Signed 64-bit comparisons used as branch conditions (cmp x,x + 2 * b.lt/le/gt/ge). Operands straddle the 32-bit range so the x-register compare 3 * is required. volatile defeats folding; noinline forces real branches. Exit 4 * code 42. */ 5 __attribute__((noinline)) static int pick_lt(long a, long b) { 6 return a < b ? 10 : 1; 7 } 8 __attribute__((noinline)) static int pick_le(long a, long b) { 9 return a <= b ? 10 : 1; 10 } 11 __attribute__((noinline)) static int pick_gt(long a, long b) { 12 return a > b ? 1 : 11; 13 } 14 __attribute__((noinline)) static int pick_ge(long a, long b) { 15 return a >= b ? 1 : 11; 16 } 17 int test_main(void) { 18 volatile long a = -5000000000L, b = 5000000000L; 19 int r = 0; 20 r += pick_lt(a, b); /* 10 */ 21 r += pick_le(a, b); /* 10 */ 22 r += pick_gt(a, b); /* 11 */ 23 r += pick_ge(a, b); /* 11 */ 24 return r; /* 42 */ 25 }