From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by sourceware.org (Postfix) with ESMTPS id 245663858D28 for ; Mon, 19 Jun 2023 08:47:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 245663858D28 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-yw1-x112b.google.com with SMTP id 00721157ae682-5700e993f37so64404507b3.0 for ; Mon, 19 Jun 2023 01:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687164428; x=1689756428; 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=8Ys4P5bDmB8X55Sg2sTQTjA2t5riSncGevl1UtRAFy8=; b=nLpO9qDxIq4uKGbnEFU/ucsUb7halLkz/lmxfS9UGc799oRA0fm0CW97UU5VvxDLOb QIUCw+IvSYeA/OVez5qtTU7zEartfPX6dJ9qyprKOUx5NXigzBno0EB00mIMB8r3vkXO X0BMBTAFcNnhgaKsKgJM3rGLSfGxeMIMmjYIo0wm4T4IzmWGs5WTikvr2K8Xc95iqRE5 SHmlXUHzy+wJjcRt19brfeqNY7IMdHarebuzwT8DZJj4v4obs2OOkTRrlaP5pKSdac9T pfJ8fSkffv/jQUlgTqIQeaxdaPkT9/LZMvTYl8bUDv0lUyHUKUR3lPMdiHtScO9kkmgI LNuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687164428; x=1689756428; 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=8Ys4P5bDmB8X55Sg2sTQTjA2t5riSncGevl1UtRAFy8=; b=YCbJ0i6IRgcysJa2Vu/JfEUAWkfxhLGT7peSPHnsUO5QuYFEBmaFOM02UQe2qdoZfj KYCA6anE0DwlS+HRWgwgKnzwXOCDeBsCi0NCJNgl0lWHo30FFTet+O1qgWDfYmcX0Brp BiRcUBL3bQ3Mp4yzC6IjjmqRVSdNVE7AqynPvM0qoiWhOOwuviiVOJIsXPA2XtamMuUG etFQ6HlQCM27qC+xPsK8Nccez9ypPIxlohnw6OEXu7CtF/T/LSEljH4m/FBVqK5FC2sl Cg9GdoPI6JbDoRROY9133Zz7mr7gIWS7Zee6zgOnhYCzB30IBHD1KW38R0ykeJwDKlMl D+fw== X-Gm-Message-State: AC+VfDyiWLnmoMbnv42Tj7tt7ovRGZA0j1KatedChmmbsjiCopUi/aNh rbqE3LybxkcyrJhJZJHwKJb+VTMHkh6ScDTlFD8= X-Google-Smtp-Source: ACHHUZ7UzHDzJ6Ft80M5eXyW+fCMv/lcQZTqadfoEUKduvtlObN0zOdAih4Z58ByfcbZ/W2n27zUr3z/S00YfJhHqRY= X-Received: by 2002:a25:b0a0:0:b0:bc8:42db:2c07 with SMTP id f32-20020a25b0a0000000b00bc842db2c07mr6229539ybj.25.1687164428468; Mon, 19 Jun 2023 01:47:08 -0700 (PDT) MIME-Version: 1.0 References: <5aa77cbb-02cc-195b-c052-22c2d993a966@suse.com> In-Reply-To: <5aa77cbb-02cc-195b-c052-22c2d993a966@suse.com> From: Hongtao Liu Date: Mon, 19 Jun 2023 16:46:57 +0800 Message-ID: Subject: Re: [PATCH v2] x86: make VPTERNLOG* usable on less than 512-bit operands with just AVX512F To: Jan Beulich Cc: "Liu, Hongtao" , Kirill Yukhin , "gcc-patches@gcc.gnu.org" 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, Jun 19, 2023 at 3:09=E2=80=AFPM Jan Beulich via Gcc-patches wrote: > > On 19.06.2023 04:07, Liu, Hongtao wrote: > >> -----Original Message----- > >> From: Jan Beulich > >> Sent: Friday, June 16, 2023 2:22 PM > >> > >> --- a/gcc/config/i386/sse.md > >> +++ b/gcc/config/i386/sse.md > >> @@ -12597,11 +12597,11 @@ > >> (set_attr "mode" "")]) > >> > >> (define_insn "*_vternlog_all" > >> - [(set (match_operand:V 0 "register_operand" "=3Dv") > >> + [(set (match_operand:V 0 "register_operand" "=3Dv,v") > >> (unspec:V > >> - [(match_operand:V 1 "register_operand" "0") > >> - (match_operand:V 2 "register_operand" "v") > >> - (match_operand:V 3 "bcst_vector_operand" "vmBr") > >> + [(match_operand:V 1 "register_operand" "0,0") > >> + (match_operand:V 2 "register_operand" "v,v") > >> + (match_operand:V 3 "bcst_vector_operand" "vBr,m") > >> (match_operand:SI 4 "const_0_to_255_operand")] > >> UNSPEC_VTERNLOG))] > >> "TARGET_AVX512F > > Change condition to =3D=3D 64 || TARGET_AVX512VL || (TARGET= _AVX512F && !TARGET_PREFER_AVX256) > > May I ask why you think this is necessary? The condition of the insn > already wasn't in sync with the condition used in all three splitters, I think it's a latent bug for the original *_vternlog_all, it should be =3D=3D 64 || TARGET_AVX512VL instead of TARGET_AVX512F, since TARGET_AVX512VL is needed for 128/256-bit vectors. The bug won't be exposed since the pattern is only generated by those 3 splitters which are guarded by TARGET_AVX512VL. But We can just fix this to make the pattern exactly correct. > and I didn't see any reason why now they would need to be brought in > sync. First and foremost because of the use of the UNSPEC (equally > before and after this patch). > > Furthermore, isn't it the case that I'm already mostly expressing > this with the "enabled" attribute? At the very least I think I > should drop that again then if following your request? You only handle alternative 1, but for alternative 0, it is still enabled when TARGET_PREFER_AVX256 && !TARGET_AVX512VL for 128/256-bit vectors. You don't need the drop that, alternative 1 still needs =3D=3D 64 || TARGET_AVX512VL since memory_operand can't be operated with the zmm instruction for 128/256-bit vectors. > > > Also please add a testcase for case TARGET_AVX512F && !TARGET_PREFER_AV= X256. > > Especially in a case like this one I'm wondering about the usefulness > of a contrived testcase: It won't test more than one minor sub-case of > the whole set of constructs covered here. But well, here as well as > for the other change I'll invent something. We don't need all sub-case, one is enough to guard that your optimization won't be corrupted by a later commit. .i.e typedef int v4si __attribute((vector_size(16))); v4si foo (v4si a, v4si b, v4si c) { return (a & b) | c; } We can now generate vpternlog with -mavx512f -O2 -mno-avx512vl -mprefer-vector-width=3D512. > > Jan --=20 BR, Hongtao