From patchwork Mon Jul 9 19:08:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: will schmidt X-Patchwork-Id: 941584 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-481238-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=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="NSuRHQi1"; 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 41PZdC22cbz9s0W for ; Tue, 10 Jul 2018 05:09:19 +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:reply-to:to:cc:content-type:date:mime-version :content-transfer-encoding:message-id; q=dns; s=default; b=OkmcJ LKPR9bGU7cgj2ZkzakbXBZzTJf2rQbS/OOc508J1qIMOJXTWNOzfQimzuh3EQaiw 5913yzpGO4AnsZ4yZJ7Cblpk71FOSXLTTx0GuyCjOi+M2TeiVgKwOD1EUtFSP/Y+ KdtsDsPILKRLbhyMzwnqc9JjeibdBl9TG7uJiA= 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=nT2j5LU3168 Dl86pIWcwxPAPJSQ=; b=NSuRHQi1lQVNcQenYLYUWfUqiqr4Ds2j+n6aiGka+/i QzVKD360vVS2VV/mDx+JTXI0SrmYW8fgK66ZNXWlEYxN928Yu2z+XaurIPZk87m3 x2Uz3TNJlImhOM7lGl5WFVObe8E2EZDgFSdV3FCZVQf8aBlYRHQER79NuPlfLGAQ = Received: (qmail 40091 invoked by alias); 9 Jul 2018 19:09:04 -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 39943 invoked by uid 89); 9 Jul 2018 19:09:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.0 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 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, 09 Jul 2018 19:09:02 +0000 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w69J49dq088096 for ; Mon, 9 Jul 2018 15:09:00 -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 2k4d9418mk-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 09 Jul 2018 15:09:00 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 9 Jul 2018 15:08:59 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 9 Jul 2018 15:08:56 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w69J8uJr13959586 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Jul 2018 19:08:56 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5CE8B124053; Mon, 9 Jul 2018 16:10:11 -0400 (EDT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 13B48124052; Mon, 9 Jul 2018 16:10:11 -0400 (EDT) Received: from [9.10.86.107] (unknown [9.10.86.107]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 9 Jul 2018 16:10:10 -0400 (EDT) Subject: [PATCH, rs6000] Add support for gimple folding vec_perm() From: Will Schmidt Reply-To: will_schmidt@vnet.ibm.com To: Richard Biener , Segher Boessenkool , David Edelsohn , Bill Schmidt Cc: GCC Patches Date: Mon, 09 Jul 2018 14:08:55 -0500 Mime-Version: 1.0 x-cbid: 18070919-0064-0000-0000-00000327694B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009340; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01058949; UDB=6.00543437; IPR=6.00836869; MB=3.00022074; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-09 19:08:58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070919-0065-0000-0000-000039E0AFEE Message-Id: <1531163335.17604.41.camel@brimstone.rchland.ibm.com> X-IsSubscribed: yes Hi, Add support for early gimple folding of vec_perm. Testcases are already in-tree as gcc.target/powerpc/fold-vec-perm-*.c OK for trunk? Thanks, -Will [gcc] 2018-07-09 Will Schmidt * gcc/config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Add support for folding vec_perm. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 1335661..7e4370c9 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -16155,10 +16155,41 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi) case ALTIVEC_BUILTIN_VUPKLPX: { return false; } + /* vec_perm. */ + case ALTIVEC_BUILTIN_VPERM_16QI: + case ALTIVEC_BUILTIN_VPERM_8HI: + case ALTIVEC_BUILTIN_VPERM_4SI: + case ALTIVEC_BUILTIN_VPERM_2DI: + case ALTIVEC_BUILTIN_VPERM_4SF: + case ALTIVEC_BUILTIN_VPERM_2DF: + { + arg0 = gimple_call_arg (stmt, 0); + arg1 = gimple_call_arg (stmt, 1); + tree permute = gimple_call_arg (stmt, 2); + lhs = gimple_call_lhs (stmt); + location_t loc = gimple_location (stmt); + gimple_seq stmts = NULL; + // convert arg0 and arg1 to match the type of the permute + // for the VEC_PERM_EXPR operation. + tree permute_type = (TREE_TYPE (permute)); + tree arg0_ptype = gimple_convert (&stmts, loc, permute_type, arg0); + tree arg1_ptype = gimple_convert (&stmts, loc, permute_type, arg1); + tree lhs_ptype = gimple_build (&stmts, loc, VEC_PERM_EXPR, + permute_type, arg0_ptype, arg1_ptype, + permute); + // Convert the result back to the desired lhs type upon completion. + tree temp = gimple_convert (&stmts, loc, TREE_TYPE (lhs), lhs_ptype); + gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); + g = gimple_build_assign (lhs, temp); + gimple_set_location (g, loc); + 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;