bebbo / gcc

Bebbo's gcc-6-branch for m68k-amigaos
GNU General Public License v2.0
33 stars 11 forks source link

fsmoved (aN)+ codegen issue #231

Closed mras0 closed 3 months ago

mras0 commented 3 months ago

Hi Bebbo,

Thanks for all your hard work. Ran into a small issue (CEX link: http://franke.ms/cex/z/8EEW9v) reproduced below:

struct s {
   double a;
   float b;
};

struct d {
    float a, b;
};

void copy(struct d* d, const struct s* s)
{
    d->a = s->a;
    d->b = s->b;
}

Compiled with m68k-amigaos-gcc -c -O3 -mregparm=4 -m68040 -O3 -mhard-float -fomit-frame-pointer Produces this code:

   0:   f219 5440       fsmoved (a1)+,fp0
   4:   f218 6400       fmove.s fp0,(a0)+
   8:   20a9 0004       move.l 4(a1),(a0)

First part is fine, but the last move.l shouldn't have the 4 displacement. Looks like the compiler somehow "thinks" fsmoved only increments a1 by 4 (while it's actually 8 since it's a double).

Don't know enough about GCC internals to know where to look though :(

bebbo commented 3 months ago

please test

mras0 commented 3 months ago

Thanks for the quick fix! I can confirm that it fixes it, and also from where the repro was extracted.