From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id DF49B3858C52 for ; Fri, 23 Sep 2022 06:53:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DF49B3858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663915997; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=I2g2uHTAcI+AWnN46yqqxQ8A7tsVmRpkJcapQDqIgsk=; b=BDZFu1DYN+REOZq5T+Ya1JooJQYyjSldoAnkcvxA7QdgmEimZCm1y+HLYxHcFe+pbprqSA pxg6djvhdl2v6nU+zhK8iD5CyGklS1mcGyUve8n4RCWVUgkNfp3EgTC1p7FySIUMW1i0L4 oKY4G6S4QsGGDdVLi0MQISCRTawKTnQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-524-fczQIQn4MaS7Cu6LHLdKxA-1; Fri, 23 Sep 2022 02:53:16 -0400 X-MC-Unique: fczQIQn4MaS7Cu6LHLdKxA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 10B5E1C04B57; Fri, 23 Sep 2022 06:53:16 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C36462166B29; Fri, 23 Sep 2022 06:53:15 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 28N6rDim184112 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 23 Sep 2022 08:53:13 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 28N6rCMB184111; Fri, 23 Sep 2022 08:53:12 +0200 Date: Fri, 23 Sep 2022 08:53:12 +0200 From: Jakub Jelinek To: liuhongt Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] [x86] Support 2-instruction vector shuffle for V4SI/V4SF in ix86_expand_vec_perm_const_1. Message-ID: Reply-To: Jakub Jelinek References: <20220923064254.326775-1-hongtao.liu@intel.com> MIME-Version: 1.0 In-Reply-To: <20220923064254.326775-1-hongtao.liu@intel.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,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 List-Id: On Fri, Sep 23, 2022 at 02:42:54PM +0800, liuhongt via Gcc-patches wrote: > 2022-09-23 Hongtao Liu > Liwei Xu > > gcc/ChangeLog: > > PR target/53346 > * config/i386/i386-expand.cc (expand_vec_perm_shufps_shufps): > New function. > (ix86_expand_vec_perm_const_1): Insert > expand_vec_perm_shufps_shufps at the end of 2-instruction > expand sequence. > > gcc/testsuite/ChangeLog: > > * gcc.target/i386/pr53346-1.c: New test. > * gcc.target/i386/pr53346-2.c: New test. > --- > gcc/config/i386/i386-expand.cc | 117 ++++++++++++++++++++++ > gcc/testsuite/gcc.target/i386/pr53346-1.c | 70 +++++++++++++ > gcc/testsuite/gcc.target/i386/pr53346-2.c | 59 +++++++++++ > gcc/testsuite/gcc.target/i386/pr53346-3.c | 69 +++++++++++++ > gcc/testsuite/gcc.target/i386/pr53346-4.c | 59 +++++++++++ > 5 files changed, 374 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/i386/pr53346-1.c > create mode 100644 gcc/testsuite/gcc.target/i386/pr53346-2.c > create mode 100644 gcc/testsuite/gcc.target/i386/pr53346-3.c > create mode 100644 gcc/testsuite/gcc.target/i386/pr53346-4.c > > diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc > index 5334363e235..43c58111a62 100644 > --- a/gcc/config/i386/i386-expand.cc > +++ b/gcc/config/i386/i386-expand.cc > @@ -19604,6 +19604,120 @@ expand_vec_perm_1 (struct expand_vec_perm_d *d) > return false; > } > > +/* A subroutine of ix86_expand_vec_perm_const_1. Try to implement D > + in terms of a pair of shufps+ shufps/pshufd instructions. */ > +static bool > +expand_vec_perm_shufps_shufps (struct expand_vec_perm_d *d) > +{ > + unsigned char perm1[4]; > + machine_mode vmode = d->vmode; > + bool ok; > + unsigned i, j, k, count = 0; > + > + if (d->one_operand_p > + || (vmode != V4SImode && vmode != V4SFmode)) > + return false; > + > + if (d->testing_p) > + return true; > + > + for (i = 0; i < 4; ++i) > + count += d->perm[i] > 3 ? 1 : 0; > + > + gcc_assert(count & 3); Missing space before ( > + /* shufps. */ > + ok = expand_vselect_vconcat(tmp, d->op0, d->op1, > + perm1, d->nelt, false); Ditto. > + /* When lone_idx is not 0, it must from second op(count == 1). */ > + gcc_assert ((lone_idx == 0 && count == 3) > + || (lone_idx != 0 && count == 1)); Perhaps write it more simply as gcc_assert (count == (lone_idx ? 1 : 3)); ? > + /* shufps. */ > + ok = expand_vselect_vconcat(tmp, d->op0, d->op1, > + perm1, d->nelt, false); Missing space before ( > + gcc_assert (ok); > + > + /* Refine lone and pair index to original order. */ > + perm1[shift] = lone_idx << 1; > + perm1[shift + 1] = pair_idx << 1; > + > + /* Select the remaining 2 elements in another vector. */ > + for (i = 2 - shift; i < 4 - shift; ++i) > + perm1[i] = (lone_idx == 1) ? (d->perm[i] + 4) : d->perm[i]; All the ()s in the above line aren't needed. > + /* shufps. */ > + ok = expand_vselect_vconcat(d->target, tmp, d->op1, > + perm1, d->nelt, false); Again, missing space Otherwise LGTM Jakub