From patchwork Sun Oct 15 12:13:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Agarwal X-Patchwork-Id: 153007 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2900525vqb; Sun, 15 Oct 2023 05:13:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAzjNILHy/RthrZIgFHhCTPmUh1O4bX3g4NFPx9CBkfIYIhcOzvUXLoqeedN0Vgfo6hrQz X-Received: by 2002:a0c:8d07:0:b0:65b:232c:1546 with SMTP id r7-20020a0c8d07000000b0065b232c1546mr29750986qvb.24.1697372037224; Sun, 15 Oct 2023 05:13:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697372037; cv=pass; d=google.com; s=arc-20160816; b=UIXzrxsSIb/lQKUQwErKHYcRLZtTGfFzw4jABhN/bPsHnDvc7xHC830B1jd/luZjAS NI1EvaFymdVMfK8SCTkz7Rkr94BKpCKJNeLP+hUNcs0nO4Vi7M0AoQyouQOzZsYieZUD tSRMvk0R80ie7VrrmSX9MNy3+9wxkc0V37ASolIe1g7MhlGawg2HVB8TW8EHtt+RGKpu +Ln85vnajseDVhpQ0ubcVXpVihXjlqTDRSI3RETzwnd6KdgbGzQKadv/ngVOS3/FJooK qouLKpSz7KClZ5Y3lCl968tG27yTaR6wEcwVh92F6DbrEyxkNbBTdHc7NQIsyfgCvBxF +wPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:in-reply-to:from:cc:to:references :content-language:subject:user-agent:date:message-id:dkim-signature :dmarc-filter:arc-filter:delivered-to; bh=KBUNRlSPaNiCJ6cP+WREP2V/pY1x3fTKRII+unQ8Low=; fh=vRIz6gnEIFhwSqJfMQlt+nhXs97QBXboPZ8T9UgukMQ=; b=cJ7ZW7YCvg6EU/TtN4QpIvh2eMQvYG3Q4F85I2S2LkOm5XAONcIjgL7m4mMaFk0uGW dLVthOJjriwIvGSlnEiLzN6ToUGyyRVV2h+/m+IH3YxUOXVmA7dKjQHnDfVaBdpoKM4Q eAHSvtlIlLAMFixUef3ekXl3aYzK2p31CxIKSBp4bFD4oSLeTDfK0sU25B0/HQjNQFJ0 BK4gx2PRsqN/PSqxXq7hJ9JgxHV9nbNDMdpvB/w31k/3+rMYDIMrRNmpQQq3WhgWEeg/ ivcF/Lz88deK0mOa9UrG2vW1nfJirUCPEL0fnHcndC2kuK/jK4KU240FIq3+PnWg65y6 5Paw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=qmOjKwAq; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id es20-20020a056214193400b0065b0541ddb9si3865864qvb.93.2023.10.15.05.13.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 05:13:57 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=qmOjKwAq; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 01C6A385841A for ; Sun, 15 Oct 2023 12:13:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id E8B173858D33 for ; Sun, 15 Oct 2023 12:13:29 +0000 (GMT) ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E8B173858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697372012; cv=none; b=RgHlC5tbzxxIjdLuUsjwhTyDP97F9kGS1PiTUUacB6117+lUuqgxZqxEV2Tpm4AjhcMb9+EBtT9hLcfLUtPfBSQZGZjW+KByIQsw5xWwCJ4+fo9GPVbpFJE7myqBM/dAgpx8i+zZTNZUBNZiI+vcdrPSNYfJGUn1cpv7FnIckVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697372012; c=relaxed/simple; bh=YBPDFs/tgfp0H+bMHW8oSHHemyYrEUO+LnEtYsvSBAA=; h=DKIM-Signature:Message-ID:Date:Subject:To:From:MIME-Version; b=cq7QTd2fxGBLgqjgyQPGi1xE6uObRUiHOxmi/649w8GiU6n/bYIOAAS4h6ciguNFvCl52CIweG/TNZUrFKfgezCL7LMaKK62ZkNZNQMxb5+Yt9cJWojPVWsDAHMqWuRhGJcMpC+STToz6Yqovgg9zoVEuPMiTzaKqq3cjkDOikI= ARC-Authentication-Results: i=1; server2.sourceware.org DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E8B173858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39FCA3pb015889; Sun, 15 Oct 2023 12:13:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : subject : references : to : cc : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pp1; bh=KBUNRlSPaNiCJ6cP+WREP2V/pY1x3fTKRII+unQ8Low=; b=qmOjKwAqflAt3IPcMFiYKWudDUPiZDhiYY3U8twh90ENMyBY8LdCb/xOQdd5ulPAtHJt 49vYji0UJ49fo4gDvBUKaUq/Y1Xg8FgoF/m1d3TmR17NEqFHP0v5ELjHTZcWdsdl3aaI ICoT7GnK5cKGNI36+ki/Z13BQranKckNejzn3XE2+HVrn0i2wCBzn+/FfH7sKNYX5mt/ iAz+itwqCA3/K9UEjlcjZpYPNx3EJkRywheM8JB1k7gxXMuUq/EEgfivXHhZkj49uJuV kewFgfz2XqEB0YGSUmmRwc83mG41eXr6XAxRn0aeNBnFMQ/h+1zPS+/EgM/Q+ttRxTb0 Sg== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3trfugg271-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 15 Oct 2023 12:13:29 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 39FBMVoB012900; Sun, 15 Oct 2023 12:13:28 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3tr5pxttg5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 15 Oct 2023 12:13:28 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 39FCDRwd23069420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 15 Oct 2023 12:13:27 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B09858059; Sun, 15 Oct 2023 12:13:27 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE69E5805B; Sun, 15 Oct 2023 12:13:24 +0000 (GMT) Received: from [9.43.104.193] (unknown [9.43.104.193]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Sun, 15 Oct 2023 12:13:24 +0000 (GMT) Message-ID: <9bab1f7d-58fc-4c87-8306-ca54893f2145@linux.ibm.com> Date: Sun, 15 Oct 2023 17:43:24 +0530 User-Agent: Mozilla Thunderbird Subject: [PING ^0][PATCH v2] rs6000: Add new pass for replacement of contiguous addresses vector load lxv with lxvp Content-Language: en-US References: To: gcc-patches Cc: Segher Boessenkool , "Kewen.Lin" , Peter Bergner From: Ajit Agarwal In-Reply-To: X-Forwarded-Message-Id: X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Vp5SuAZ4vdBIVrSjJFMWGfRDDtA-YddH X-Proofpoint-ORIG-GUID: Vp5SuAZ4vdBIVrSjJFMWGfRDDtA-YddH X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-14_03,2023-10-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 impostorscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310150109 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779124678968931798 X-GMAIL-MSGID: 1779823581610203289 Hello All: Please review. Thanks & Regards Ajit -------- Forwarded Message -------- Subject: [PATCH v2] rs6000: Add new pass for replacement of contiguous addresses vector load lxv with lxvp Date: Sun, 8 Oct 2023 00:34:27 +0530 From: Ajit Agarwal To: gcc-patches CC: Segher Boessenkool , Peter Bergner , Kewen.Lin Hello All: This patch add new pass to replace contiguous addresses vector load lxv with mma instruction lxvp. This patch addresses one regressions failure in ARM architecture. Bootstrapped and regtested with powepc64-linux-gnu. Thanks & Regards Ajit rs6000: Add new pass for replacement of contiguous lxv with lxvp. New pass to replace contiguous addresses lxv with lxvp. This pass is registered after ree rtl pass. 2023-10-07 Ajit Kumar Agarwal gcc/ChangeLog: * config/rs6000/rs6000-passes.def: Registered vecload pass. * config/rs6000/rs6000-vecload-opt.cc: Add new pass. * config.gcc: Add new executable. * config/rs6000/rs6000-protos.h: Add new prototype for vecload pass. * config/rs6000/rs6000.cc: Add new prototype for vecload pass. * config/rs6000/t-rs6000: Add new rule. gcc/testsuite/ChangeLog: * g++.target/powerpc/vecload.C: New test. --- gcc/config.gcc | 4 +- gcc/config/rs6000/rs6000-passes.def | 1 + gcc/config/rs6000/rs6000-protos.h | 2 + gcc/config/rs6000/rs6000-vecload-opt.cc | 234 +++++++++++++++++++++ gcc/config/rs6000/rs6000.cc | 3 +- gcc/config/rs6000/t-rs6000 | 4 + gcc/testsuite/g++.target/powerpc/vecload.C | 15 ++ 7 files changed, 260 insertions(+), 3 deletions(-) create mode 100644 gcc/config/rs6000/rs6000-vecload-opt.cc create mode 100644 gcc/testsuite/g++.target/powerpc/vecload.C diff --git a/gcc/config.gcc b/gcc/config.gcc index ee46d96bf62..482ab094b89 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -515,7 +515,7 @@ or1k*-*-*) ;; powerpc*-*-*) cpu_type=rs6000 - extra_objs="rs6000-string.o rs6000-p8swap.o rs6000-logue.o" + extra_objs="rs6000-string.o rs6000-p8swap.o rs6000-logue.o rs6000-vecload-opt.o" extra_objs="${extra_objs} rs6000-call.o rs6000-pcrel-opt.o" extra_objs="${extra_objs} rs6000-builtins.o rs6000-builtin.o" extra_headers="ppc-asm.h altivec.h htmintrin.h htmxlintrin.h" @@ -552,7 +552,7 @@ riscv*) ;; rs6000*-*-*) extra_options="${extra_options} g.opt fused-madd.opt rs6000/rs6000-tables.opt" - extra_objs="rs6000-string.o rs6000-p8swap.o rs6000-logue.o" + extra_objs="rs6000-string.o rs6000-p8swap.o rs6000-logue.o rs6000-vecload-opt.o" extra_objs="${extra_objs} rs6000-call.o rs6000-pcrel-opt.o" target_gtfiles="$target_gtfiles \$(srcdir)/config/rs6000/rs6000-logue.cc \$(srcdir)/config/rs6000/rs6000-call.cc" target_gtfiles="$target_gtfiles \$(srcdir)/config/rs6000/rs6000-pcrel-opt.cc" diff --git a/gcc/config/rs6000/rs6000-passes.def b/gcc/config/rs6000/rs6000-passes.def index ca899d5f7af..9ecf8ce6a9c 100644 --- a/gcc/config/rs6000/rs6000-passes.def +++ b/gcc/config/rs6000/rs6000-passes.def @@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see The power8 does not have instructions that automaticaly do the byte swaps for loads and stores. */ INSERT_PASS_BEFORE (pass_cse, 1, pass_analyze_swaps); + INSERT_PASS_AFTER (pass_ree, 1, pass_analyze_vecload); /* Pass to do the PCREL_OPT optimization that combines the load of an external symbol's address along with a single load or store using that diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h index f70118ea40f..9c44bae33d3 100644 --- a/gcc/config/rs6000/rs6000-protos.h +++ b/gcc/config/rs6000/rs6000-protos.h @@ -91,6 +91,7 @@ extern int mems_ok_for_quad_peep (rtx, rtx); extern bool gpr_or_gpr_p (rtx, rtx); extern bool direct_move_p (rtx, rtx); extern bool quad_address_p (rtx, machine_mode, bool); +extern bool mode_supports_dq_form (machine_mode); extern bool quad_load_store_p (rtx, rtx); extern bool fusion_gpr_load_p (rtx, rtx, rtx, rtx); extern void expand_fusion_gpr_load (rtx *); @@ -344,6 +345,7 @@ class rtl_opt_pass; extern rtl_opt_pass *make_pass_analyze_swaps (gcc::context *); extern rtl_opt_pass *make_pass_pcrel_opt (gcc::context *); +extern rtl_opt_pass *make_pass_analyze_vecload (gcc::context *); extern bool rs6000_sum_of_two_registers_p (const_rtx expr); extern bool rs6000_quadword_masked_address_p (const_rtx exp); extern rtx rs6000_gen_lvx (enum machine_mode, rtx, rtx); diff --git a/gcc/config/rs6000/rs6000-vecload-opt.cc b/gcc/config/rs6000/rs6000-vecload-opt.cc new file mode 100644 index 00000000000..63ee733af89 --- /dev/null +++ b/gcc/config/rs6000/rs6000-vecload-opt.cc @@ -0,0 +1,234 @@ +/* Subroutines used to replace lxv with lxvp + for p10 little-endian VSX code. + Copyright (C) 2020-2023 Free Software Foundation, Inc. + Contributed by Ajit Kumar Agarwal . + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#define IN_TARGET_CODE 1 + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "backend.h" +#include "rtl.h" +#include "tree.h" +#include "memmodel.h" +#include "df.h" +#include "tm_p.h" +#include "ira.h" +#include "print-tree.h" +#include "varasm.h" +#include "explow.h" +#include "expr.h" +#include "output.h" +#include "tree-pass.h" +#include "regs.h" +#include "rtx-vector-builder.h" +#include "rs6000-protos.h" + +static inline bool +quad_address_offset_p (HOST_WIDE_INT offset) +{ + return (IN_RANGE (offset, -32768, 32767) && ((offset) & 0xf) == 0); +} + +/* Replace identified lxv with lxvp. */ +static void +replace_lxv_with_lxvp (rtx_insn *insn1, rtx_insn *insn2) +{ + rtx body = PATTERN (insn1); + rtx src_exp = SET_SRC (body); + rtx dest_exp = SET_DEST (body); + rtx lxv; + rtx insn2_body = PATTERN (insn2); + rtx insn2_dest_exp = SET_DEST (insn2_body); + unsigned int regno = REGNO (dest_exp); + + if (regno > REGNO (insn2_dest_exp)) + { + df_set_regs_ever_live (REGNO (dest_exp), false); + df_set_regs_ever_live (REGNO (insn2_dest_exp), true); + SET_REGNO (dest_exp, REGNO (insn2_dest_exp)); + dest_exp->used = 1; + df_set_regs_ever_live (REGNO (insn2_dest_exp), false); + df_set_regs_ever_live (regno, true); + SET_REGNO (insn2_dest_exp, regno); + insn2_dest_exp->used = 1; + } + rtx opnd = gen_rtx_REG (OOmode, REGNO (dest_exp)); + PUT_MODE (src_exp, OOmode); + lxv = gen_movoo (opnd, src_exp); + rtx_insn *new_insn = emit_insn_before (lxv, insn1); + set_block_for_insn (new_insn, BLOCK_FOR_INSN (insn1)); + df_insn_rescan (new_insn); + + if (dump_file) + { + unsigned int new_uid = INSN_UID (new_insn); + fprintf (dump_file, "Replacing lxv %d with lxvp %d\n", + INSN_UID (insn1), new_uid); + } + df_insn_delete (insn1); + remove_insn (insn1); + df_insn_delete (insn2); + remove_insn (insn2); + insn1->set_deleted (); + insn2->set_deleted (); +} + +/* Identify lxv instruction that are candidate of continguous + addresses and replace them with mma instruction lxvp. */ +unsigned int +rs6000_analyze_vecload (function *fun) +{ + basic_block bb; + rtx_insn *insn, *curr_insn = 0; + rtx_insn *insn1 = 0, *insn2 = 0; + bool first_vec_insn = false; + unsigned int offset = 0; + unsigned int regno = 0; + + FOR_ALL_BB_FN (bb, fun) + FOR_BB_INSNS_SAFE (bb, insn, curr_insn) + { + if (NONDEBUG_INSN_P (insn) && GET_CODE (PATTERN (insn)) == SET) + { + rtx set = single_set (insn); + rtx src = SET_SRC (set); + machine_mode mode = GET_MODE (SET_DEST (set)); + bool dest_fp_p, dest_vmx_p, dest_vsx_p = false; + rtx dest = SET_DEST (PATTERN (insn)); + int dest_regno; + + if (REG_P (dest)) + { + dest_regno = REGNO (dest); + dest_fp_p = FP_REGNO_P (dest_regno); + dest_vmx_p = ALTIVEC_REGNO_P (dest_regno); + dest_vsx_p = dest_fp_p | dest_vmx_p; + } + else + { + dest_regno = -1; + dest_fp_p = dest_vmx_p = dest_vsx_p = false; + } + + if (TARGET_VSX && TARGET_MMA && dest_vsx_p) + { + if (mode_supports_dq_form (mode) + && dest_regno >= 0 && MEM_P (src) + && quad_address_p (XEXP (src, 0), mode, true)) + { + if (first_vec_insn) + { + rtx addr = XEXP (src, 0); + insn2 = insn; + + if (GET_CODE (addr) != PLUS) + return false; + + rtx op0 = XEXP (addr, 0); + if (!REG_P (op0) || !INT_REG_OK_FOR_BASE_P (op0, true)) + return false; + + rtx op1 = XEXP (addr, 1); + if (!CONST_INT_P (op1)) + return false; + + mem_attrs attrs (*get_mem_attrs (src)); + bool reg_attrs_found = false; + + if (REG_P (dest) && REG_ATTRS (dest)) + { + poly_int64 off = REG_ATTRS (dest)->offset; + if (known_ge (off, 0)) + reg_attrs_found = true; + } + if ((attrs.offset_known_p && known_ge (attrs.offset, 0)) + && reg_attrs_found + && quad_address_offset_p (INTVAL (op1)) + && (regno == REGNO (op0)) + && ((INTVAL (op1) - offset) == 16)) + { + replace_lxv_with_lxvp (insn1, insn2); + return true; + } + } + if (REG_P (XEXP (src, 0)) + && GET_CODE (XEXP (src, 0)) != PLUS) + { + mem_attrs attrs (*get_mem_attrs (src)); + if (attrs.offset_known_p) + offset = attrs.offset; + if (offset == 0 && REG_P (dest) && REG_ATTRS (dest)) + offset = REG_ATTRS (dest)->offset; + regno = REGNO (XEXP (src,0)); + first_vec_insn = true; + insn1 = insn; + } + } + } + } + } + return false; +} + +const pass_data pass_data_analyze_vecload = +{ + RTL_PASS, /* type */ + "vecload", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_NONE, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_df_finish, /* todo_flags_finish */ +}; + +class pass_analyze_vecload : public rtl_opt_pass +{ +public: + pass_analyze_vecload(gcc::context *ctxt) + : rtl_opt_pass(pass_data_analyze_vecload, ctxt) + {} + + /* opt_pass methods: */ + virtual bool gate (function *) + { + return (optimize > 0 && TARGET_VSX); + } + + virtual unsigned int execute (function *fun) + { + return rs6000_analyze_vecload (fun); + } + + opt_pass *clone () + { + return new pass_analyze_vecload (m_ctxt); + } + +}; // class pass_analyze_vecload + +rtl_opt_pass * +make_pass_analyze_vecload (gcc::context *ctxt) +{ + return new pass_analyze_vecload (ctxt); +} + diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index cc9253bb040..dba545271e0 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -387,7 +387,7 @@ mode_supports_vmx_dform (machine_mode mode) /* Return true if we have D-form addressing in VSX registers. This addressing is more limited than normal d-form addressing in that the offset must be aligned on a 16-byte boundary. */ -static inline bool +bool mode_supports_dq_form (machine_mode mode) { return ((reg_addr[mode].addr_mask[RELOAD_REG_ANY] & RELOAD_REG_QUAD_OFFSET) @@ -1178,6 +1178,7 @@ static bool rs6000_secondary_reload_move (enum rs6000_reg_type, secondary_reload_info *, bool); rtl_opt_pass *make_pass_analyze_swaps (gcc::context*); +rtl_opt_pass *make_pass_analyze_vecload (gcc::context*); /* Hash table stuff for keeping track of TOC entries. */ diff --git a/gcc/config/rs6000/t-rs6000 b/gcc/config/rs6000/t-rs6000 index f183b42ce1d..da7ae26e88b 100644 --- a/gcc/config/rs6000/t-rs6000 +++ b/gcc/config/rs6000/t-rs6000 @@ -47,6 +47,10 @@ rs6000-builtin.o: $(srcdir)/config/rs6000/rs6000-builtin.cc $(COMPILE) $< $(POSTCOMPILE) +rs6000-vecload-opt.o: $(srcdir)/config/rs6000/rs6000-vecload-opt.cc + $(COMPILE) $< + $(POSTCOMPILE) + build/rs6000-gen-builtins.o: $(srcdir)/config/rs6000/rs6000-gen-builtins.cc build/rbtree.o: $(srcdir)/config/rs6000/rbtree.cc diff --git a/gcc/testsuite/g++.target/powerpc/vecload.C b/gcc/testsuite/g++.target/powerpc/vecload.C new file mode 100644 index 00000000000..f1689ad6522 --- /dev/null +++ b/gcc/testsuite/g++.target/powerpc/vecload.C @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_p9vector_ok } */ +/* { dg-options "-mdejagnu-cpu=power10 -O2 -mmma" } */ + +#include + +void +foo (__vector_quad *dst, vector unsigned char *ptr, vector unsigned char src) +{ + __vector_quad acc; + __builtin_mma_xvf32ger(&acc, src, ptr[0]); + __builtin_mma_xvf32gerpp(&acc, src, ptr[1]); + *dst = acc; +} +/* { dg-final { scan-assembler {\mlxvp\M} } } */