This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Why so bad optimized code ?


> 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
> 
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]