From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22425 invoked by alias); 20 Nov 2011 13:04:59 -0000 Received: (qmail 22413 invoked by uid 22791); 20 Nov 2011 13:04:58 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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; Sun, 20 Nov 2011 13:04:45 +0000 From: "oleg.endo@t-online.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/49263] SH Target: underutilized "TST #imm, R0" instruction Date: Sun, 20 Nov 2011 14:20: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: oleg.endo@t-online.de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: 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: 2011-11/txt/msg02048.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49263 --- Comment #14 from Oleg Endo 2011-11-20 13:04:39 UTC --- With trunk rev 181517 I have observed the following problem, which happens when compiling for -m2*, -m3*, -m4* and -Os: The function compiled with -m2 -Os int test_int64_lowword (long long* x) { return *x & 0xFFFFFFFF ? -20 : -40; } results in the following code: mov #0,r2 ! 42 movsi_i/3 [length = 2] tst r2,r2 ! 44 cmpeqsi_t/1 [length = 2] bf.s .L4 ! 45 branch_false [length = 2] mov.l @(4,r4),r3 ! 12 movsi_i/5 [length = 2] tst r3,r3 ! 46 cmpeqsi_t/1 [length = 2] .L4: bt .L3 ! 14 branch_true [length = 2] mov #-20,r0 ! 4 movsi_i/3 [length = 2] rts nop ! 52 *return_i [length = 4] .L3: rts ! 54 *return_i [length = 2] mov #-40,r0 ! 5 movsi_i/3 [length = 2] When compiled with -O1 or -O2 the high word test is completely eliminated correctly: mov.l @(4,r4),r1 ! 10 movsi_i/5 [length = 2] tst r1,r1 ! 17 cmpeqsi_t/1 [length = 2] bt .L4 ! 18 branch_true [length = 2] mov #-20,r0 ! 4 movsi_i/3 [length = 2] rts nop ! 50 *return_i [length = 4] .L4: rts ! 52 *return_i [length = 2] mov #-40,r0 ! 5 movsi_i/3 [length = 2] I'm not sure whether this is actually related to this PR, but have noticed it with the test cases of this PR. It seems only to happen for comparison-like insns. If I remember correctly, this problem did not exist when I started working on this PR.