Re: where exactly c++,c fail and Ada gets thru'
- From: Maciej Sobczak <no.spam@xxxxxxxxxxx>
- Date: Fri, 28 Apr 2006 14:27:27 +0200
Martin Krischik wrote:
The point is - of corse - it that the semantic tree of the Ada
compiler contains the information that X will be in the range of (1 ..
5) and then the optimizer can easily calculate that (1 .. 5) + 3 < 10
and then optimize away the check.
The sematinc tree of the C++ will contain the information that X is in
the range of (-2*32 .. +2*32-1) and that is a pretty useless
information to the optimizer.
Except that the optimizer is not limited to use only this information.
With the two example ranges (1..5 and 1..10) the result of inlining will be that the following operations - all operating on the single value - will be placed one after another:
1. compare against 5
2. add 3
3. compare against 10
It doesn't take a rocket scientist to deduce that the third operation has a dead branch and can be therefore eliminated.
Of course, Ada provides more information to the compiler and the more information the compiler has, the wider are the optimization opportunities, therefore languages with richer type systems are easier to optimize. Nobody questions that. But this is very far from the optimization being guaranteed in Ada or impossible in C++ - neither is the case.
--
Maciej Sobczak : http://www.msobczak.com/
Programming : http://www.msobczak.com/prog/
.
- Follow-Ups:
- Re: where exactly c++,c fail and Ada gets thru'
- From: Martin Krischik
- Re: where exactly c++,c fail and Ada gets thru'
- References:
- where exactly c++,c fail and Ada gets thru'
- From: Ananth the Boss
- Re: where exactly c++,c fail and Ada gets thru'
- From: jimmaureenrogers@xxxxxxxxxxxxxxxx
- Re: where exactly c++,c fail and Ada gets thru'
- From: Maciej Sobczak
- Re: where exactly c++,c fail and Ada gets thru'
- From: Martin Krischik
- Re: where exactly c++,c fail and Ada gets thru'
- From: Maciej Sobczak
- Re: where exactly c++,c fail and Ada gets thru'
- From: Martin Krischik
- where exactly c++,c fail and Ada gets thru'
- Prev by Date: Re: Type safety, C++ and code generation
- Next by Date: Re: Type safety, C++ and code generation
- Previous by thread: Re: where exactly c++,c fail and Ada gets thru'
- Next by thread: Re: where exactly c++,c fail and Ada gets thru'
- Index(es):
Relevant Pages
|