Re: Optimization o2 vs o3 issue

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

 



Maybe there's something obvious here - you say that count goes from 0 .. 7, and the shift amount is (8+count)*8, or from 0 to 120?? You're far beyond a reasonable shift count, and perhaps the compiler is seeing that. And with volatile, it actually does
the shifts, and your cpu does some masking with the shift amount.

What DO you want dout to be after shifting right 120 bits? What are you calling the "right" answer?

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
#Line1# dout.data[15 - count] = (uint8_t)(((long long unsigned int)(*(soc_cpr_dbusdataout_->sig_value_upper)) & (mask << ((8+count)*8)))>>((8+count)*8)); #Line2# 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. 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.
Should it be logged as bug in gcc somewhere ?

-Manish





[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