lean4-htt/tests/lean/run/10443.lean
Henrik Böving 85ce814689
fix: constant folding for UIntX (#10495)
This PR fixes constant folding for UIntX in the code generator. This
optimization was previously simply dead code due to the way that uint
literals are encoded.
2025-09-22 10:06:24 +00:00

28 lines
659 B
Text

/-!
This test is a regression for issue #10443 where the RC analysis would wrongfully insert ref counts
for large `UInt64` constants.
-/
def gSize : UInt64 := 0x8000000000000000
/--
trace: [Compiler.IR] [result]
def mwe (x_1 : u64) : u64 :=
let x_2 : u64 := 9223372036854775808;
let x_3 : u64 := UInt64.add x_2 x_1;
ret x_3
def mwe._boxed (x_1 : tobj) : tobj :=
let x_2 : u64 := unbox x_1;
dec x_1;
let x_3 : u64 := mwe x_2;
let x_4 : tobj := box x_3;
ret x_4
-/
#guard_msgs in
set_option trace.compiler.ir.result true in
def mwe (y : UInt64) : UInt64 :=
let x := gSize
let y := y
x + y