icmp_branch_unsigned_int.c (989B)
1 /* Unsigned 32-bit comparisons used as branch conditions (cmp + b.lo/b.ls/ 2 * b.hi/b.hs). The large operand has the top bit set so signed vs unsigned 3 * branches disagree, pinning the unsigned condition codes. volatile defeats 4 * folding; noinline forces real branches. Exit code totals 42. */ 5 __attribute__((noinline)) static int pick_lt(unsigned a, unsigned b) { 6 return a < b ? 10 : 1; 7 } 8 __attribute__((noinline)) static int pick_le(unsigned a, unsigned b) { 9 return a <= b ? 10 : 1; 10 } 11 __attribute__((noinline)) static int pick_gt(unsigned a, unsigned b) { 12 return a > b ? 1 : 11; 13 } 14 __attribute__((noinline)) static int pick_ge(unsigned a, unsigned b) { 15 return a >= b ? 1 : 11; 16 } 17 int test_main(void) { 18 volatile unsigned int a = 3u, b = 0xfffffff0u; 19 int r = 0; 20 r += pick_lt(a, b); /* 3 < big -> 10 */ 21 r += pick_le(a, b); /* 3 <= big -> 10 */ 22 r += pick_gt(a, b); /* 3 > big false -> 11 */ 23 r += pick_ge(a, b); /* 3 >= big false -> 11 */ 24 return r; /* 42 */ 25 }