octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: constant folding


From: John W. Eaton
Subject: Re: constant folding
Date: Sat, 14 Dec 2013 09:09:53 -0600
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.11) Gecko/20121123 Icedove/10.0.11

On 12/13/2013 09:27 AM, John W. Eaton wrote:
On 12/13/2013 07:55 AM, Rik wrote:

The coding pattern

while (1)
...
if (condition)
break
endif
endwhile

is pretty common and uses constants in the conditional.

There should be no effect for that because "1" is already a constant
value that can't be further reduced.

FWIW, I removed the two remaining constant folding functions on the
default branch and timed the test suite before and after and there
seemed to be no significant difference in execution time.  But I don't
think that's a great test.

A place where constant folding might matter is if you write a function
that uses a lot of large matrix "constants" that look like this:

  c1 = [ .. many values .. ];
  c2 = [ .. many values .. ];
  ...

It would be nice to turn these into constants once instead of
evaluating the matrix expression each time the function is called.
But my change would not affect code like this because the only two
constant folding functions that I removed were for unary and binary
expressions, not matrix expressions.  I thought we used to have one
for matrix expressions, but I haven't tried to do the archaeology to
actually find out.  In any case, you can sort of fake it by making
those values persistent, because then they will only be initialized
once.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]