From patchwork Mon Jul 31 16:19:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 795855 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-459395-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="TJXIT9h1"; 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 3xLl5s0F7qz9ryr for ; Tue, 1 Aug 2017 02:19:42 +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:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=FV1gv nrquJFb5Q4gk7DIkzqIpmWeyG7ASaLy6acBibaz9A9qUyTVJVMXNJY4drqkdRsx2 JAHHQEeSBFQEFYIrlnOnQWnVnqsGZJfr/x3FGc/LlKBAX4INLaA7R4VBwn0icDs5 bKleLpSmkOIqWgo5QQlaLAijoxt3s8KZ/k4yLk= 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:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=eOtxw8ERQIe CnZ8BPAdYmkj2ZuI=; b=TJXIT9h1+WmrdCaLS3q5uug99HtEj6lnEJLehrqvNiA 0VjlGZmiNnvRyD5IajGqBOM8gYnLWaYmP5YJDjnjSVlxjgv/FhRbQjkWs1O4VxnG xS5NxTuyrcmKSfx6LlwJJBo77AsvR/Bu6Z5MdpcuYMtb+zxNeI3RYz0ob8AYyeO4 = Received: (qmail 35684 invoked by alias); 31 Jul 2017 16:19:35 -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 35666 invoked by uid 89); 31 Jul 2017 16:19:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.4 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= 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; Mon, 31 Jul 2017 16:19:33 +0000 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6VGJLN5011943 for ; Mon, 31 Jul 2017 12:19:31 -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 2c21ewvqfq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 31 Jul 2017 12:19:31 -0400 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 31 Jul 2017 12:19:30 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e19.ny.us.ibm.com (146.89.104.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 31 Jul 2017 12:19:27 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6VGJQxQ25428114; Mon, 31 Jul 2017 16:19:26 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A060F12404C; Mon, 31 Jul 2017 12:16:51 -0400 (EDT) Received: from bigmac.rchland.ibm.com (unknown [9.10.86.172]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 7297B124035; Mon, 31 Jul 2017 12:16:51 -0400 (EDT) To: GCC Patches Cc: Segher Boessenkool , David Edelsohn From: Bill Schmidt Subject: [PATCH, rs6000] Fix PR81622 Date: Mon, 31 Jul 2017 11:19:26 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17073116-0056-0000-0000-000003AF7470 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007459; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00895589; UDB=6.00447938; IPR=6.00675777; BA=6.00005503; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016467; XFM=3.00000015; UTC=2017-07-31 16:19:28 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17073116-0057-0000-0000-000007E59CD2 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-31_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707310277 X-IsSubscribed: yes Hi, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81622 reports an ICE-on-invalid for the vec_ld and vec_st built-in functions. This fires when the last argument of the built-in is not a pointer or array type, as is required. We break on this during early expansion of the built-ins into tree code during parsing. The solution, as with other ill-formed uses of these built-ins, is to avoid the early expansion when the argument has an invalid type, so that normal error handling can kick in later. (The long-term solution is to move the vec_ld and vec_st built-ins to the gimple folding work that Will Schmidt has been doing, but that hasn't happened yet.) Bootstrapped and tested on powerpc64le-linux-gnu with no regressions. Is this ok for trunk and GCC 7? I'd like to get it into 7.2 since it is a 7 regression. Thanks, Bill [gcc] 2017-07-31 Bill Schmidt PR target/81622 * config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): Don't expand vec_ld or vec_st early if the last argument isn't a pointer or array type. [gcc/testsuite] 2017-07-31 Bill Schmidt PR target/81622 * gcc.target/powerpc/pr81622.c: New file. Index: gcc/config/rs6000/rs6000-c.c =================================================================== --- gcc/config/rs6000/rs6000-c.c (revision 250721) +++ gcc/config/rs6000/rs6000-c.c (working copy) @@ -6454,10 +6454,13 @@ altivec_resolve_overloaded_builtin (location_t loc consider this for all memory access built-ins. When -maltivec=be is specified, or the wrong number of arguments - is provided, simply punt to existing built-in processing. */ + is provided, or the second argument isn't a pointer, simply punt + to existing built-in processing. */ if (fcode == ALTIVEC_BUILTIN_VEC_LD && (BYTES_BIG_ENDIAN || !VECTOR_ELT_ORDER_BIG) - && nargs == 2) + && nargs == 2 + && (POINTER_TYPE_P ((*arglist)[1]) + || TREE_CODE (TREE_TYPE ((*arglist)[1])) == ARRAY_TYPE)) { tree arg0 = (*arglist)[0]; tree arg1 = (*arglist)[1]; @@ -6528,7 +6531,9 @@ altivec_resolve_overloaded_builtin (location_t loc /* Similarly for stvx. */ if (fcode == ALTIVEC_BUILTIN_VEC_ST && (BYTES_BIG_ENDIAN || !VECTOR_ELT_ORDER_BIG) - && nargs == 3) + && nargs == 3 + && (POINTER_TYPE_P ((*arglist)[2]) + || TREE_CODE (TREE_TYPE ((*arglist)[2])) == ARRAY_TYPE)) { tree arg0 = (*arglist)[0]; tree arg1 = (*arglist)[1]; Index: gcc/testsuite/gcc.target/powerpc/pr81622.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr81622.c (nonexistent) +++ gcc/testsuite/gcc.target/powerpc/pr81622.c (working copy) @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +void a() +{ + __builtin_vec_ld (1, 2); /* { dg-error "invalid parameter combination for AltiVec intrinsic __builtin_vec_ld" } */ +} + +void b() +{ + __builtin_vec_st (0, 1, 2); /* { dg-error "invalid parameter combination for AltiVec intrinsic __builtin_vec_st" } */ +}