From patchwork Thu Oct 27 15:37:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: will schmidt X-Patchwork-Id: 687755 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 3t4WHC3cMNz9ryZ for ; Fri, 28 Oct 2016 02:37:42 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=CsRHdjWR; 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 :subject:from:reply-to:to:cc:content-type:date:mime-version :content-transfer-encoding:message-id; q=dns; s=default; b=WlBJ3 p/imFWv+LI9WSHL+9GCaSIKaSyTMIZBmAfaOZNEYc62chsjnAnb34BPq0izP95c4 Vewuly+zZ6UL7zZdUy4ledqux7TmsOuA9XORiwj6QwTrPJUyUWxmoB7hXFRt+m2Q QSNZRVrHr9VE5Kg1Dm23J9qdz7VWHEw4cOEIFM= 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:reply-to:to:cc:content-type:date:mime-version :content-transfer-encoding:message-id; s=default; bh=ABxuCFizO5f g9ATLxFn5SOyDWG8=; b=CsRHdjWR7O0VXBwiPA+Oot1KfzSVzzxCWAWHG6FQKvh ATYgHNpRzuIIn3fNtR/nv5gR02yOdwvqtnjydPBlbVYzsgsqAuwVqRwIN4M/xdpD Xs6BY9LxvPNHNO1Y1OgJ1hST0r1K4LaYXYERr3gBEnidDZNf7v8ddaQaMgz8pDxw = Received: (qmail 87351 invoked by alias); 27 Oct 2016 15:37:30 -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 85986 invoked by uid 89); 27 Oct 2016 15:37:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=vw, sides, our X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Oct 2016 15:37:28 +0000 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9RFT6Jq027799 for ; Thu, 27 Oct 2016 11:37:26 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 26bkh1mg2q-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Oct 2016 11:37:26 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Oct 2016 09:37:25 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 27 Oct 2016 09:37:24 -0600 Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 364163E4004F; Thu, 27 Oct 2016 09:37:23 -0600 (MDT) Received: from b01ledav03.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9RFbMCx20119764; Thu, 27 Oct 2016 15:37:22 GMT Received: from b01ledav03.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9FBCDB205F; Thu, 27 Oct 2016 11:37:22 -0400 (EDT) Received: from [9.10.86.107] (unknown [9.10.86.107]) by b01ledav03.gho.pok.ibm.com (Postfix) with ESMTP id 63E2BB2056; Thu, 27 Oct 2016 11:37:22 -0400 (EDT) Subject: [PATCH] Fix and testcases for pr72747 From: Will Schmidt Reply-To: will_schmidt@vnet.ibm.com To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com Date: Thu, 27 Oct 2016 10:37:21 -0500 Mime-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16102715-0008-0000-0000-000005EB08C1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005988; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000189; SDB=6.00773520; UDB=6.00371428; IPR=6.00550354; BA=6.00004837; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013116; XFM=3.00000011; UTC=2016-10-27 15:37:25 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16102715-0009-0000-0000-00003C7F9084 Message-Id: <1477582641.17912.136.camel@brimstone.rchland.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-10-27_10:, , 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-1609300000 definitions=main-1610270257 X-IsSubscribed: yes Hi, Per PR72747, A statement such as "v = vec_splats (1);" correctly initializes a vector. However, a statement such as "v[1] = v[0] = vec_splats (1);" initializes both v[1] and v[0] to random garbage. It has been determined that this is occurring because we did not emit the actual initialization statement before our final exit from gimplify_init_constructor, at which time we lose the expression when we assign *expr_p to either NULL or object. This problem affected both constant and non-constant initializers. Corrected this by moving the logic to emit the statement up earlier within the if/else logic. Bootstrapped and make check ran without regressions on powerpc64le-unknown-linux-gnu. OK for trunk? Thanks, -Will gcc: 2016-10-26 Will Schmidt PR middle-end/72747 * gimplify.c (gimplify_init_constructor): Move emit of constructor assignment to earlier in the if/else logic. testsuite: 2016-10-26 Will Schmidt PR middle-end/72747 * c-c++-common/pr72747-1.c: New test. * c-c++-common/pr72747-2.c: Likewise. Index: gcc/gimplify.c =================================================================== --- gcc/gimplify.c (revision 241600) +++ gcc/gimplify.c (working copy) @@ -4730,24 +4730,23 @@ if (ret == GS_ERROR) return GS_ERROR; - else if (want_value) + /* If we have gimplified both sides of the initializer but have + not emitted an assignment, do so now. */ + if (*expr_p) { + tree lhs = TREE_OPERAND (*expr_p, 0); + tree rhs = TREE_OPERAND (*expr_p, 1); + gassign *init = gimple_build_assign (lhs, rhs); + gimplify_seq_add_stmt (pre_p, init); + } + if (want_value) + { *expr_p = object; return GS_OK; } else { - /* If we have gimplified both sides of the initializer but have - not emitted an assignment, do so now. */ - if (*expr_p) - { - tree lhs = TREE_OPERAND (*expr_p, 0); - tree rhs = TREE_OPERAND (*expr_p, 1); - gassign *init = gimple_build_assign (lhs, rhs); - gimplify_seq_add_stmt (pre_p, init); - *expr_p = NULL; - } - + *expr_p = NULL; return GS_ALL_DONE; } } Index: gcc/testsuite/c-c++-common/pr72747-1.c =================================================================== --- gcc/testsuite/c-c++-common/pr72747-1.c (revision 0) +++ gcc/testsuite/c-c++-common/pr72747-1.c (working copy) @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-maltivec -fdump-tree-gimple" } */ + +/* PR 72747: Test that cascaded definition is happening for constant vectors. */ + +#include + +int main (int argc, char *argv[]) +{ + __vector int v1,v2; + v1 = v2 = vec_splats ((int) 42); + return 0; +} +/* { dg-final { scan-tree-dump-times " v2 = { 42, 42, 42, 42 }" 1 "gimple" } } */ + Index: gcc/testsuite/c-c++-common/pr72747-2.c =================================================================== --- gcc/testsuite/c-c++-common/pr72747-2.c (revision 0) +++ gcc/testsuite/c-c++-common/pr72747-2.c (working copy) @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-c -maltivec -fdump-tree-gimple" } */ + +/* PR 72747: test that cascaded definition is happening for non constants. */ + +void foo () +{ + extern int i; + __vector int v,w; + v = w = (vector int) { i }; +} + +int main (int argc, char *argv[]) +{ + return 0; +} +/* { dg-final { scan-tree-dump-times " w = {i.0_1}" 1 "gimple" } } */