From patchwork Wed Mar 29 17:08:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kelvin Nilsen X-Patchwork-Id: 744878 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 3vtZ416Lplz9s3w for ; Thu, 30 Mar 2017 04:09:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="mE96o6P4"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:cc:date:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=DIwZW kgVk28ZSBy3IXdGZIYBdXPTsM4duX7ukG6+rDDgXSod4KDFLBgLjKN09bJvPYXV4 fsF5KVVuM557HqN5wyYVJCryrNBMm7B8eWdqP/mpvXVxCEuXYLDq96z+g5EZZ8e/ vw5/lum7WSH62AMKN8KMdrgaoOVBlPQnkMPFmo= 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:to :from:subject:cc:date:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=2xMapm65Zz5 5U+TEapKq8JMTvDE=; b=mE96o6P4OGyFbxbbZuZuCUbzDNU/h69YFIYdlxpcov1 9tz2Rv05G4/EhwDCPd0//v6vSmqMkNFVbi4pCynJitq0ZPwsIjrY+ghsONn+1++R 6nXMYwJ4DawB9SvcLlDxBYYCBvtcI7/heiGug57Ipb3Sf/HskjkrjkFsOcVG2Kt0 = Received: (qmail 119179 invoked by alias); 29 Mar 2017 17:08:52 -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 119164 invoked by uid 89); 29 Mar 2017 17:08:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.8 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=Prior, producers, Kelvin, Nilsen X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Mar 2017 17:08:50 +0000 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2TH8nkM096592 for ; Wed, 29 Mar 2017 13:08:50 -0400 Received: from e19.ny.us.ibm.com (e19.ny.us.ibm.com [129.33.205.209]) by mx0a-001b2d01.pphosted.com with ESMTP id 29gfqfv0jn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 29 Mar 2017 13:08:49 -0400 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 29 Mar 2017 13:08:43 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e19.ny.us.ibm.com (146.89.104.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 29 Mar 2017 13:08:40 -0400 Received: from b01ledav03.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2TH8blp44892212; Wed, 29 Mar 2017 17:08:40 GMT Received: from b01ledav03.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B3B49B2052; Wed, 29 Mar 2017 13:08:35 -0400 (EDT) Received: from oc6462846008.ibm.com (unknown [9.80.215.179]) by b01ledav03.gho.pok.ibm.com (Postfix) with ESMTP id 2F696B2050; Wed, 29 Mar 2017 13:08:33 -0400 (EDT) To: gcc-patches@gcc.gnu.org From: Kelvin Nilsen Subject: [PATCH] PR80101: Fix ICE in store_data_bypass_p Cc: rguenther@suse.de Date: Wed, 29 Mar 2017 11:08:36 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17032917-0056-0000-0000-000003240DD1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006872; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000206; SDB=6.00840400; UDB=6.00413629; IPR=6.00618394; BA=6.00005248; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014854; XFM=3.00000013; UTC=2017-03-29 17:08:41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17032917-0057-0000-0000-0000075A1AF1 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-29_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703290144 X-IsSubscribed: yes This problem reports an assertion error when certain rtl expressions which are not eligible as producers or consumers of a store bypass optimization are passed as arguments to the store_data_bypass_p function. The proposed patch returns false from store_data_bypass_p rather than terminating with an assertion error. False indicates that the passed arguments are not eligible for the store bypass scheduling optimization. The patch has been boostrapped without regressions on powerpc64le-unknown-linux-gnu. Is this ok for the trunk? gcc/ChangeLog: 2017-03-29 Kelvin Nilsen PR target/80101 * recog.c (store_data_bypass_p): Rather than terminate with assertion error, return false if either function argument is not a single_set or a PARALLEL with SETs inside. gcc/testsuite/ChangeLog: 2017-03-29 Kelvin Nilsen PR target/80101 * gcc.target/powerpc/pr80101-1.c: New test. Index: gcc/recog.c =================================================================== --- gcc/recog.c (revision 246469) +++ gcc/recog.c (working copy) @@ -3663,9 +3663,12 @@ peephole2_optimize (void) /* Common predicates for use with define_bypass. */ -/* True if the dependency between OUT_INSN and IN_INSN is on the store - data not the address operand(s) of the store. IN_INSN and OUT_INSN - must be either a single_set or a PARALLEL with SETs inside. */ +/* Returns true if the dependency between OUT_INSN and IN_INSN is on + the stored data, false if there is no dependency. Note that a + consumer instruction that loads only the address (rather than the + value) stored by a producer instruction does not represent a + dependency. If IN_INSN or OUT_INSN are not a single_set or a + PARALLEL with SETs inside, this function returns false. */ int store_data_bypass_p (rtx_insn *out_insn, rtx_insn *in_insn) @@ -3701,7 +3704,8 @@ store_data_bypass_p (rtx_insn *out_insn, rtx_insn if (GET_CODE (out_exp) == CLOBBER) continue; - gcc_assert (GET_CODE (out_exp) == SET); + if (GET_CODE (out_exp) != SET) + return false; if (reg_mentioned_p (SET_DEST (out_exp), SET_DEST (in_set))) return false; @@ -3711,7 +3715,8 @@ store_data_bypass_p (rtx_insn *out_insn, rtx_insn else { in_pat = PATTERN (in_insn); - gcc_assert (GET_CODE (in_pat) == PARALLEL); + if (GET_CODE (in_pat) != PARALLEL) + return false; for (i = 0; i < XVECLEN (in_pat, 0); i++) { @@ -3720,7 +3725,8 @@ store_data_bypass_p (rtx_insn *out_insn, rtx_insn if (GET_CODE (in_exp) == CLOBBER) continue; - gcc_assert (GET_CODE (in_exp) == SET); + if (GET_CODE (in_exp) != SET) + return false; if (!MEM_P (SET_DEST (in_exp))) return false; @@ -3734,7 +3740,8 @@ store_data_bypass_p (rtx_insn *out_insn, rtx_insn else { out_pat = PATTERN (out_insn); - gcc_assert (GET_CODE (out_pat) == PARALLEL); + if (GET_CODE (out_pat) != PARALLEL) + return false; for (j = 0; j < XVECLEN (out_pat, 0); j++) { @@ -3743,7 +3750,8 @@ store_data_bypass_p (rtx_insn *out_insn, rtx_insn if (GET_CODE (out_exp) == CLOBBER) continue; - gcc_assert (GET_CODE (out_exp) == SET); + if (GET_CODE (out_exp) != SET) + return false; if (reg_mentioned_p (SET_DEST (out_exp), SET_DEST (in_exp))) return false; Index: gcc/testsuite/gcc.target/powerpc/pr80101-1.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr80101-1.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/pr80101-1.c (working copy) @@ -0,0 +1,22 @@ +/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power6" } } */ +/* { dg-require-effective-target dfp_hw } */ +/* { dg-options "-mcpu=power6 -mno-sched-epilog -Ofast" } */ + +/* Prior to resolving PR 80101, this test case resulted in an internal + compiler error. The role of this test program is to assure that + dejagnu's "test for excess errors" does not find any. */ + +int b; + +void e (); + +int c () +{ + struct + { + int a[b]; + } d; + if (d.a[0]) + e (); +}