public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: mark@cal005304.student.utwente.nl
To: gcc-gnats@gcc.gnu.org
Subject: optimization/8832: "asm volatile" code is removed
Date: Thu, 05 Dec 2002 14:46:00 -0000	[thread overview]
Message-ID: <20021205224223.25925.qmail@sources.redhat.com> (raw)


>Number:         8832
>Category:       optimization
>Synopsis:       "asm volatile" code is removed
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 05 14:46:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     mark
>Release:        3.2 and beyond (2.95.3 was still ok)
>Organization:
>Environment:

>Description:
I have the following test program:

void t(int v)
{
        asm volatile ("movaps %xmm0,%xmm1");
        if(v&7)
                asm volatile ("movaps %xmm1,%xmm2");
        asm volatile ("movaps %xmm2,%xmm1");
        if(v&7)
                asm volatile ("movaps %xmm3,%xmm2");
        asm volatile ("movaps %xmm4,%xmm1");
}


With gcc-3.2/3.2.1/3.3 (Invoked with: gcc -O3 -c bug.cpp) produces the following code:

   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   0f 28 c8                movaps %xmm0,%xmm1
   6:   f6 45 08 07             testb  $0x7,0x8(%ebp)
   a:   74 09                   je     15 <_Z2tti+0x15>
   c:   0f 28 d1                movaps %xmm1,%xmm2
   f:   0f 28 ca                movaps %xmm2,%xmm1
  12:   0f 28 d3                movaps %xmm3,%xmm2
  15:   0f 28 cc                movaps %xmm4,%xmm1
  18:   5d                      pop    %ebp
  19:   c3                      ret

This is not what I want because "movaps %xmm1,%xmm2" is not done if v==7. Is this a bug, or am I doing something wrong ?

The code used to work correctly, gcc 2.95.3 (same system and options) produces the code below, which does excactly what I expect it to do:

   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   0f 28 c8                movaps %xmm0,%xmm1
   6:   8b 45 08                mov    0x8(%ebp),%eax
   9:   83 e0 07                and    $0x7,%eax
   c:   74 03                   je     11 <tt__Fi+0x11>
   e:   0f 28 d1                movaps %xmm1,%xmm2
  11:   0f 28 ca                movaps %xmm2,%xmm1
  14:   85 c0                   test   %eax,%eax
  16:   74 03                   je     1b <tt__Fi+0x1b>
  18:   0f 28 d3                movaps %xmm3,%xmm2
  1b:   0f 28 cc                movaps %xmm4,%xmm1
  1e:   c9                      leave
  1f:   c3                      ret
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


                 reply	other threads:[~2002-12-05 22:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021205224223.25925.qmail@sources.redhat.com \
    --to=mark@cal005304.student.utwente.nl \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).