From patchwork Tue Feb 17 21:17:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 440711 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 812EC1401EF for ; Wed, 18 Feb 2015 08:18:18 +1100 (AEDT) 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=VAXR4x1EPkm+vN6l/H558siIxaXTTVE2dZACPKl1e3sTDu fwRgQxOn98ytBe2DQhZnnsEtI8ZZIJSQXHzw9vnGDoQwD6u1axJxIfHe/+MaFSpo y5bufUxcE3AIJXhr1RtbNJCNxAqUANOsFZHeGGz+jZzCkhLj8pWzxyvXvKzPM= 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=jsN/A9gcBF4HJfSIiaMmxJ1wZNI=; b=wA/YeIQnH0VqhL4bAvGv /BeXEV4HrkDUdA9+IZwXrb7T6Hl9DuEpX/214+ENzTSQWrxxeQsPfowKeEcEcjSV XUW2GR/u2CygL18uLuF5+sfxlO74KRN9RKsnP9b/QXMZxaJIQNpvBTM8XtsV9tvQ tfz0XELyPw9KgAB7mdVvBTI= Received: (qmail 28377 invoked by alias); 17 Feb 2015 21:18:10 -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 28365 invoked by uid 89); 17 Feb 2015 21:18:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailout06.t-online.de Received: from mailout06.t-online.de (HELO mailout06.t-online.de) (194.25.134.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 17 Feb 2015 21:18:08 +0000 Received: from fwd22.aul.t-online.de (fwd22.aul.t-online.de [172.20.26.127]) by mailout06.t-online.de (Postfix) with SMTP id 07AFF3A21B6 for ; Tue, 17 Feb 2015 22:18:02 +0100 (CET) Received: from [192.168.0.106] (VagYCaZbghc1TNxmuCk93IAqaBuC29-4qUuATpX-8sRuvoUWD57QiAITayhP1ImZsN@[84.183.240.30]) by fwd22.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-SHA encrypted) esmtp id 1YNpWq-2CsEKW0; Tue, 17 Feb 2015 22:18:00 +0100 Message-ID: <1424207868.14981.110.camel@yam-132-YW-E178-FTW> Subject: [SH][committed] Fix PR 64793 From: Oleg Endo To: gcc-patches Date: Tue, 17 Feb 2015 22:17:48 +0100 Mime-Version: 1.0 X-IsSubscribed: yes Hi, The attached patch fixes PR 64793. For some reason the SH port would pretend that it can do annulled branch true insns in the delay slot of conditional branches, which then got pulled out from the delay slot by the SH reorg pass. I believe there were some misunderstandings regarding the matter. It effectively avoids using conditional branches with delay slots in some cases and as a side effect also prevents stuffing of delay slots of normal branches (which always have a delay slot). Tested with make -k -j2 check RUNTESTFLAGS="--target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}" Committed as r220772. Cheers, Oleg gcc/ChangeLog: PR target/64793 * config/sh/sh.md (cbranch define_delay): Set annulled true branch insn to nil. Adjust comments. gcc/testsuite/ChangeLog: PR target/64793 * gcc.target/sh/pr64793.c: New. * gcc.target/sh/pr51244-20-sh2a.c: Adjust expected cmp/gt insn count. Index: gcc/testsuite/gcc.target/sh/pr64793.c =================================================================== --- gcc/testsuite/gcc.target/sh/pr64793.c (revision 0) +++ gcc/testsuite/gcc.target/sh/pr64793.c (revision 0) @@ -0,0 +1,18 @@ +/* Check that the delay slot of an rts insn is filled, if it follows a cbranch + with an unfilled delay slot, as in: + bt .L3 + mov r7,r0 <<< this insn + rts + nop <<< should go into this delay slot +*/ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "nop" } } */ + +int +test_0 (const char* x, int a, int b, int c) +{ + if (x[a] == 92) + return b; + return c; +} Index: gcc/testsuite/gcc.target/sh/pr51244-20-sh2a.c =================================================================== --- gcc/testsuite/gcc.target/sh/pr51244-20-sh2a.c (revision 220708) +++ gcc/testsuite/gcc.target/sh/pr51244-20-sh2a.c (working copy) @@ -8,7 +8,7 @@ /* { dg-final { scan-assembler-times "nott" 2 } } */ /* { dg-final { scan-assembler-times "cmp/eq" 2 } } */ /* { dg-final { scan-assembler-times "cmp/hi" 4 } } */ -/* { dg-final { scan-assembler-times "cmp/gt" 3 } } */ +/* { dg-final { scan-assembler-times "cmp/gt" 2 } } */ /* { dg-final { scan-assembler-not "not\t" } } */ #include "pr51244-20.c" Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 220708) +++ gcc/config/sh/sh.md (working copy) @@ -593,20 +593,10 @@ [(and (eq_attr "in_delay_slot" "yes") (eq_attr "type" "!pstore,prget")) (nil) (nil)]) -;; Say that we have annulled true branches, since this gives smaller and -;; faster code when branches are predicted as not taken. - -;; ??? The non-annulled condition should really be "in_delay_slot", -;; but insns that can be filled in non-annulled get priority over insns -;; that can only be filled in anulled. - +;; Conditional branches with delay slots are available starting with SH2. (define_delay - (and (eq_attr "type" "cbranch") - (match_test "TARGET_SH2")) - ;; SH2e has a hardware bug that pretty much prohibits the use of - ;; annulled delay slots. - [(eq_attr "cond_delay_slot" "yes") (and (eq_attr "cond_delay_slot" "yes") - (not (eq_attr "cpu" "sh2e"))) (nil)]) + (and (eq_attr "type" "cbranch") (match_test "TARGET_SH2")) + [(eq_attr "cond_delay_slot" "yes") (nil) (nil)]) ;; ------------------------------------------------------------------------- ;; SImode signed integer comparisons