From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14820 invoked by alias); 4 Sep 2014 11:52:44 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 14758 invoked by uid 55); 4 Sep 2014 11:52:41 -0000 From: "rguenther at suse dot de" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-09/txt/msg01036.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D61559 --- Comment #14 from 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=3D61559 >=20 > --- Comment #12 from Uro=C5=A1 Bizjak --- > (In reply to Uro=C5=A1 Bizjak from comment #11) >=20 > > This one should be: > >=20 > > (simplify > > (bswap (bitop (bswap @0) (bswap @1))) > > (bitop @0 @1)) >=20 > 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: 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: List-Archive: List-Post: List-Help: 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" 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: 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?id=63164 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(a); } compiles into the following assembly, which contains a call (jump) to __dynamic_cast: 0000000000000000 : 0: 48 85 ff test %rdi,%rdi 3: 74 1b je 20 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 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.