[MLton] Constant folding vector expressions

skaller skaller at users.sourceforge.net
Mon Sep 17 00:44:28 PDT 2007


On Mon, 2007-09-17 at 09:08 +0300, Vesa Karvonen wrote:
> Is there some reason why vector expressions are not subject to
> constant folding? 

> The probably incorrect part is "WordSize.cint ()".  The code shouldn't
> use the size of cint (C-integers), but the size of SML integers,
> Int.int, but I couldn't see where to find the correct size.

I guess the usual issue with constant folding needs to be checked:
if you're cross compiling say on a 32 bit machine for a 64 bit target,
the compiler has to use the target mathematics, eg 64 bit integers,
to do the folding (otherwise the results will differ from that which
would be produced at run time).

This is a real biatch for Felix, since the compiler doesn't KNOW
the target, in fact as a matter of principle it isn't allowed 
to know because the output is required to be target independent C++.
So I do all the integer constant folding with infinite 
precision integers by specification, even if the results would 
not agree with a run time calculation.

But it seems this is the very issue you raise here.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net



More information about the MLton mailing list