From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by sourceware.org (Postfix) with ESMTPS id F12443858D28 for ; Thu, 4 May 2023 02:49:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F12443858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yb1-xb32.google.com with SMTP id 3f1490d57ef6-b99efd7c335so16431276.0 for ; Wed, 03 May 2023 19:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683168593; x=1685760593; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1KIgYGYqgRJ1lxvxM4WWILaK+t0CLgorAFDekyZzq70=; b=KGcL8ENK/9n8JrZaOVlUNZOTWsuwPms7gdSagCN3nIL/cOpLC3lznhj3inGzkWkNL1 +1ftVKv1Fq3gHojPV9PDYAyVuyKL6shicnza3keH0BdnWVnxjIKt3cQfcwT0R8rzmt8a KltpW080OpLVH/cwlleCHmVn+yDsR3iW26w2pkc215Lx3PPwGyO6MlY1xXORHOr+CVV7 E3JCqVfH22G12bzaXzCt5+87JnvNea0BGJPt8Q3ocVRiJTkZW91uPRX81PW/IAR34J/J vwP6enzAJgj4f2ozgZ6MpOUs6KwxzHbk8KEOQcjtt3tkTpb3QWg+3k1Zd/M/ijbsNed7 zwxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683168593; x=1685760593; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1KIgYGYqgRJ1lxvxM4WWILaK+t0CLgorAFDekyZzq70=; b=QQcgCJCflwKczl6sLhAxukTnT5AaiwW61nk3DEzd2V838VYC4caGhEOu2LcMbSLj+Q p1pV0F+4MhMVkqJOgAxrLN1mn1pFNppeZ3FOdEMDIYNa0IcHRGC7dY0BubKUz5pB0jIn MMulXLh09w6c3OrcZ4SAf/R3HEZItncgN8WNbtblz7XPrpEZirSR0f0dfwP46Cb70maG IgV+TAPI1guswIIldQcj1Nkgx+NiWI8Eh94F7DQhI4pF6iLoi8p8BtHDjqE4ZMT2fKeC 75AQ4OWMoDUKLytK/khFxP6Pr3PPcorSW8Mgk4kJhbZfWqh/AMbiYivG1OKq2clkpux3 Z9AA== X-Gm-Message-State: AC+VfDxnXh74uSbdrD5q0ST3/J98SplJNvUbhoy0t+d7TmSiHdXz7vCt khyeTRVEWXsCVTcwJM90X4rUcPszYGVdPRdHJZY= X-Google-Smtp-Source: ACHHUZ6rU3cl9lSrHc1Fs4nFgxRkZSg2yAi0x3JT2uUci3cm5EPB4ezstnNONGWEZ1iBDYHxFp1VxJPczxAjOW21VJc= X-Received: by 2002:a25:cf45:0:b0:b9d:bede:2366 with SMTP id f66-20020a25cf45000000b00b9dbede2366mr16353359ybg.20.1683168593302; Wed, 03 May 2023 19:49:53 -0700 (PDT) MIME-Version: 1.0 References: <20230420035821.4113007-1-hongtao.liu@intel.com> <1995c643-47bb-6376-ce72-d5440e59196b@gmail.com> In-Reply-To: <1995c643-47bb-6376-ce72-d5440e59196b@gmail.com> From: Hongtao Liu Date: Thu, 4 May 2023 10:49:42 +0800 Message-ID: Subject: Re: [PATCH] Canonicalize vec_merge when mask is constant. To: Jeff Law Cc: liuhongt , gcc-patches@gcc.gnu.org, hjl.tools@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 Mon, May 1, 2023 at 3:37=E2=80=AFAM Jeff Law wro= te: > > > > On 4/19/23 21:58, liuhongt via Gcc-patches wrote: > > Use swap_communattive_operands_p for canonicalization. When both value > > has same operand precedence value, then first bit in the mask should > > select first operand. > > > > The canonicalization should help backends for pattern match. .i.e. x86 > > backend has lots of vec_merge patterns, combine will create any form > > of vec_merge(mask, or inverted mask), then backend need to add 2 > > patterns to match exact 1 instruction. The canonicalization can > > simplify 2 patterns to 1. > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}, aarch64-linux= -gnu. > > Ok for trunk? > > > > gcc/ChangeLog: > > > > * combine.cc (maybe_swap_commutative_operands): Canonicalize > > vec_merge when mask is constant. > ISTM that if we're going to call this the canonical form, then we should > document it in rtl.texi. Yes., how about the wording: 1 file changed, 7 insertions(+) gcc/doc/md.texi | 7 +++++++ modified gcc/doc/md.texi @@ -8215,6 +8215,13 @@ second operand. If a machine only supports a constant as the second operand, only patterns that match a constant in the second operand need be supplied. +@cindex @code{vec_merge}, canonicalization of +@item +For the @code{vec_merge} with constant mask(the third operand), the first +and the second operand can be exchanged by inverting the mask. In such cas= es, +a constant is always made the second operand, otherwise the least signific= ant +bit of the mask is always set(select the first operand first). + @item For associative operators, a sequence of operators will always chain to the left; for instance, only the left operand of an integer @code{plus} > > Otherwise it looks pretty good to me. So let's get the docs updated and > get this installed. > > jeff --=20 BR, Hongtao