From patchwork Fri Apr 13 20:37:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sawdey X-Patchwork-Id: 898104 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-476370-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="oFT8vvQq"; dkim-atps=neutral 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 40N8hz4L99z9ryk for ; Sat, 14 Apr 2018 06:37:23 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:date:content-type:mime-version:message-id; q=dns; s=default; b=XxI5Eyl/ZDMRPRdumW5wY3oaPE6Ofi4KYesdOypVRKP kpBH+osq3ctVBGqY+uLLEzG/I+XOpY8u9Wmj4FdPt+XEWH1e2UlGuytgv96A2dfW oMBAn/YNKEQmucVDvr3P/2lDoesnJu0VJ52xOC0qXR0xpIVZQYRZANCavtqENpCY = 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 :subject:from:to:cc:date:content-type:mime-version:message-id; s=default; bh=MDiUU7zKMkz0QtZG91812Q7AHA0=; b=oFT8vvQq5yf8SGnLr vB5kZJcSBoRI+aSQ2k8i5kN52g9FFSrX2fZ30ppWJO4t/H8O6r+1yVgwNDb4E3lX rERzPjJci+sM8ICyxEDCtksNihdnfruacKw6fcy3scsIEdytrbXImecOgQcG2p/9 ow0vNPJQyIvPbNuCvmjpFIF6cQ= Received: (qmail 110641 invoked by alias); 13 Apr 2018 20:37:16 -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 110616 invoked by uid 89); 13 Apr 2018 20:37:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, 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=aaron, Aaron, sawdey, sk:acsawde 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; Fri, 13 Apr 2018 20:37:14 +0000 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3DKZQKt115493 for ; Fri, 13 Apr 2018 16:37:13 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hb2hw2y8f-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Fri, 13 Apr 2018 16:37:12 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 13 Apr 2018 14:37:12 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 13 Apr 2018 14:37:10 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3DKb9PM9896376; Fri, 13 Apr 2018 13:37:09 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A25D8C6037; Fri, 13 Apr 2018 14:37:09 -0600 (MDT) Received: from ragesh3a (unknown [9.85.133.183]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 17B44C603C; Fri, 13 Apr 2018 14:37:08 -0600 (MDT) Subject: [PATCH] rs6000 PR83660 fix ICE with vec_extract From: Aaron Sawdey To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool , David Edelsohn Date: Fri, 13 Apr 2018 15:37:08 -0500 Mime-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18041320-0004-0000-0000-000013F34BAA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008851; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000257; SDB=6.01017454; UDB=6.00518918; IPR=6.00796691; MB=3.00020564; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-13 20:37:11 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041320-0005-0000-0000-000086DF5040 Message-Id: <1523651828.6245.26.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-13_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804130191 X-IsSubscribed: yes Per the discussion on the 83660, I've come to a minimal patch to prevent this. Basically marking the vec_extract tree as having side effects later makes sure that it gets all the cleanup points it needs so that gimplify_cleanup_point_expr () is happy. Also because vec_insert puts a MODIFY_EXPR in there, it has side effects and this problem will not occur. Doing bootstrap/regtest on ppc64le with -mcpu=power7 since that is where this issue arises. OK for trunk if everything passes? Thanks, Aaron 2018-04-13 Aaron Sawdey PR target/83660 * config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): Mark vec_extract expression as having side effects to make sure it gets a cleanup point. 2018-04-13 Aaron Sawdey PR target/83660 * gcc.target/powerpc/pr83660.C: New test. Index: config/rs6000/rs6000-c.c =================================================================== --- config/rs6000/rs6000-c.c (revision 259353) +++ config/rs6000/rs6000-c.c (working copy) @@ -6705,6 +6705,15 @@ stmt = build_binary_op (loc, PLUS_EXPR, stmt, arg2, 1); stmt = build_indirect_ref (loc, stmt, RO_NULL); + /* PR83660: We mark this as having side effects so that + downstream in fold_build_cleanup_point_expr () it will get a + CLEANUP_POINT_EXPR. If it does not we can run into an ICE + later in gimplify_cleanup_point_expr (). Potentially this + causes missed optimization because the actually is no side + effect. */ + if (c_dialect_cxx ()) + TREE_SIDE_EFFECTS (stmt) = 1; + return stmt; } Index: testsuite/gcc.target/powerpc/pr83660.C =================================================================== --- testsuite/gcc.target/powerpc/pr83660.C (nonexistent) +++ testsuite/gcc.target/powerpc/pr83660.C (working copy) @@ -0,0 +1,14 @@ +/* PR target/83660 */ +/* { dg-do compile } */ +/* { dg-options "-mcpu=power7" } */ + +#include + +typedef __vector unsigned int uvec32_t __attribute__((__aligned__(16))); + +unsigned get_word(uvec32_t v) +{ + return ({const unsigned _B1 = 32; + vec_extract((uvec32_t)v, 2);}); +} +