<story><title>Why a*a*a*a*a*a cannot be optimized to (a*a*a)*(a*a*a)?</title><url>http://stackoverflow.com/questions/6430448/why-aaaaaa-cannot-be-optimized-to-aaaaaa</url><text></text></story><parent_chain></parent_chain><comment><author>dougws</author><text>When I first read the headline, I definitely thought that was a regular expression which could be &quot;optimized&quot; to a+. I guess I&apos;m more inclined to read &quot;*&quot; as the Kleene operator than as multiplication...</text></comment>
<story><title>Why a*a*a*a*a*a cannot be optimized to (a*a*a)*(a*a*a)?</title><url>http://stackoverflow.com/questions/6430448/why-aaaaaa-cannot-be-optimized-to-aaaaaa</url><text></text></story><parent_chain></parent_chain><comment><author>kaiwetzel</author><text>In numerical analysis class &lt;i&gt;numerical stability&lt;/i&gt; was a major theme[1]. It was very definitely eye-opening how quickly rounding/truncation errors can bite you in seemingly trivial situations!&lt;p&gt;On the other hand, if I have a function that works on parameters in a specified range (say, 0.0 to 1.0) and returns results which is supposed to be correct to a specified accuracy I would &lt;i&gt;love&lt;/i&gt; to have the compiler do all the possible optimizations without having to specify a compiler flag (doing so for, say, just a single function can be quite annoying!). Maybe approaches like Haskell&apos;s type inference will, eventually, produce significantly faster code because they can do things like this?&lt;p&gt;In a somewhat related case, it would be awesome if the compiler recognized properties like associativeness, distributiveness, commutitiveness of composite functions and rearange things optimally for performance. It&apos;s really nice to see so much development in languages and compilers at the moment (llvm, javascript, functional languages like Haskell, etc.) :°)&lt;p&gt;[1] &lt;a href=&quot;http://en.wikipedia.org/wiki/Numerical_stability&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Numerical_stability&lt;/a&gt;</text></comment>