From patchwork Tue Apr 11 21:27:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 749625 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 3w2gBC0xqrz9s8c for ; Wed, 12 Apr 2017 07:27:23 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="TKaDybop"; 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=rn/Sk BGJV9ILv4OgLgcykQ7Jpt4QF0p4VK0rdyqoGzKE7N94c0qnIcDwB0wOfmn8zaLFB yUe9PIV9TEdkPeTdHGo/dit4kPw36amf+XSk3i0eVF9C7egdEEMCqdICC0qtGHD/ 09DWc8Ocgf4Og64NlAaQG8zXEslNBLIteh8XOo= 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=rjyuxyH2a7M oXcy3gD57JRdER6I=; b=TKaDybopuCDD9sE44J4ksdTScCiie19y43l3tFfHnGw b/C1uxKr9l9Vk5cxlqV/vB1L6toEgLwUCialAXjifY352f01HEgyEJJlvaBAuye3 hha/yLj/+QpG3PGPGN0i2M3bxNWeqSHpSAxavNUWcqcp97MuFXRl/2pMgdkTmBGE = Received: (qmail 37128 invoked by alias); 11 Apr 2017 21:27:13 -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 37105 invoked by uid 89); 11 Apr 2017 21:27:10 -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; Tue, 11 Apr 2017 21:27:08 +0000 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3BLIxmf036325 for ; Tue, 11 Apr 2017 17:27:09 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0b-001b2d01.pphosted.com with ESMTP id 29rqse34bd-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 11 Apr 2017 17:27:08 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 11 Apr 2017 17:27:08 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 11 Apr 2017 17:27:06 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3BLR6X443319522; Tue, 11 Apr 2017 21:27:06 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 94420AC03F; Tue, 11 Apr 2017 17:26:55 -0400 (EDT) Received: from bigmac.rchland.ibm.com (unknown [9.10.86.201]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id 586B1AC055; Tue, 11 Apr 2017 17:26:55 -0400 (EDT) To: GCC Patches Cc: Segher Boessenkool , David Edelsohn From: Bill Schmidt Subject: [PATCH, rs6000] Fix PR80376 and PR80315 Date: Tue, 11 Apr 2017 16:27:05 -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: 17041121-0044-0000-0000-0000030151C2 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006919; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00846203; UDB=6.00417365; IPR=6.00624636; BA=6.00005284; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015010; XFM=3.00000013; UTC=2017-04-11 21:27:07 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041121-0045-0000-0000-0000072F5407 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-11_16:, , 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-1704110165 X-IsSubscribed: yes Hi, The previous patch for PR80376 produced a different sort of ICE, which wasn't a terribly great solution. I looked into Segher's suggestion based on code in x86, but that wasn't appropriate here as the problem happens at a different place. The real secondary problem is that we produce a const0_rtx instead of a mode-compatible CONST0_RTX, so the assignment of the built-in result to its target rtx fails with an ICE. I've gone through rs6000.c and fixed the places where we do this in an obviously wrong manner. This patch still fixes the missing vec_xxpermdi cases that were the primary cause of the bug (this time with consistent whitespace), and corrects the documentation to show that argument 3 must be a constant. I also decided to fix PR80315, which just had a silly pasto where we were checking the value of the wrong argument, since this patch fixes one of the CONST0_RTX cases right next to it. Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no regressions. Is this ok for trunk? Both bugs were reported against GCC 6.2, so I would also like to backport the fixes to 6 and possibly 5. Thanks, Bill 2017-04-11 Bill Schmidt PR target/80376 PR target/80315 * config/rs6000/rs6000.c (rs6000_expand_unop_builtin): Return CONST0_RTX (mode) rather than const0_rtx where appropriate. (rs6000_expand_binop_builtin): Likewise. (rs6000_expand_ternop_builtin): Likewise; also add missing vsx_xxpermdi_* variants; also fix typo (arg1 => arg2) for vshasigma built-ins. * 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) @@ -14550,7 +14550,7 @@ rs6000_expand_unop_builtin (enum insn_code icode, || INTVAL (op0) < -16) { error ("argument 1 must be a 5-bit signed literal"); - return const0_rtx; + return CONST0_RTX (tmode); } } @@ -14653,7 +14653,7 @@ rs6000_expand_binop_builtin (enum insn_code icode, || TREE_INT_CST_LOW (arg1) & ~0x1f) { error ("argument 2 must be a 5-bit unsigned literal"); - return const0_rtx; + return CONST0_RTX (tmode); } } else if (icode == CODE_FOR_dfptstsfi_eq_dd @@ -15579,7 +15579,7 @@ rs6000_expand_ternop_builtin (enum insn_code icode || TREE_INT_CST_LOW (arg2) & ~0xf) { error ("argument 3 must be a 4-bit unsigned literal"); - return const0_rtx; + return CONST0_RTX (tmode); } } else if (icode == CODE_FOR_vsx_xxpermdi_v2df @@ -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 @@ -15599,7 +15604,7 @@ rs6000_expand_ternop_builtin (enum insn_code icode || TREE_INT_CST_LOW (arg2) & ~0x3) { error ("argument 3 must be a 2-bit unsigned literal"); - return const0_rtx; + return CONST0_RTX (tmode); } } else if (icode == CODE_FOR_vsx_set_v2df @@ -15619,7 +15624,7 @@ rs6000_expand_ternop_builtin (enum insn_code icode || TREE_INT_CST_LOW (arg2) & ~0x1) { error ("argument 3 must be a 1-bit unsigned literal"); - return const0_rtx; + return CONST0_RTX (tmode); } } else if (icode == CODE_FOR_dfp_ddedpd_dd @@ -15631,7 +15636,7 @@ rs6000_expand_ternop_builtin (enum insn_code icode || TREE_INT_CST_LOW (arg2) & ~0x3) { error ("argument 1 must be 0 or 2"); - return const0_rtx; + return CONST0_RTX (tmode); } } else if (icode == CODE_FOR_dfp_denbcd_dd @@ -15643,7 +15648,7 @@ rs6000_expand_ternop_builtin (enum insn_code icode || TREE_INT_CST_LOW (arg0) & ~0x1) { error ("argument 1 must be a 1-bit unsigned literal"); - return const0_rtx; + return CONST0_RTX (tmode); } } else if (icode == CODE_FOR_dfp_dscli_dd @@ -15657,7 +15662,7 @@ rs6000_expand_ternop_builtin (enum insn_code icode || TREE_INT_CST_LOW (arg1) & ~0x3f) { error ("argument 2 must be a 6-bit unsigned literal"); - return const0_rtx; + return CONST0_RTX (tmode); } } else if (icode == CODE_FOR_crypto_vshasigmaw @@ -15669,14 +15674,14 @@ rs6000_expand_ternop_builtin (enum insn_code icode if (TREE_CODE (arg1) != INTEGER_CST || wi::geu_p (arg1, 2)) { error ("argument 2 must be 0 or 1"); - return const0_rtx; + return CONST0_RTX (tmode); } STRIP_NOPS (arg2); - if (TREE_CODE (arg2) != INTEGER_CST || wi::geu_p (arg1, 16)) + if (TREE_CODE (arg2) != INTEGER_CST || wi::geu_p (arg2, 16)) { error ("argument 3 must be in the range 0..15"); - return const0_rtx; + return CONST0_RTX (tmode); } } 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);