icmp_cset_unsigned_int.c (718B)
1 /* Unsigned 32-bit ordering comparisons materialized to booleans: 2 * < -> cset w, lo (cc) <= -> cset w, ls 3 * > -> cset w, hi >= -> cset w, hs (cs) 4 * volatile operands defeat folding and force unsigned compares. A large value 5 * (0xfffffff0) would be "less" if treated as signed, ensuring the unsigned 6 * condition codes are what's emitted. 7 * Exit code: with a=3, b=0xfffffff0u: lt=1 le=1 gt=0 ge=0 8 * 1*10 + 1*10 + 0*100 + 0*100 + 22 = 42. */ 9 int test_main(void) { 10 volatile unsigned int a = 3u, b = 0xfffffff0u; 11 int lt = (a < b); /* 1 (unsigned) */ 12 int le = (a <= b); /* 1 */ 13 int gt = (a > b); /* 0 */ 14 int ge = (a >= b); /* 0 */ 15 return lt * 10 + le * 10 + gt * 100 + ge * 100 + 22; 16 }