public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/49583] New: Reloading stack operands in the wrong order, so needs to insert fxch
@ 2011-06-29 18:18 sgunderson at bigfoot dot com
  2011-06-30 10:08 ` [Bug target/49583] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: sgunderson at bigfoot dot com @ 2011-06-29 18:18 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49583

           Summary: Reloading stack operands in the wrong order, so needs
                    to insert fxch
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sgunderson@bigfoot.com


Created attachment 24638
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24638
Minimal testcase

Hi,

It seems that when generating x87 code, GCC sometimes reloads items from the
stack in the wrong order, and then goes to great lengths to swap them around. I
have an example with six loads and six fxch instructions, but attached is a
minimal example. Compiling with "gcc version 4.6.1 (Debian 4.6.1-1)" as
follows:

pannekake:~> gcc-4.6 -m32 -Wall -O2 -march=pentium3 -c fxch.c

The odd sequence is around this:

  41:    d9 44 24 48              flds   0x48(%esp)
  45:    dd 5c 24 08              fstpl  0x8(%esp)
  49:    dd 14 24                 fstl   (%esp)
  4c:    d9 5c 24 10              fstps  0x10(%esp)
  50:    e8 fc ff ff ff           call   51 <process+0x51>
  55:    d9 5c 24 1c              fstps  0x1c(%esp)
  59:    d9 44 24 1c              flds   0x1c(%esp)
  5d:    d9 44 24 10              flds   0x10(%esp)
  61:    d9 c9                    fxch   %st(1)
  63:    d9 1c b7                 fstps  (%edi,%esi,4)
  66:    46                       inc    %esi
  67:    39 ee                    cmp    %ebp,%esi

In particular, why did it use fstps immediately followed by flds of the same
value? And if it really wants to reload (in my more complex example, it really
needs to), why not just do the loads in the right order from the start instead
of doing the fxch?


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-07-03 17:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-29 18:18 [Bug tree-optimization/49583] New: Reloading stack operands in the wrong order, so needs to insert fxch sgunderson at bigfoot dot com
2011-06-30 10:08 ` [Bug target/49583] " rguenth at gcc dot gnu.org
2011-07-03 14:39 ` ubizjak at gmail dot com
2011-07-03 17:20 ` sgunderson at bigfoot dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).