From patchwork Fri Dec 6 10:01:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 297694 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E697A2C00A1 for ; Fri, 6 Dec 2013 21:02:08 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:date:content-type:mime-version; q= dns; s=default; b=b9DJFGerQ97mlQugCUF1ypoWEfhod08l/BFZ1hitrVMgvd tE8lVosIUA1wle08JboE7aDgksyxdttNKXttY3y9OxK1FOEO9TIX/2ZY6T4aQQRA nf8U5Ijyf1E2wz5tGBUqK0ebKpPD/ywxicgPIU+5s2uKy6WB2+XZ99xj7v4Vo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:date:content-type:mime-version; s= default; bh=wMDCKio2ysnit7oWqZSbxSCdHYw=; b=Y4pNrNzYFFuYUzjQ4+O0 d4cCo9QoHLAdFqbg5oOcpXv0Zcg2m+P9TJailIrhDRzJONZKLeF6UiKWvy9OFd3+ zh/Bjp0HbftyijBzEVEoYQxjScplCtMBoYxdQFQdcC+fB4Ut0Z+PScZdBQHqxfWS 0UyO18fpeS21vn/vk2YL5mw= Received: (qmail 14353 invoked by alias); 6 Dec 2013 10:02:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 14343 invoked by uid 89); 6 Dec 2013 10:02:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-HELO: mailout11.t-online.de Received: from Unknown (HELO mailout11.t-online.de) (194.25.134.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Dec 2013 10:02:00 +0000 Received: from fwd07.aul.t-online.de (fwd07.aul.t-online.de ) by mailout11.t-online.de with smtp id 1VosEA-0008D4-Ai; Fri, 06 Dec 2013 11:01:42 +0100 Received: from [192.168.0.103] (X6X40OZGrh+n2V8WGwZ1fedXnYpcw6bw10ZoHN6HhdPDC10ByrpAzkhvJNua-SHZK-@[87.155.245.172]) by fwd07.t-online.de with esmtp id 1VosEA-271ns00; Fri, 6 Dec 2013 11:01:42 +0100 Message-ID: <1386324094.14008.79.camel@yam-132-YW-E178-FTW> Subject: [SH, 4.8] Fix PR 59343 From: Oleg Endo To: gcc-patches Date: Fri, 06 Dec 2013 11:01:34 +0100 Mime-Version: 1.0 X-IsSubscribed: yes Hello, This fixes a bug on the 4.8 branch which was initially described in PR 51244 comment 59 and also reported as a separate PR 59343. Tested with make -k check RUNTESTFLAGS="--target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}" and no new failures. OK for 4.8? Cheers, Oleg gcc/ChangeLog: PR target/51244 PR target/59343 * config/sh/sh.md (*cbranch_t): Check that there are no labels between the s1 insn and the testing insn. Remove REG_DEAD note from s1 insn. testsuite/ChangeLog: PR target/51244 PR target/59343 * gcc.target/sh/pr51244-19.c: Adjust test case. Index: gcc/testsuite/gcc.target/sh/pr51244-19.c =================================================================== --- gcc/testsuite/gcc.target/sh/pr51244-19.c (revision 205675) +++ gcc/testsuite/gcc.target/sh/pr51244-19.c (working copy) @@ -22,11 +22,16 @@ unwanted sequences. Thus, if we see any movt insns, something is not working as expected. This test requires -O2 because the T bit stores in question will be eliminated in additional insn split passes after - reload. */ + reload. + + Notice: When this test case was initially added, the T bit optimization + was buggy and this test case resulted in wrong code. The movt + instructions actually have to be present in this case to get + correct code. */ /* { dg-do compile { target "sh*-*-*" } } */ /* { dg-options "-O2" } */ /* { dg-skip-if "" { "sh*-*-*" } { "-m5*" } { "" } } */ -/* { dg-final { scan-assembler-not "movt" } } */ +/* { dg-final { scan-assembler "movt" } } */ struct request { Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 205675) +++ gcc/config/sh/sh.md (working copy) @@ -8427,11 +8427,9 @@ while (true) { - /* It's not safe to go beyond the current basic block after reload. */ set_of_reg s1 = sh_find_set_of_reg (tested_reg, s0.insn, - reload_completed - ? prev_nonnote_insn_bb - : prev_nonnote_insn); + prev_nonnote_insn); + if (s1.set_src == NULL_RTX) break; @@ -8449,15 +8447,25 @@ continue; } - /* It's only safe to remove the testing insn if the T bit is not - modified between the testing insn and the insn that stores the - T bit. Notice that some T bit stores such as negc also modify - the T bit. */ - if (modified_between_p (get_t_reg_rtx (), s1.insn, testing_insn) - || modified_in_p (get_t_reg_rtx (), s1.insn)) - operands[2] = NULL_RTX; + /* It's only safe to remove the testing insn if the T bit is not + modified between the testing insn and the insn that stores the + T bit. Notice that some T bit stores such as negc also modify + the T bit. */ + if (modified_between_p (get_t_reg_rtx (), s1.insn, testing_insn) + || modified_in_p (get_t_reg_rtx (), s1.insn) + || !no_labels_between_p (s1.insn, testing_insn)) + operands[2] = NULL_RTX; + else + { + /* If the insn that sets the tested reg has a REG_DEAD note on + the T bit remove that note since we're extending the usage + of the T bit. */ + rtx n = find_regno_note (s1.insn, REG_DEAD, T_REG); + if (n != NULL_RTX) + remove_note (s1.insn, n); + } - break; + break; } if (operands[2] == NULL_RTX)