From patchwork Mon Apr 10 17:08:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 749129 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 3w1xVZ3w2Cz9sNg for ; Tue, 11 Apr 2017 03:09:09 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="h2P2kNo8"; 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:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=S5MaC 5HCGRlLw357N7eMTDoYk9eeER0rNlFyLYkFrwn6/3QXJ8mzzXjHLrOrd3iGYekXG Ez7ClIqBglazGgTHeYZJMVFW3wGBmvpAcTc181O+HmXWhq1Y92Gn/sxuTOwlH7hG 7mL0+HqvognvsS1LiYmdcPKLXdT4mTJ0RlW+e4= 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=U9Y7VsXlSqA WePWQohnqnllUxIA=; b=h2P2kNo8wKNHX0TC8o/k+RNZaUu9FwAFPQxwj+jw4Jj TR9l1vuTJJ6yIkSXxLP5w4nlh7n69GRkGPbUivI6l2W+htarEIqLXJJF5dGgSt52 5wykHeeWlpCl0ik5JH8YwDIKTH25K2xAbfEPzl0h5PD784CNm5ry6NY2i35lmoF4 = Received: (qmail 128309 invoked by alias); 10 Apr 2017 17:08:57 -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 127393 invoked by uid 89); 10 Apr 2017 17:08:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.2 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 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; Mon, 10 Apr 2017 17:08:55 +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 v3AH3buZ080915 for ; Mon, 10 Apr 2017 13:08:55 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 29rbx8pwhx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 10 Apr 2017 13:08:54 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 10 Apr 2017 13:08:54 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 10 Apr 2017 13:08:52 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3AH8sBe41615466; Mon, 10 Apr 2017 17:08:54 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD10428041; Mon, 10 Apr 2017 13:08:46 -0400 (EDT) Received: from bigmac.rchland.ibm.com (unknown [9.10.86.201]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id 871862803E; Mon, 10 Apr 2017 13:08:46 -0400 (EDT) To: GCC Patches Cc: Segher Boessenkool , David Edelsohn From: Bill Schmidt Subject: [PATCH, rs6000] Fix PR80376 (somewhat) Date: Mon, 10 Apr 2017 12:08:50 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17041017-0040-0000-0000-0000030F133F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006912; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00845637; UDB=6.00417026; IPR=6.00624071; BA=6.00005281; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014994; XFM=3.00000013; UTC=2017-04-10 17:08:53 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041017-0041-0000-0000-000007031AB6 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-10_13:, , 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-1702020001 definitions=main-1704100135 X-IsSubscribed: yes Hi, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80376 shows an ICE on invalid code when using certain flavors of the vec_xxpermdi intrinsic. The root cause is that we were not checking the parameter for a legal value, and an illegal value was being provided by the user (only an integer constant is permissible for argument 3). However, this brings up a slightly larger problem, in that the invalid vec_xxpermdi call is nested within another call. We have a lot of cases in rs6000.c where we signal an error message and replace the offending construct with a const0_rtx. In this case, that const0_rtx was being used as a vector argument to another call, leading to a follow-up ICE that is not easy to parse. The fix for the root problem is just to add some missing cases to existing error checking. To help reduce the mystery of the follow-up ICE, I added some logic to the vector move pattern in vector.md to check for a scalar constant being used in a vector context, and forced an ICE with an explanatory message at that point. The results look like this: wschmidt@pike:~/src$ $GCC_INSTALL/bin/gcc pr80376.c pr80376.c: In function 'main': pr80376.c:12:5: error: argument 3 must be a 2-bit unsigned literal vec_vsx_st(vec_xxpermdi(a, b, j), 0, c); ^~~~~~~~~~ pr80376.c:12:5: internal compiler error: non-vector constant found where vector expected 0x116cde0b gen_movv4si(rtx_def*, rtx_def*) /home/wschmidt/gcc/gcc-mainline-test/gcc/config/rs6000/vector.md:114 0x105fd113 insn_gen_fn::operator()(rtx_def*, rtx_def*) const /home/wschmidt/gcc/gcc-mainline-test/gcc/recog.h:301 0x1077a497 emit_move_insn_1(rtx_def*, rtx_def*) /home/wschmidt/gcc/gcc-mainline-test/gcc/expr.c:3643 0x1077ab37 emit_move_insn(rtx_def*, rtx_def*) /home/wschmidt/gcc/gcc-mainline-test/gcc/expr.c:3738 0x107826d3 store_expr_with_bounds(tree_node*, rtx_def*, int, bool, bool, tree_node*) /home/wschmidt/gcc/gcc-mainline-test/gcc/expr.c:5729 0x107802a3 expand_assignment(tree_node*, tree_node*, bool) /home/wschmidt/gcc/gcc-mainline-test/gcc/expr.c:5321 0x1056ec0b expand_call_stmt /home/wschmidt/gcc/gcc-mainline-test/gcc/cfgexpand.c:2656 0x10572b87 expand_gimple_stmt_1 /home/wschmidt/gcc/gcc-mainline-test/gcc/cfgexpand.c:3571 0x105734c3 expand_gimple_stmt /home/wschmidt/gcc/gcc-mainline-test/gcc/cfgexpand.c:3737 0x1057cd03 expand_gimple_basic_block /home/wschmidt/gcc/gcc-mainline-test/gcc/cfgexpand.c:5744 0x1057ef3b execute /home/wschmidt/gcc/gcc-mainline-test/gcc/cfgexpand.c:6357 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See for instructions. I think this is the best way to handle this for stage 4. At some point we should review our error handling and see whether we can produce better replacement values than const0_rtx, that won't immediately ICE when used in a call argument context. This seems like too much churn for late stage 4. I've also fixed the documentation to clarify that the third argument to vec_xxpermdi must be a constant. Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no regressions. Is this ok for trunk, and eventual backport to GCC 6? Thanks, Bill 2017-04-10 Bill Schmidt PR target/80376 * config/rs6000/rs6000.c (rs6000_expand_ternop_builtin): Add missing vsx_xxpermdi_* variants. * config/rs6000/vector.md (mov): Add pre-emptive ICE when a non-vector constant is used in a vector context. * doc/extend.texi: Document that vec_xxpermdi's third argument must be a constant. Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 246804) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -15586,6 +15586,11 @@ rs6000_expand_ternop_builtin (enum insn_code icode || icode == CODE_FOR_vsx_xxpermdi_v2di || icode == CODE_FOR_vsx_xxpermdi_v2df_be || icode == CODE_FOR_vsx_xxpermdi_v2di_be + || icode == CODE_FOR_vsx_xxpermdi_v1ti + || icode == CODE_FOR_vsx_xxpermdi_v4sf + || icode == CODE_FOR_vsx_xxpermdi_v4si + || icode == CODE_FOR_vsx_xxpermdi_v8hi + || icode == CODE_FOR_vsx_xxpermdi_v16qi || icode == CODE_FOR_vsx_xxsldwi_v16qi || icode == CODE_FOR_vsx_xxsldwi_v8hi || icode == CODE_FOR_vsx_xxsldwi_v4si Index: gcc/config/rs6000/vector.md =================================================================== --- gcc/config/rs6000/vector.md (revision 246804) +++ gcc/config/rs6000/vector.md (working copy) @@ -109,6 +109,11 @@ { if (CONSTANT_P (operands[1])) { + /* Handle cascading error conditions. */ + if (VECTOR_MODE_P (mode) + && !VECTOR_MODE_P (GET_MODE (operands[1]))) + internal_error ("non-vector constant found where vector expected"); + if (FLOAT128_VECTOR_P (mode)) { if (!easy_fp_constant (operands[1], mode)) Index: gcc/doc/extend.texi =================================================================== --- gcc/doc/extend.texi (revision 246804) +++ gcc/doc/extend.texi (working copy) @@ -17623,20 +17623,21 @@ void vec_vsx_st (vector bool char, int, vector boo void vec_vsx_st (vector bool char, int, unsigned char *); void vec_vsx_st (vector bool char, int, signed char *); -vector double vec_xxpermdi (vector double, vector double, int); -vector float vec_xxpermdi (vector float, vector float, int); -vector long long vec_xxpermdi (vector long long, vector long long, int); +vector double vec_xxpermdi (vector double, vector double, const int); +vector float vec_xxpermdi (vector float, vector float, const int); +vector long long vec_xxpermdi (vector long long, vector long long, const int); vector unsigned long long vec_xxpermdi (vector unsigned long long, - vector unsigned long long, int); -vector int vec_xxpermdi (vector int, vector int, int); + vector unsigned long long, const int); +vector int vec_xxpermdi (vector int, vector int, const int); vector unsigned int vec_xxpermdi (vector unsigned int, - vector unsigned int, int); -vector short vec_xxpermdi (vector short, vector short, int); + vector unsigned int, const int); +vector short vec_xxpermdi (vector short, vector short, const int); vector unsigned short vec_xxpermdi (vector unsigned short, - vector unsigned short, int); -vector signed char vec_xxpermdi (vector signed char, vector signed char, int); + vector unsigned short, const int); +vector signed char vec_xxpermdi (vector signed char, vector signed char, + const int); vector unsigned char vec_xxpermdi (vector unsigned char, - vector unsigned char, int); + vector unsigned char, const int); vector double vec_xxsldi (vector double, vector double, int); vector float vec_xxsldi (vector float, vector float, int);