public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/61559] FAIL: gcc.dg/builtin-bswap-8.c on i686 with -mmovbe
Date: Thu, 04 Sep 2014 11:52:00 -0000	[thread overview]
Message-ID: <bug-61559-4-Ns5XgwvCsM@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-61559-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61559

--- Comment #14 from rguenther at suse dot de <rguenther at suse dot de> ---
On Thu, 4 Sep 2014, ubizjak at gmail dot com wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61559
> 
> --- Comment #12 from Uroš Bizjak <ubizjak at gmail dot com> ---
> (In reply to Uroš Bizjak from comment #11)
> 
> > This one should be:
> > 
> >     (simplify
> >       (bswap (bitop (bswap @0) (bswap @1)))
> >       (bitop @0 @1))
> 
> Oh, we already have this. Please disregard this message.

Not sure - we don't exactly have it.  OTOH I think
that

    (simplify
      (bitop (bswap @0) (bswap @1))
      (bswap (bitop @0 @1)))

is profitable in most cases (not only when wrapped inside another
bswap).  Jakubs concern applies though.

OTOH

    (simplify
      (bswap (bitop (bswap @0) INTEGER_CST@1))
      (bitop @0 (bswap @1)))))

may generally apply (not only to INTEGER_CST 2nd operand to bitop).
The argument would be that one bswap goes away.  But again if
@0 was a memory and @1 is not then this isn't always profitable(?)
(well, the outer bswap goes away).

So merge the restricted first one and this to

   (simplify
     (bswap (bitop:c (bswap @0) @1))
     (bitop @0 (bswap @1)))

?  Thus only one operand of the bitop needs to be a bswap if
there is an outer bswap.  For constant @1 the inner bswap
will be folded away as well as if @1 is a bswap itself.


/* PR61559.  Transforms for gcc.dg/builtin-bswap-8.c  */
(for bswap in BUILT_IN_BSWAP16 BUILT_IN_BSWAP32 BUILT_IN_BSWAP64
  (simplify
    (bswap (bswap @0))
    @0)
  (simplify
    (bswap (bit_not (bswap @0)))
    (bit_not @0))
  (for bitop in bit_xor bit_ior bit_and
    /* This might not be profitable if the inner bswaps are
       free because @0 and @1 are memory operands and the
       target has an instruction for load+bswap.  */
    (simplify
      (bitop (bswap @0) (bswap @1))
      (bswap (bitop @0 @1)))
    (simplify
      (bswap (bitop:c (bswap @0) @1))
      (bitop @0 (bswap @1)))))
>From gcc-bugs-return-461203-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Sep 04 12:02:20 2014
Return-Path: <gcc-bugs-return-461203-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 29421 invoked by alias); 4 Sep 2014 12:02:20 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 29190 invoked by uid 48); 4 Sep 2014 12:02:13 -0000
From: "avi@cloudius-systems.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/63164] New: unnecessary calls to __dynamic_cast
Date: Thu, 04 Sep 2014 12:02:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: avi@cloudius-systems.com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-63164-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-09/txt/msg01037.txt.bz2
Content-length: 1432

https://gcc.gnu.org/bugzilla/show_bug.cgi?idc164

            Bug ID: 63164
           Summary: unnecessary calls to __dynamic_cast
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: avi@cloudius-systems.com

The code

  struct A {
    virtual ~A() {}
  };

  struct B final : A {
    virtual ~B() {}
  };

  B* dc(A* a) {
    return dynamic_cast<B*>(a);
  }

compiles into the following assembly, which contains a call (jump) to
__dynamic_cast:

0000000000000000 <dc(A*)>:
   0:    48 85 ff                 test   %rdi,%rdi
   3:    74 1b                    je     20 <dc(A*)+0x20>
   5:    31 c9                    xor    %ecx,%ecx
   7:    ba 00 00 00 00           mov    $0x0,%edx
            8: R_X86_64_32    typeinfo for B
   c:    be 00 00 00 00           mov    $0x0,%esi
            d: R_X86_64_32    typeinfo for A
  11:    e9 00 00 00 00           jmpq   16 <dc(A*)+0x16>
            12: R_X86_64_PC32    __dynamic_cast-0x4
  16:    66 2e 0f 1f 84 00 00     nopw   %cs:0x0(%rax,%rax,1)
  1d:    00 00 00
  20:    31 c0                    xor    %eax,%eax
  22:    c3                       retq


However, since B is declared final, a simple compare of a's typeinfo with B's
would suffice.  This is a missed optimization opportunity.


  parent reply	other threads:[~2014-09-04 11:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-19  9:16 [Bug rtl-optimization/61559] New: " ubizjak at gmail dot com
2014-06-19  9:18 ` [Bug rtl-optimization/61559] " ubizjak at gmail dot com
2014-06-25  5:13 ` thopre01 at gcc dot gnu.org
2014-06-25  6:22 ` ebotcazou at gcc dot gnu.org
2014-09-03 17:11 ` [Bug tree-optimization/61559] " ubizjak at gmail dot com
2014-09-04  8:56 ` rguenth at gcc dot gnu.org
2014-09-04  9:52 ` jakub at gcc dot gnu.org
2014-09-04  9:59 ` rguenther at suse dot de
2014-09-04 11:36 ` ubizjak at gmail dot com
2014-09-04 11:52 ` rguenther at suse dot de [this message]
2014-09-04 12:08 ` jakub at gcc dot gnu.org
2014-11-13  8:46 ` rguenth at gcc dot gnu.org

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=bug-61559-4-Ns5XgwvCsM@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).