Floating-pointer number optimization in LLVM
Pen:
sum = \(x number, i number) number {
if i == 0 {
x
} else {
sum(x + i, i - 1)
}
}
LLVM:
else.i:
%.tr47.i.int = phi i32 [ 100000000, %phi6 ], [ %.int, %else.i ]
%.tr36.i = phi double [ 0.000000e+00, %phi6 ], [ %14, %else.i ]
%indvar.conv = sitofp i32 %.tr47.i.int to double
%14 = fadd double %.tr36.i, %indvar.conv
%.int = add nsw i32 %.tr47.i.int, -1
%15 = icmp eq i32 %.int, 0
br i1 %15, label %_fmm_aa7.exit, label %else.i