Re: Optimization o2 vs o3 issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Manish Baphna wrote:

> A quick update, Though I couldn't really found real issue , I found
> an interesting solution which worked. magic word is 'volatile' :)
>
>
> Original two lines were
>
>   dout.data[15 - count]
>     = (uint8_t)(((long long unsigned int)
> 		 (*(soc_cpr_dbusdataout_->sig_value_upper))
> 		 & (mask << ((8+count)*8)))>>((8+count)*8));
>
>   cout << "Dout data " << (uint64_t)((dout.data)[15-count]) << endl;
>
> What I did was inserting this line just above Line#1
> volatile uint32_t shift_val = ((8+count)*8) ;
> and used this in above Line#1 , and then I removed Line#2 and this time it worked.
>  ( First I tried without using 'volatile' and it didn't help )
> Another workaround that did the same thing was making
> count as volatile.

Interesting.  Is this a multi-threaded application?  The other
possibility is an array bounds overflow.

> These two lines are in for loop which goes for count = 0 to 7 , I
> don't know why compiler is being lazy here to read it everytime
> unless I make it volatile.

The compiler isn't supposed to read it everytime unless you make it
volatile.

> Should it be logged as bug in gcc somewhere ?

Not until you can come up with a test cases that someone else can run.

Andrew.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux