boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

085-i32-u32-eq.scm (851B)


      1 ;; tests/cc-cg/85-i32-u32-eq.scm — comparing int -3 with unsigned 4294967293
      2 ;; via the usual arithmetic conversions: both operands take the unsigned
      3 ;; common type so the comparison must hold (C 6.3.1.8).
      4 ;;
      5 ;; cg-arith-conv currently relabels the i32 operand to u32 without
      6 ;; rewriting its canonical 64-bit slot form (still sign-extended
      7 ;; 0xFFFF...FFFD), while %li(t1, 4294967293) materializes the literal
      8 ;; as 0x00000000FFFFFFFD. cmpset_eq compares full 64 bits and reports
      9 ;; unequal. Correct cg makes the operand carry the canonical u32 form
     10 ;; for u32-typed operands.
     11 
     12 (let ((cg (cg-init)))
     13   (cg-fn-begin cg "main" '() %t-i32)
     14   (cg-push-imm cg %t-i32 -3)
     15   (cg-promote cg)
     16   (cg-push-imm cg %t-u32 4294967293)
     17   (cg-promote cg)
     18   (cg-arith-conv cg)
     19   (cg-binop cg 'eq)
     20   (cg-return cg)
     21   (cg-fn-end cg)
     22   (write-bv-fd 1 (cg-finish cg)))