From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10958 invoked by alias); 27 Aug 2012 19:52:02 -0000 Received: (qmail 10945 invoked by uid 22791); 27 Aug 2012 19:52:01 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Aug 2012 19:51:48 +0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/49263] SH Target: underutilized "TST #imm, R0" instruction Date: Mon, 27 Aug 2012 19:52:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: olegendo at gcc dot gnu.org X-Bugzilla-Status: REOPENED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: olegendo at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Status Last reconfirmed Resolution AssignedTo Ever Confirmed Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2012-08/txt/msg01817.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49263 Oleg Endo changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Last reconfirmed| |2012-08-27 Resolution|FIXED | AssignedTo|unassigned at gcc dot |olegendo at gcc dot gnu.org |gnu.org | Ever Confirmed|0 |1 --- Comment #18 from Oleg Endo 2012-08-27 19:51:42 UTC --- Not quite so done, actually. The following example case does not work properly: void test00 (int* x, int xb) { if (! (xb & 128)) x[0] = 0; } -O2 -m4: mov r5,r0 and #128,r0 tst r0,r0 bf .L3 mov.l r0,@r4 .L3: rts nop void test01 (int* x, int xb) { if (! (xb & 0x55)) x[0] = 0; } -O2 -m4: mov r5,r0 and #85,r0 tst r0,r0 bf .L7 mov.l r0,@r4 .L7: rts nop It seems that combine is trying to look for the following patterns: Failed to match this instruction: (set (pc) (if_then_else (ne (zero_extract:SI (reg:SI 5 r5 [ xb ]) (const_int 1 [0x1]) (const_int 7 [0x7])) (const_int 0 [0])) (label_ref:SI 15) (pc))) Failed to match this instruction: (set (pc) (if_then_else (ne (and:SI (reg:SI 5 r5 [ xb ]) (const_int 85 [0x55])) (const_int 0 [0])) (label_ref:SI 15) (pc))) Another case that could see some improvement ... bool test04 (int* x, int xb) { return ! (xb & 0x55); } -O2 -m4 (OK): mov r5,r0 tst #85,r0 rts movt r0 bool test02 (int* x, int xb) { return ! (xb & (1 << 6)); } -O2 -m4 (NG): mov r5,r0 mov #-6,r1 shld r1,r0 xor #1,r0 rts and #1,r0