// f32lit_test — f32-suffixed literal narrowing, migrated from // test/wcc/964_f32lit_run.c (#5-C4, #104 fold-1). An f32-typed float literal // must narrow to single precision (CVTSD2SS at the materialise site) before the // f32 consumer reads it; pre-fix both stages materialised it as a 64-bit double // in X0 and the downstream MOVSS read the low 4 bytes (garbage; 0.0f for clean // values, which is why 0.0 coincidentally survived). Covers the f32 suffix // (1.0f32) and the no-decimal N_INTLIT-float arm (8f32). Both stages emit // byte-identical asm, so byte-id alone never catches a reintroduction — the T1 // cstage run is the live net; T2 byte-id rides along. package f32lit_test; fn g() f32 = { return 2.5f32; }; @test fn bare_value() void = { let x: f32 = 1.0f32; assert(x: f64 == 1.0); }; @test fn arith() void = { let a: f32 = 1.5f32; let b: f32 = 2.5f32; let s: f32 = a + b; assert(s: f64 == 4.0); }; @test fn return_arith() void = { let r: f32 = g() + 1.5f32; assert(r: i32 == 4); }; @test fn intlit_f32_arm() void = { let y: f32 = 8f32; assert(y: i32 == 8); }; // genuine single-rounding: 2^24 + 1 is NOT representable in f32 and rounds back // to 2^24 (round-to-even); if the add ran in double it would be 16777217.0. @test fn single_round() void = { let big: f32 = 16777216.0f32; let r: f32 = big + 1.0f32; assert(r: f64 == 16777216.0); };