This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Why so bad optimized code ?
- To: Dave Korn <davek-ml at ntlworld dot com>
- Subject: Re: Why so bad optimized code ?
- From: Daniel Berlin <dan at www dot cgsoftware dot com>
- Date: Sun, 25 Mar 2001 01:58:34 -0500 (EST)
- cc: Jamie Lokier <egcs at tantalophile dot demon dot co dot uk>, Mike Stump <mrs at windriver dot com>, amylaar at cambridge dot redhat dot com, denisc at overta dot ru, gcc at gcc dot gnu dot org
> the definition of 'time' to
>
> static struct time_struct * const time
>
> Would it then assume that the value of 'time' does not change and
> therefore not need to reload it each time?
Yes, that works.
In fact, the difference once you add the const, from not using a pointer
at all (IE static struct time_struct foo) , is:
7d6
< .lcomm _foo,16,2
19c18
< la r9,lo16(_foo-L1$pb)(r9)
---
> lwz r9,lo16(_foo-L1$pb)(r9)
27a27
> .lcomm _foo,4,2
Which is what one would expect.
If i remove the const, it reloads it each time.
localhost:~] dberlin% diff a.s b.s
7c7
< .lcomm _foo,16,2
---
> .lcomm _foo,4,2
17,26c17,30
< addis r9,r12,ha16(_foo-L1$pb)
< li r11,5
< la r9,lo16(_foo-L1$pb)(r9)
< li r10,6
< li r8,7
< li r0,8
< stw r0,12(r9)
< stw r11,0(r9)
< stw r10,4(r9)
< stw r8,8(r9)
---
> addis r10,r12,ha16(_foo-L1$pb)
> li r0,5
> la r10,lo16(_foo-L1$pb)(r10)
> li r8,6
> lwz r9,0(r10)
> li r7,7
> li r6,8
> stw r0,0(r9)
> lwz r11,0(r10)
> stw r8,4(r11)
> lwz r9,0(r10)
> stw r7,8(r9)
> lwz r11,0(r10)
> stw r6,12(r11)
[localhost:~] dberlin%
(b.s is the pointered version, a.s is the non-pointered version)
>
> DaveK
>
>