From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 88015 invoked by alias); 21 May 2015 08:46:05 -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 86660 invoked by uid 48); 21 May 2015 08:46:00 -0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/66235] New: [SH] Optimize tst reg,const movrt sequence Date: Thu, 21 May 2015 08:46:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: olegendo at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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 target_milestone cf_gcctarget 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: 2015-05/txt/msg01732.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66235 Bug ID: 66235 Summary: [SH] Optimize tst reg,const movrt sequence Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: olegendo at gcc dot gnu.org Target Milestone: --- Target: sh*-*-* The following example: bool test_00 (unsigned int x) { return (x & 0x1042A) != 0; } compiled with -O2 -m4: mov.l .L3,r1 tst r1,r4 mov #-1,r1 rts negc r1,r0 .L4: .align 2 .L3: .long 0x1042A On non-SH2A there is no movrt insn and a !T -> reg move is done via negc. If the preceeding tst insn uses a constant, the constant can be complemented to avoid the negc and #-1 constant load: mov.l .L3,r1 tst r1,r4 rts movt r0 .L4: .align 2 .L3: .long 0xFFFEFBD5 The tstsi_t splitter could be extended to look for a following movrt insn and optimize it accordingly. The downside of doing this is an increased constant pool size, if the original (non-complemented) constant is used for something else. Moreover, it is only beneficial to do this if there are no other negc #-1 movrt insns which share the #-1 constant. On the other hand, sharing the #-1 constant increases the life time of regs and thus increases reg pressure.