#1647: Constant folding on num type
--------------------+-------------------------------------------------------
Reporter: grom | Owner: plobsing
Type: bug | Status: new
Priority: normal | Milestone:
Component: imcc | Version: 2.3.0
Severity: medium | Keywords: constant folding
Lang: | Patch:
Platform: |
--------------------+-------------------------------------------------------
Comment(by plobsing):
Replying to [comment:1 bacek]:
> I do suspect that IMCC uses {{{float}}} instead of {{{double}}} for
constant folding. There is 2 major problems:
> 0. Using {{{float}}} for constant folding is... weird.
IMCC uses registers and invokes ops directly to fold. Whatever you use for
FLOATVAL is what is used for folding.
> 1. IMCC without -On flag shouldn't optimize at all (apart from necessary
constant folding for non-existent ops)
This is exactly what it is doing. mul_n_nc_nc does not exist. I'm fairly
certain we don't have *any* ops with all constant arguments. This is
likely a vestige from when our optimizer was held in high regard (btw, I
recently ran -01 as a runcore test and it failed remarkably few tests).
What is going wrong is that DAY_PER_YEAR isn't being symbolic-constant-
expanded before evaluation as a float (the string "DAYS_PER_YEAR" has a
float value of 0). For reference, this works:
{{{
.sub "main"
$N0 = 2.96460137564761618e-03 * 365.24
say $N0
.end
}}}
--
Ticket URL: <https://trac.parrot.org/parrot/ticket/1647#comment:2>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets