From patchwork Wed Dec 6 16:36:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: will schmidt X-Patchwork-Id: 845253 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-468625-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="BYNBMnkX"; 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 3ysPR25KxWz9s83 for ; Thu, 7 Dec 2017 03:37:17 +1100 (AEDT) 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=nqMJY kvgPo42+uYMmOCmMw/SyLqG/JB2UTQfzyTfEuEaRU/FKBN77nFlmA9vgPrNnvMkk +YqKmaVRLQAhAm0gqtEQya0LmlGCKCXHwPP+GLCHRjszszkWIyy7KRLQXOm5QP5X fGmir6Uo3GQDkLMZsC1Jn1MaYK1TfFhinsJFPo= 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=rB7SPZTTYNZ O3LI2pxIiL8VL4xk=; b=BYNBMnkXV0MvAbXF36MgBEqeDD0k2OO4/t5MCw/Hkk4 ef8Q1u8Sc20PmmVxFgeb3Be7LbUKj39DaEQ4+EUjYnLd/fTv2K+L66PBKoEo8S7O MqxC3pIF5e7nuSJFvlRqnzUlVePwSP+zbtHE2ptNFhZr/ElafZb7XWtWMpCQ2vv0 = Received: (qmail 59373 invoked by alias); 6 Dec 2017 16:37:10 -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 59341 invoked by uid 89); 6 Dec 2017 16:37:09 -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= 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; Wed, 06 Dec 2017 16:37:08 +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 vB6GZ66S137511 for ; Wed, 6 Dec 2017 11:37:06 -0500 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ephf7jju6-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 06 Dec 2017 11:37:05 -0500 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 Dec 2017 11:37:03 -0500 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 6 Dec 2017 11:36:59 -0500 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vB6GaxTK44564646; Wed, 6 Dec 2017 16:36:59 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E3EF228058; Wed, 6 Dec 2017 11:36:25 -0500 (EST) Received: from [9.10.86.107] (unknown [9.10.86.107]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id A6F442803D; Wed, 6 Dec 2017 11:36:25 -0500 (EST) Subject: [PATCH, rs6000] Gimple folding of splat_uX From: Will Schmidt Reply-To: will_schmidt@vnet.ibm.com To: GCC Patches Cc: Richard Biener , Segher Boessenkool , Bill Schmidt , David Edelsohn Date: Wed, 06 Dec 2017 10:36:58 -0600 Mime-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17120616-0048-0000-0000-00000210A319 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008160; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000244; SDB=6.00956326; UDB=6.00483410; IPR=6.00736362; BA=6.00005729; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018385; XFM=3.00000015; UTC=2017-12-06 16:37:01 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17120616-0049-0000-0000-00004361C3EF Message-Id: <1512578218.11602.59.camel@brimstone.rchland.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-12-06_07:, , 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-1712060236 X-IsSubscribed: yes Hi, Add support for gimple folding of splat_u{8,16,32}. Testcase coverage is primarily handled by existing tests testsuite/gcc.target/powerpc/fold-vec-splat_*.c One new test added to verify we continue to receive an 'invalid argument, must be a 5-bit immediate' error when we try to splat a non-constant value. Regtests currently running across assorted power systems. OK for trunk with successful results? Thanks -Will [gcc] 2017-12-05 Will Schmidt * config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Add support for early folding of splat_u{8,16,32}. [testsuite] 2017-12-05 Will Schmidt * gcc.target/powerpc/fold-vec-splat-misc-invalid.c: New. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 045a014..1470557 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -16614,10 +16614,33 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi) case VSX_BUILTIN_CMPLE_2DI: case VSX_BUILTIN_CMPLE_U2DI: fold_compare_helper (gsi, LE_EXPR, stmt); return true; + /* flavors of vec_splat_[us]{8,16,32}. */ + case ALTIVEC_BUILTIN_VSPLTISB: + case ALTIVEC_BUILTIN_VSPLTISH: + case ALTIVEC_BUILTIN_VSPLTISW: + { + 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) + return false; + tree splat_value = build_int_cst (TREE_TYPE (TREE_TYPE (lhs)), + TREE_INT_CST_LOW (arg0)); + vec *ctor_elts = NULL; + unsigned int n_elts = TYPE_VECTOR_SUBPARTS (TREE_TYPE (lhs)); + for (unsigned int i=0; i < n_elts ; i++) + CONSTRUCTOR_APPEND_ELT (ctor_elts, NULL_TREE, splat_value); + tree splat_tree = build_constructor (TREE_TYPE (lhs), ctor_elts); + g = gimple_build_assign (lhs, splat_tree); + gimple_set_location (g, gimple_location (stmt)); + gsi_replace (gsi, g, true); + return true; + } + default: if (TARGET_DEBUG_BUILTIN) fprintf (stderr, "gimple builtin intrinsic not matched:%d %s %s\n", fn_code, fn_name1, fn_name2); break; diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-misc-invalid.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-misc-invalid.c new file mode 100644 index 0000000..20f5b05 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-misc-invalid.c @@ -0,0 +1,33 @@ +/* Verify that overloaded built-ins for vec_splat_s8 and vec_splat_s16 + generate errors as expected when we attempt to use invalid inputs. */ + +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-options "-mvsx -O2" } */ + +#include + +vector signed short +testss_1 (unsigned int ui) +{ + return vec_splat_s16 (ui);/* { dg-error "argument 1 must be a 5-bit signed literal" } */ +} + +vector unsigned short +testss_2 (signed int si) +{ + return vec_splat_u16 (si);/* { dg-error "argument 1 must be a 5-bit signed literal" } */ +} + +vector signed char +testsc_1 (unsigned int ui) +{ + return vec_splat_s8 (ui); /* { dg-error "argument 1 must be a 5-bit signed literal" } */ +} + +vector unsigned char +testsc_2 (signed int si) +{ + return vec_splat_u8 (si);/* { dg-error "argument 1 must be a 5-bit signed literal" } */ +} +