https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86635
Bug ID: 86635
Summary: [avr] Miscompilation with __memx and libgcc float
function __gtsf2
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: saaadhu at gcc dot gnu.org
Target Milestone: ---
A libgcc float function invocation (_e.g. _gtsf2) with one of its arguments in
the __memx address space is miscompiled - that argument is never loaded/passed
to the function.
In the below case, a does not get loaded from memory, and it's value is not set
in the argument registers.
$ cat test.c
extern const __memx float a;
extern const float b;
int diff () { return a > b; }
$ avr-gcc -Os -mmcu=atmega328p -S -o -
diff:
push r28
push r29
/* prologue: function */
/* frame size = 0 */
/* stack size = 2 */
ldi r28,lo8(1)
ldi r29,0
lds r18,b
lds r19,b+1
lds r20,b+2
lds r21,b+3
call __gtsf2
cp __zero_reg__,r24
brlt .L2
ldi r29,0
ldi r28,0
.L2:
movw r24,r28
/* epilogue start */
pop r29
pop r28
ret