You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6260 Reporter: vbrankov Assigned to:@alainfrisch Status: closed (set by @xavierleroy on 2015-12-11T18:26:26Z) Resolution: fixed Priority: normal Severity: minor Version: 4.01.0 Fixed in version: 4.02.0+dev Category: back end (clambda to assembly) Tags: patch Monitored by:@gasche@hcarty@alainfrisch
Bug description
This code comes with a ton of unnecessary boxing:
let () =
let x = 0.5 in
let w =
let y =
let z = x +. x in
z +. z
in
y +. y
in
let u = w +. w in ()
Why does it matter? This means that short inlined functions which return float values do unnecessary boxing. This little change hopefully gets rid of it:
I'm sorry, there's no way for me to modify the "Summary" and I now see it's too long. Also, I think that the patch should be worked on, because I think it should handle things other than Ulet, for instance Usequence.
Original bug ID: 6260
Reporter: vbrankov
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:26:26Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.01.0
Fixed in version: 4.02.0+dev
Category: back end (clambda to assembly)
Tags: patch
Monitored by: @gasche @hcarty @alainfrisch
Bug description
This code comes with a ton of unnecessary boxing:
let () =
let x = 0.5 in
let w =
let y =
let z = x +. x in
z +. z
in
y +. y
in
let u = w +. w in ()
Why does it matter? This means that short inlined functions which return float values do unnecessary boxing. This little change hopefully gets rid of it:
Index: asmcomp/cmmgen.ml
--- asmcomp/cmmgen.ml (revision 14338)
+++ asmcomp/cmmgen.ml (working copy)
@@ -1122,7 +1122,7 @@
| Boxed_float
| Boxed_integer of boxed_integer
-let is_unboxed_number = function
+let rec is_unboxed_number = function
Uconst(Const_base(Const_float f), _) ->
Boxed_float
| Uprim(p, _, _) ->
@@ -1164,6 +1164,7 @@
| Pbbswap bi -> Boxed_integer bi
| _ -> No_unboxing
end
| _ -> No_unboxing
let subst_boxed_number unbox_fn boxed_id unboxed_id box_chunk box_offset exp =
The assembly before and after:
camlX87__entry:
.cfi_startproc
subq $8, %rsp
.cfi_adjust_cfa_offset 8
.L100:
movsd .L101(%rip), %xmm0
addsd %xmm0, %xmm0
call caml_alloc3@PLT
.L102:
leaq 8(%r15), %rax
movq $1277, -8(%rax)
addsd %xmm0, %xmm0
movsd %xmm0, (%rax)
leaq 16(%rax), %rbx
movq $1277, -8(%rbx)
movsd (%rax), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rbx)
movsd (%rbx), %xmm0
addsd (%rbx), %xmm0 cc-ed
movq $1, %rax
movq $1, %rax
addq $8, %rsp
.cfi_adjust_cfa_offset -8
ret
.cfi_adjust_cfa_offset 8
.cfi_endproc
camlX87__entry:
.cfi_startproc
.L100:
movsd .L101(%rip), %xmm0
addsd %xmm0, %xmm0
addsd %xmm0, %xmm0
addsd %xmm0, %xmm0
addsd %xmm0, %xmm0
movq $1, %rax
movq $1, %rax
ret
.cfi_endproc
The text was updated successfully, but these errors were encountered: