https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87376
Bug ID: 87376 Summary: [avr] Miscompilation with __memx and long long addition Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: saaadhu at gcc dot gnu.org Target Milestone: --- Attempting to add a __memx long long with a long long in the generic address space results in wrong code. 2 of the 8 bytes of the variable in __memx do not get loaded at all. Compiling the below code with -Os -mmcu=avr51 extern const __memx long long a; extern const long long b; long long add (void) { return a + b;} results in the following assembly output. Note the missing loads for a+3 and a+4. <snip> ldi r24,lo8(a) ldi r25,hi8(a) ldi r26,hlo8(a) movw r30,r24 mov r21,r26 call __xload_1 mov r18,r22 ldi r24,lo8(a+1) ldi r25,hi8(a+1) ldi r26,hlo8(a+1) movw r30,r24 mov r21,r26 call __xload_1 mov r19,r22 ldi r24,lo8(a+2) ldi r25,hi8(a+2) ldi r26,hlo8(a+2) movw r30,r24 mov r21,r26 call __xload_1 mov r20,r22 ldi r24,lo8(a+5) ldi r25,hi8(a+5) ldi r26,hlo8(a+5) movw r30,r24 mov r21,r26 call __xload_1 mov r23,r22 ldi r24,lo8(a+6) ldi r25,hi8(a+6) ldi r26,hlo8(a+6) movw r30,r24 mov r21,r26 call __xload_1 mov r24,r22 ldi r25,lo8(a+7) mov r12,r25 ldi r25,hi8(a+7) mov r13,r25 ldi r25,hlo8(a+7) mov r14,r25 movw r30,r12 mov r21,r14 call __xload_1 mov r25,r22 lds r10,b lds r11,b+1 lds r12,b+2 lds r13,b+3 lds r14,b+4 lds r15,b+5 lds r16,b+6 lds r17,b+7 call __adddi3 </snip>