From patchwork Wed Mar 14 21:27:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kelvin Nilsen X-Patchwork-Id: 886046 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-474742-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="NUl+Bw+k"; 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 401lF016CMz9sSt for ; Thu, 15 Mar 2018 08:27:46 +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:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=jVbj4 Ji7cVWjin9zRcVfFmGYC1KNphYL4iHqlNdoL4bWlmqQg1Hwd3vclB9Bm6CqJUshB IjBp5iteF4jYwO9xBy9Pda2vqkrDDp6ofJPIDaWAKEssEGvtwnHzELvVhWM9tKcE mVK5b7jRAxcIQ+vkE0cBtUnjfqvTEUJiszcjas= 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=lEyGobfU89d sl7rvFtImAQhkdMw=; b=NUl+Bw+kWx3IcLfmzgVUZkdZ3bQeErrqKCpq6x/aktO shTkaqUuFBztSANLLwlBPyUCxwts5veXzYidpxpne3ZXeWF4oQC2OnO9hZZVD8KL IHN8DIxORjJ2G0Rc98FoFltvKBKsAYDCbOzI0skKHQyieptZe/MfJ2NQxThh11k8 = Received: (qmail 27814 invoked by alias); 14 Mar 2018 21:27:39 -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 27797 invoked by uid 89); 14 Mar 2018 21:27:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.5 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; Wed, 14 Mar 2018 21:27:36 +0000 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2ELNZpc102306 for ; Wed, 14 Mar 2018 17:27:34 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gqauqhnyn-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 17:27:34 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:27:33 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:27:32 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2ELRVnD47317152; Wed, 14 Mar 2018 21:27:31 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D7BB9112040; Wed, 14 Mar 2018 17:26:08 -0400 (EDT) Received: from oc6462846008.ibm.com (unknown [9.10.86.139]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id A3071112051; Wed, 14 Mar 2018 17:26:08 -0400 (EDT) To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool From: Kelvin Nilsen Subject: [PATCH, rs6000] Finish implementation of __builtin_atlivec_lvx_v1ti Date: Wed, 14 Mar 2018 16:27:31 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031421-0008-0000-0000-000002E59542 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008675; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000254; SDB=6.01003085; UDB=6.00510460; IPR=6.00782416; MB=3.00020036; MTD=3.00000008; XFM=3.00000015; UTC=2018-03-14 21:27:32 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031421-0009-0000-0000-000038902329 Message-Id: <8365537f-20b3-6616-0180-3713bc0db215@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1803140229 X-IsSubscribed: yes During code review, it was discovered that the implementation of __builtin_altivec_lvx_v1ti is not complete. The constant ALTIVEC_BUILTINLVX_V1TI is introduced and is bound to the function __builtin_altivec_lvx_v1ti. However, this function's implementation is incomplete because there is no call to the def_builtin function for this binding. This patch provides the missing pieces to add support for this function. Additionally, this patch introduces four new __int128-based prototypes of the overloaded __builtin_vec_ld function. This is the function that implements the vec_ld () macro expansion. A new test case has been provided to exercise each of these prototypes. This patch has been bootstrapped and tested without regressions on both powerpc64le-unknown-linux (P8) and on powerpc-linux (P7 big-endian, with both -m32 and -m64 target options). Is this patch ok for trunk? gcc/ChangeLog: 2018-03-14 Kelvin Nilsen * config/rs6000/rs6000-c.c (altivec_overloaded_builtins): Add entries for V1TI variants of __builtin_altivec_ld builtin. * config/rs6000/rs6000.c (altivec_expand_lv_builtin): Add test and handling of V1TI variant of LVX icode pattern. (altivec_expand_builtin): Add case for ALTIVEC_BUILTIN_LVX_V1TI. (rs6000_gimple_fold_builtin): Likewise. (altivec_init_builtins): Add code to define __builtin_altivec_lvx_v1ti function. * doc/extend.texi: Add four new prototypes for vec_ld. gcc/testsuite/ChangeLog: 2018-03-14 Kelvin Nilsen * gcc.target/powerpc/altivec-ld-1.c: New test. Index: gcc/config/rs6000/rs6000-c.c =================================================================== --- gcc/config/rs6000/rs6000-c.c (revision 258341) +++ gcc/config/rs6000/rs6000-c.c (working copy) @@ -1562,6 +1562,15 @@ const struct altivec_builtin_types altivec_overloa { VSX_BUILTIN_VEC_FLOATO, VSX_BUILTIN_UNS_FLOATO_V2DI, RS6000_BTI_V4SF, RS6000_BTI_unsigned_V2DI, 0, 0 }, + { ALTIVEC_BUILTIN_VEC_LD, ALTIVEC_BUILTIN_LVX_V1TI, + RS6000_BTI_V1TI, RS6000_BTI_INTSI, ~RS6000_BTI_V1TI, 0 }, + { ALTIVEC_BUILTIN_VEC_LD, ALTIVEC_BUILTIN_LVX_V1TI, + RS6000_BTI_unsigned_V1TI, RS6000_BTI_INTSI, ~RS6000_BTI_unsigned_V1TI, 0 }, + { ALTIVEC_BUILTIN_VEC_LD, ALTIVEC_BUILTIN_LVX_V1TI, + RS6000_BTI_V1TI, RS6000_BTI_INTSI, ~RS6000_BTI_INTTI, 0 }, + { ALTIVEC_BUILTIN_VEC_LD, ALTIVEC_BUILTIN_LVX_V1TI, + RS6000_BTI_unsigned_V1TI, RS6000_BTI_INTSI, ~RS6000_BTI_UINTTI, 0 }, + { ALTIVEC_BUILTIN_VEC_LD, ALTIVEC_BUILTIN_LVX_V2DF, RS6000_BTI_V2DF, RS6000_BTI_INTSI, ~RS6000_BTI_V2DF, 0 }, { ALTIVEC_BUILTIN_VEC_LD, ALTIVEC_BUILTIN_LVX_V2DI, Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 258341) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -14452,6 +14452,7 @@ altivec_expand_lv_builtin (enum insn_code icode, t LVXL and LVE*X expand to use UNSPECs to hide their special behavior, so the raw address is fine. */ if (icode == CODE_FOR_altivec_lvx_v2df_2op + || icode == CODE_FOR_altivec_lvx_v1ti_2op || icode == CODE_FOR_altivec_lvx_v2di_2op || icode == CODE_FOR_altivec_lvx_v4sf_2op || icode == CODE_FOR_altivec_lvx_v4si_2op @@ -15811,6 +15812,9 @@ altivec_expand_builtin (tree exp, rtx target, bool case ALTIVEC_BUILTIN_LVX_V2DI: return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v2di_2op, exp, target, false); + case ALTIVEC_BUILTIN_LVX_V1TI: + return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v1ti_2op, + exp, target, false); case ALTIVEC_BUILTIN_LVX_V4SF: return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v4sf_2op, exp, target, false); @@ -16542,6 +16546,7 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator * case ALTIVEC_BUILTIN_LVX_V4SF: case ALTIVEC_BUILTIN_LVX_V2DI: case ALTIVEC_BUILTIN_LVX_V2DF: + case ALTIVEC_BUILTIN_LVX_V1TI: { arg0 = gimple_call_arg (stmt, 0); // offset arg1 = gimple_call_arg (stmt, 1); // address @@ -17443,6 +17448,10 @@ altivec_init_builtins (void) = build_function_type_list (V2DI_type_node, long_integer_type_node, pcvoid_type_node, NULL_TREE); + tree v1ti_ftype_long_pcvoid + = build_function_type_list (V1TI_type_node, + long_integer_type_node, pcvoid_type_node, + NULL_TREE); tree void_ftype_opaque_long_pvoid = build_function_type_list (void_type_node, @@ -17540,6 +17549,8 @@ altivec_init_builtins (void) def_builtin ("__builtin_altivec_lvx", v4si_ftype_long_pcvoid, ALTIVEC_BUILTIN_LVX); def_builtin ("__builtin_altivec_lvx_v2df", v2df_ftype_long_pcvoid, ALTIVEC_BUILTIN_LVX_V2DF); + def_builtin ("__builtin_altivec_lvx_v1ti", v1ti_ftype_long_pcvoid, + ALTIVEC_BUILTIN_LVX_V1TI); def_builtin ("__builtin_altivec_lvx_v2di", v2di_ftype_long_pcvoid, ALTIVEC_BUILTIN_LVX_V2DI); def_builtin ("__builtin_altivec_lvx_v4sf", v4sf_ftype_long_pcvoid, Index: gcc/doc/extend.texi =================================================================== --- gcc/doc/extend.texi (revision 258341) +++ gcc/doc/extend.texi (working copy) @@ -18396,6 +18396,10 @@ vector double vec_div (vector double, vector doubl vector long vec_div (vector long, vector long); vector unsigned long vec_div (vector unsigned long, vector unsigned long); vector double vec_floor (vector double); +vector __int128 vec_ld (int, const vector __int128 *); +vector unsigned __int128 vec_ld (int, const vector unsigned __int128 *); +vector __int128 vec_ld (int, const __int128 *); +vector unsigned __int128 vec_ld (int, const unsigned __int128 *); vector double vec_ld (int, const vector double *); vector double vec_ld (int, const double *); vector double vec_ldl (int, const vector double *); Index: gcc/testsuite/gcc.target/powerpc/altivec-ld-1.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/altivec-ld-1.c (nonexistent) +++ gcc/testsuite/gcc.target/powerpc/altivec-ld-1.c (working copy) @@ -0,0 +1,67 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-maltivec -O0 -Wall -Wno-deprecated" } */ + +#include +#include + +static __vector __int128 v; +static __vector __int128 *pv; + +static __vector unsigned __int128 uv; +static __vector unsigned __int128 *puv; + +static __int128 i128; +static __int128 *pi128; + +static unsigned __int128 u128; +static unsigned __int128 *pu128; + + +void +doInitialization () +{ + v[0] = -1; + pv = &v; + + uv[0] = 0xcafebabe; + puv = &uv; + + i128 = 0xfabeabe; + pi128 = &i128; + + u128 = 0xabefabe; + pu128 = &u128; +} + +int +main (int argc, char *argv[]) +{ + __vector __int128 loaded_v; + __vector unsigned __int128 loaded_uv; + + /* Usage: + * result = vec_ld (int index, __vector v) + * is equivalent to: + * result = v [index]; + */ + doInitialization (); + loaded_v = vec_ld (0, pv); + if (loaded_v[0] != -1) + abort (); + + loaded_uv = vec_ld (0, puv); + if (loaded_uv[0] != 0xcafebabe) + abort (); + + loaded_v = vec_ld (0, pi128); + if (loaded_v[0] != 0xfabeabe) + abort (); + + loaded_uv = vec_ld (0, pu128); + if (loaded_uv[0] != 0xabefabe) + abort (); + + return 0; +}