[Bug target/39386] [avr] different computation results for O1 and O0 executables
anitha dot boyapati at atmel dot com
gcc-bugzilla@gcc.gnu.org
Mon Aug 23 13:25:00 GMT 2010
------- Comment #8 from anitha dot boyapati at atmel dot com 2010-08-23 13:25 -------
When -O2 is enabled result is 0xFF (255) which is incorrect. The code generated
for the following shift operation:
13: return (left << right);
+000000AB: C004 RJMP PC+0x0005 Relative jump
+000000AC: 0F22 LSL R18 Logical Shift Left
+000000AD: 1F33 ROL R19 Rotate Left Through Carry
+000000AE: 1F44 ROL R20 Rotate Left Through Carry
+000000AF: 1F55 ROL R21 Rotate Left Through Carry
+000000B0: 952A DEC R18 Decrement
+000000B1: F7D2 BRPL PC-0x05 Branch if plus
19: g_6= func_1 (g_6, g_6);
+000000B2: 93200100 STS 0x0100,R18 Store direct to data space
'left' is stored in registers R21:R20:R19:R18 as it is typecasted to uint32_t
type while 'right' is stored in R18. Because of shift logic, R18 becomes 0xFF
in first iteration which is then stored.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
More information about the Gcc-bugs
mailing list