This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Incorrect movem optimization on m68k
- To: Alan Modra <alan at SPRI dot Levels dot UniSA dot Edu dot Au>
- Subject: Re: Incorrect movem optimization on m68k
- From: Tony Mantler <eek at escape dot ca>
- Date: Thu, 2 Mar 2000 11:09:42 -0600
- Cc: gcc-bugs at gcc dot gnu dot org
- Organisation: Judean People's Front; Department of Whips, Chains, Thumb-Screws, Six Tons of Whipping Cream, the Entire Soprano Section of the Mormon Tabernacle Choir and Guest Apperances of Eva Peron aka Eric Conspiracy Secret Laboratories
- References: <v04003a00b4e3f81e413a@[24.66.67.189]>
At 6:22 AM -0600 3/2/2000, Alan Modra wrote:
>On Thu, 2 Mar 2000, Tony Mantler wrote:
>
>> asm volatile ("moveml %1/%2/%3/%4,%0@-"
>> : "=a" (out)
>> : "d" (0), "d" (0), "d" (0), "d" (0), "0" (&stack[4]));
>
>You haven't told gcc that there is anything wrong with putting the asm
>input `d' operands in the same register. Since all the `d' inputs are the
>same value, gcc assigns them (quite correctly) to the same register.
Ah, I see, it's optimizing away registers. That makes a little more sense.
>Hrrm, I don't have a 68k gcc compiler handy to check this, but something
>like the following should work.
>
>int t1,t2,t3,t4;
>asm volatile ("moveml %1/%2/%3/%4,%0@-"
> : "=a" (out), "=d" (t1), "=d" (t2), "=d" (t3), "=d" (t4)
> : "1" (0), "2" (0), "3" (0), "4" (0), "0" (&stack[4]));
Cool, that generates much more agreeable asm:
800003a8 <main>:
800003a8: 4e56 ffec linkw %fp,#-20
800003ac: 48e7 3020 moveml %d2-%d3/%a2,%sp@-
800003b0: 486e ffec pea %fp@(-20)
800003b4: 4879 8000 042e pea 8000042e <_IO_stdin_used+0x4>
800003ba: 45f9 8000 02e4 lea 800002e4 <_init+0x6c>,%a2
800003c0: 4e92 jsr %a2@
800003c2: 4280 clrl %d0
800003c4: 41ee fffc lea %fp@(-4),%a0
800003c8: 2600 movel %d0,%d3
800003ca: 2400 movel %d0,%d2
800003cc: 2200 movel %d0,%d1
800003ce: 48e0 f000 moveml %d0-%d3,%a0@- <-- ** yay! **
800003d2: 2f08 movel %a0,%sp@-
800003d4: 4879 8000 042e pea 8000042e <_IO_stdin_used+0x4>
800003da: 4e92 jsr %a2@
800003dc: 4cee 040c ffe0 moveml %fp@(-32),%d2-%d3/%a2
800003e2: 4e5e unlk %fp
800003e4: 4e75 rts
800003e6: 4e75 rts
Though I'm sure I could do with only 1 rts. (is that for alignment or ?)
By the way, where is the syntax for asm inlines documented? They seem to
have a rather obscure format.
Cheers - Tony :)
--
Tony Mantler Renaissance Nerd Extraordinaire eek@escape.ca
Winnipeg, Manitoba, Canada http://www.escape.ca/~eek