From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31962 invoked by alias); 13 Aug 2014 22:02:27 -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 31906 invoked by uid 48); 13 Aug 2014 22:02:21 -0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/53976] [SH] Unnecessary clrt/sett after bt/bf Date: Wed, 13 Aug 2014 22:02: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-Version: 4.8.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: olegendo at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED 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_status cf_reconfirmed_on short_desc everconfirmed Message-ID: In-Reply-To: References: 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-08/txt/msg00896.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53976 Oleg Endo changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2014-08-13 Summary|[SH] Unnecessary clrt after |[SH] Unnecessary clrt/sett |bt |after bt/bf Ever confirmed|0 |1 --- Comment #8 from Oleg Endo --- Another case that could be handled is trying to invert comparisons so that conditional branches from multiple basic blocks have the same T bit value. The following code: static const int table[] = { 0, 1, 2, 3, 4, 9, 10, 42 }; int test (int n) { return *std::lower_bound (std::begin (table), std::end (table), n); } compiled with -m2 -ml -Os: mov.l .L37,r3 mov #8,r1 .L33: cmp/pl r1 bf.s .L36 mov r1,r7 shar r7 mov r7,r2 shll2 r2 add r3,r2 mov.l @r2,r6 cmp/ge r4,r6 <<< bt .L35 <<< mov r2,r3 sett <<< add #4,r3 bra .L33 subc r7,r1 .L35: bra .L33 mov r7,r1 .L36: rts mov.l @r3,r0 .L38: .align 2 .L37: .long __ZN5test5L5tableE In this case 'cmp/ge r4,r6; bt .L35' can be changed to 'cmp/gt r6,r4; bf .L35' and the sett insn can be eliminated.