Related articles |
---|
[8 earlier articles] |
Re: Executing code at compilation time pat@jantar.org (Patryk Zadarnowski) (2010-03-17) |
Re: Executing code at compilation time shreyas76@gmail.com (shrey) (2010-03-16) |
Re: Executing code at compilation time pronesto@gmail.com (Fernando Magno Quintao Pereira) (2010-03-16) |
Re: Executing code at compilation time pat@jantar.org (Patryk Zadarnowski) (2010-03-17) |
Re: Executing code at compilation time gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-03-17) |
Re: Executing code at compilation time bear@sonic.net (Ray) (2010-03-19) |
Re: Executing code at compilation time bear@sonic.net (Ray) (2010-03-19) |
Re: Executing code at compilation time bobduff@shell01.TheWorld.com (Robert A Duff) (2010-03-21) |
Re: Executing code at compilation time torbenm@diku.dk (2010-03-22) |
Re: Executing code at compilation time bear@sonic.net (Ray) (2010-03-22) |
Re: Executing code at compilation time gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-03-23) |
Re: Executing code at compilation time martin@gkc.org.uk (Martin Ward) (2010-03-26) |
From: | Ray <bear@sonic.net> |
Newsgroups: | comp.compilers |
Date: | Fri, 19 Mar 2010 10:45:18 -0700 |
Organization: | Doubtful |
References: | 10-03-038 <31F5149B-7EAB-498D-95B4-DE608FDDD3A5@jantar.org> 10-03-050 |
Keywords: | optimize, analysis |
Posted-Date: | 20 Mar 2010 23:21:05 EDT |
For a pretty complete list of closed forms for finite and infinite
sums that compiler writers can use for a reference page, see:
http://en.wikipedia.org/wiki/List_of_mathematical_series
Compilers can use these rules to lift a lot of mathematical operations
out of loops, eliminating the loop completely if that's all that the
loop was doing.
The OP in this thread was asking about a reduction that clearly
results from gcc using an application of a finite- sum rule.
Some folks think such tricks are "not right" in that they change the
"semantics" of the program by changing its algorithm. Others,
including myself, think that a program that gets the same results
faster and with fewer operations than its source code would lead you
to believe is a better program. If I can write an O(n^2) or even
O(2^n) algorithm and get O(1) runtime performance, I'm not going to
lodge a complaint.
Things get hazier in the event of O(infinity) or non-halting programs
- If you can use an infinite-sum rule to produce an executable that
comes to a halt with the result that the source-code operation "would
have" obtained if run to conclusion on some infinitely-fast computer,
is that an optimization or is that cheating?
Bear
Return to the
comp.compilers page.
Search the
comp.compilers archives again.