kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

icmp_cset_eq_int.c (466B)


      1 /* icmp == on 32-bit ints materialized to a boolean (cmp + cset eq). volatile
      2  * operands defeat constant folding so the compare and cset are really emitted.
      3  * Exercises the disasm/encode round-trip of `cmp w,w` + `cset w, eq`.
      4  * Exit code: (5==5)*40 + (5==6)*100 + 2 = 40 + 0 + 2 = 42. */
      5 int test_main(void) {
      6   volatile int a = 5, b = 5, c = 6;
      7   int eq_true = (a == b);  /* 1 */
      8   int eq_false = (a == c); /* 0 */
      9   return eq_true * 40 + eq_false * 100 + 2;
     10 }