From patchwork Fri Apr 13 16:49:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Carl Love X-Patchwork-Id: 898024 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-476349-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="BtRZVkkc"; 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 40N3fP5wXkz9s0W for ; Sat, 14 Apr 2018 02:49:49 +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 :content-transfer-encoding:message-id; q=dns; s=default; b=ctYAk 0bwPLTbjdm0mUkBqzXClenCyb8Aw8Q3NaK4kVKs67f8clg+iTfv2S0XN37UkGAda xZZIGMGER/7rr29mgxf8UiduC+G5Aq0xPaO+49CpPCMkjb9x+IqG7skxNT2hjwhs o13GerZ11z++tEmgmm2j/q8Us0EThdG8ENRLpk= 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 :content-transfer-encoding:message-id; s=default; bh=TBHsA6tFJbJ Vg63avtCPvjJrDzQ=; b=BtRZVkkcUGsUlqtaPeXcRffneCTDhSHLxhe6OEDEECr w+Grwn1ZRlAIM7/pX2UixlL9YBLE9ysckcgTqc/mf/biaDaADTxJZMu5CRJXMkGB a0As2YcBE5cXjq02CLstdZUkp0GH4WjMtHh0n5w+jZckLdJi1YIjPQoSrBMJgGXc = Received: (qmail 79550 invoked by alias); 13 Apr 2018 16:49:33 -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 79411 invoked by uid 89); 13 Apr 2018 16:49:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=maintainers, rs6000cc, UD:rs6000-c.c, rs6000-c.c 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; Fri, 13 Apr 2018 16:49:31 +0000 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3DGmSQr011084 for ; Fri, 13 Apr 2018 12:49:29 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hawan1e5b-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Fri, 13 Apr 2018 12:49:29 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 13 Apr 2018 12:49:28 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 13 Apr 2018 12:49:27 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3DGnQmB47317024; Fri, 13 Apr 2018 16:49:26 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A6352B2052; Fri, 13 Apr 2018 13:51:31 -0400 (EDT) Received: from oc3304648336.ibm.com (unknown [9.70.82.121]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 1C21DB2046; Fri, 13 Apr 2018 13:51:31 -0400 (EDT) Subject: [PATCH] PR 83402 Fix ICE for vec_splat_s8, vec_splat_s16, vec_splat_s32 builtins From: Carl Love To: Segher Boessenkool , gcc-patches@gcc.gnu.org, David Edelsohn Cc: Bill Schmidt , cel@us.ibm.com Date: Fri, 13 Apr 2018 09:49:25 -0700 Mime-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18041316-0052-0000-0000-000002DAA194 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008850; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000257; SDB=6.01017378; UDB=6.00518875; IPR=6.00796615; MB=3.00020562; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-13 16:49:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041316-0053-0000-0000-00005C51C9AF Message-Id: <1523638165.12016.22.camel@us.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-13_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 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-1804130154 X-IsSubscribed: yes GCC Maintainers: GCC revision 255549  implemented early gimple folding for the vec_splat_s[8,16,32] builtins.  However, as a consequence of the implementation, we lost error checking for out-of-range values for the expected vspltis[bhw] instructions.  The result of not having the out- of-range checking is we get and ICE. This patch adds the missing error checking on argument zero for the vec_splat_s[8,16,32] builtins. The argument must be a 5-bit const int as specified for the vspltis[bhw] instructions. The regression testing for the patch was done on GCC mainline on powerpc64le-unknown-linux-gnu (Power 8 LE) with no regressions. Additional hand testing was done as well to test the various cases such as vec_splat_s8 (31) vec_splat_s8 (32) vec_splat_s8 (value) where "value" is an integer variable to verify vector result is correct for a 5-bit const int argument ( i.e. 31). The error message "error: argument 1 must be a 5-bit signed literal" is generated in the other cases. Please let me know if the patch looks OK for the GCC 7 branch.                          Carl Love --------------------------------------------------- gcc/ChangeLog: 2018-04-13 Carl Love PR target/83402 * config/rs6000/rs6000-c.c (rs6000_gimple_fold_builtin): Add size check for arg0. --- gcc/config/rs6000/rs6000.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index a0c9b5c..855be43 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -16576,8 +16576,9 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi) { arg0 = gimple_call_arg (stmt, 0); lhs = gimple_call_lhs (stmt); - /* Only fold the vec_splat_*() if arg0 is constant. */ - if (TREE_CODE (arg0) != INTEGER_CST) + /* Only fold the vec_splat_*() if arg0 is a 5-bit constant. */ + if (TREE_CODE (arg0) != INTEGER_CST + || TREE_INT_CST_LOW (arg0) & ~0x1f) return false; gimple_seq stmts = NULL; location_t loc = gimple_location (stmt);