The below mail was not sent to the mailing list, so I do it again.
---------- Forwarded message ----------
From: Roman Marynchak <roman.marynchak@...>
Subject: Re:How smart do we want Python (the compiler) to be?
Cc: sbcl-devel@..., Roman Marynchak <
That three issues were reported by me, so I hope that I can put my two
cents here. I have a little experience with SBCL Internals, but on my daily
job I develop a bytecode compiler and a virtual machine for it, so I have
some expertise in the field. And I should say that SBCL compiler may be
extended with some additional stages to handle these missing optimizations,
and I believe that it is not _very_ hard to implement. These optimizations
may be done during IR1 phases, I guess.
However, I see that CLISP has all the same loop optimizations issues, and it
makes me think that maybe it is normal for a CL compiler? But there are some
advanced loop optimizations (see Allen and Kennedy) which are not so easy to
make by hand, and it is probably better to have them in a compiler. Thanks
to the rich Lisp syntax, I can think about a lot of them.
Regarding a "big rewrite", I think that it is not so bad as it may seem to
be at a first sight. Recall that (AFAIK):
- Python has no SSA
- Python has no peephole optimizer
- Python has no implicit parallelism (here may be some discussion, maybe it
is not needed)
- No loop optimizations
- Not sure whether it has vectorization or not for CPUs which support it
- [Add your own claim here]
I don't insist on any rewrites, however (and I have no vote here at all,
since I am not a member of sbcl-devel at this time). But I think that any
optimizing compiler should handle at least that childish examples which were
reported in that three issues.
On Wed, Apr 7, 2010 at 7:52 AM, Roman Marynchak
> Regarding a "big rewrite", I think that it is not so bad as it may seem to
> be at a first sight. Recall that (AFAIK):
> - Python has no SSA
> - Python has no implicit parallelism (here may be some discussion, maybe it
> is not needed)
> - No loop optimizations
> - Not sure whether it has vectorization or not for CPUs which support it
These don't constitute "big rewrites" in your book? Perhaps the last
three are just bolting on optimizations--big ones, but just extra
passes--but at least doing SSA form would mean throwing out a good
chunk of the compiler and starting over, SSA-is-CPS relationships
> I don't insist on any rewrites, however (and I have no vote here at all,
> since I am not a member of sbcl-devel at this time). But I think that any
> optimizing compiler should handle at least that childish examples which were
> reported in that three issues.
I checked three mature optimizing compilers (one open source, two
commercial) with your three examples translated to C. Out of those
nine cases, only one was optimized (removal of an empty loop). So at
least a couple of compiler writers and vendors would disagree with you
on the necessity of said optimizations. I would not be surprised to
discover the same results with a wider sample of compilers for C or
implementations for other languages.