icmp_csel_int.c (828B)
1 /* Several boolean comparison results summed directly into an int, producing a 2 * chain of back-to-back `cmp + cset` (csinc) sequences with no intervening 3 * branch. Exercises the disasm/encode round-trip of consecutive csinc forms. 4 * volatile operands defeat folding. The aarch64 backend lowers a C `?:` to a 5 * branch (covered by ctl_ternary / icmp_branch_*); this case instead pins the 6 * branchless boolean-materialization path. 7 * Exit code: a=4,b=9: 8 * (a<b)=1 (a<=b)=1 (a!=b)=1 (a>b)=0 (a>=b)=0 (a==b)=0 9 * -> sum=3; 3*13 + 3 = 42. */ 10 int test_main(void) { 11 volatile int a = 4, b = 9; 12 int s = 0; 13 s += (a < b); /* 1 */ 14 s += (a <= b); /* 1 */ 15 s += (a != b); /* 1 */ 16 s += (a > b); /* 0 */ 17 s += (a >= b); /* 0 */ 18 s += (a == b); /* 0 */ 19 return s * 13 + 3; /* 3*13 + 3 = 42 */ 20 }