From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by sourceware.org (Postfix) with ESMTPS id 4027B3858D20; Fri, 14 Apr 2023 11:47:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4027B3858D20 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-lj1-x229.google.com with SMTP id l7so4341606ljq.11; Fri, 14 Apr 2023 04:47:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681472859; x=1684064859; 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=HTLLfFOKip4qrI7pzegZA1FxiWV0UBBoShS1ZGRrWRs=; b=NgnL1N9NMfzj382566kj3XkbyXQnocsmwTbuVENRvvZiNgq1Z9aVW47O2amona8oLZ jUgIW4mxCBJIs8wP9R5ggAE/kZavsHatYidYAKaPuevk5/wjAuMGeeAgnjkJzw6Pnzi3 OzEKurDRdvuXo3tSBXvnBOjhmO0yuFMyNXNqcFV7Uh+aY+MZ0KkpKmgHpZMdiRChtP9A HiWKx9px/8yaKWGXPlAgjRMSzFBMiu3R7E9Yn8kHRW/7vtvd6ZQrhBttnfMxDE08ku6k 32wSnfs9qqIe/fsk7ESAeIDCq4kwmMFsaAKQEr6sWKwJZ38QCIEnsiYOx/8DwQTsGw04 guUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681472859; x=1684064859; 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=HTLLfFOKip4qrI7pzegZA1FxiWV0UBBoShS1ZGRrWRs=; b=Sq6lSRqLX7nf0zUkMtMi2ftjy8uq5gUit1RO73vu2hAM8RkSO0EnoXMAmBrOqbB+kR 90PmJa0ibWzWp0pEGsZ1zf6zouDdgk0wI7xd7sejYqd1PjrpkeQ2n+7PMNJp2JzFjFh8 CHsSkWlz+J5jA7Qv0YQ6j/TRNsZhxCaJGAC0xAzVRQLipo8R2f/0U9iOUtUHzmFjxe5x vhBGigfZXLiOmLpjTJFTMNJGlVcg5cRRmhL6aCgpU8VngcA/1iDA/eosilzHD3OTL6SC KZdMwWuAvRbrv3vx57LE3aF+MpH1PGIKBo/Caqo7i0iQaBECMO9QrR9a+HgYI2UealDF 8j2Q== X-Gm-Message-State: AAQBX9cZdXrg5u6XKOZzXNtiU5hbuxFeysoxHfUF/KS0q9CZ5B3n+z3C E8ZcFYjES777n2c9j90bGGJ57Fl40swbzIRe7oZBLWW51rc= X-Google-Smtp-Source: AKy350bZuJrkxIM46EK4ZEsdFYGh5CG9ZmWGArKN2VUtQ7RCTDSbgJMv55NYuXXJVHvYAlfrvKVLXdaZdvOwoDtiw1M= X-Received: by 2002:a2e:940e:0:b0:29f:caf0:f77f with SMTP id i14-20020a2e940e000000b0029fcaf0f77fmr1847166ljh.3.1681472858305; Fri, 14 Apr 2023 04:47:38 -0700 (PDT) MIME-Version: 1.0 References: <202304130148.33D1mmns1987590@shliclel4214.sh.intel.com> <341dd608-a512-3c74-303d-1942876a3850@arm.com> In-Reply-To: From: Richard Biener Date: Fri, 14 Apr 2023 13:47:26 +0200 Message-ID: Subject: Re: [r13-7135 Regression] FAIL: gcc.dg/vect/vect-simd-clone-18f.c scan-tree-dump-times vect "[\\n\\r] [^\\n]* = foo\\.simdclone" 2 on Linux/x86_64 To: "Andre Vieira (lists)" Cc: Andrew Stubbs , "gcc-regression@gcc.gnu.org" , "gcc-patches@gcc.gnu.org" , "haochen.jiang@intel.com" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_NUMSUBJECT,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 Fri, Apr 14, 2023 at 11:42=E2=80=AFAM Andre Vieira (lists) wrote: > > > > On 14/04/2023 10:09, Richard Biener wrote: > > On Fri, Apr 14, 2023 at 10:43=E2=80=AFAM Andre Vieira (lists) > > wrote: > >> > >> Resending this to everyone (sorry for the double send Richard). > >> > >> On 14/04/2023 09:15, Andre Vieira (lists) wrote: > >> > > >> > > >> > On 14/04/2023 07:55, Richard Biener wrote: > >> >> On Thu, Apr 13, 2023 at 4:25=E2=80=AFPM Andre Vieira (lists) > >> >> wrote: > >> >>> > >> >>> > >> >>> > >> >>> On 13/04/2023 15:00, Richard Biener wrote: > >> >>>> On Thu, Apr 13, 2023 at 3:00=E2=80=AFPM Andre Vieira (lists) vi= a Gcc-patches > >> >>>> wrote: > >> >>>>> > >> >>>>> > >> >>>>> > >> >>> > >> >>> But that's not it, I've been looking at it, and there is code in= place > >> >>> that does what I expected which is defer the choice of vectype f= or simd > >> >>> clones until vectorizable_simd_clone_call, unfortunately it has = a > >> >>> mistaken assumption that simdclones don't return :/ > >> >> > >> >> I think that's not it - when the SIMD clone returns a vector we h= ave to > >> >> determine the vector type in this function. We cannot defer this= . > >> > > >> > What's 'this function' here, do you mean we have to determine the > >> > vectype in 'vect_get_vector_types_for_stmt' & > >> > 'vect_determine_vf_for_stmt' ? > > > > Yes. > > > >> Because at that time we don't yet know > >> > what clone we will be using, this choice is done inside > >> > vectorizable_simd_clone_call. In fact, to choose the simd clone, w= e need > >> > to know the vf as that has to be a multiple of the chosen clone's > >> > simdlen. So we simply can't use the simdclone's types (as that dep= ends > >> > on the simdlen) to choose the vf because the choice of simdlend de= pends > >> > on the vf. And there was already code in place to handle this, > >> > unfortunately that code was wrong and had the wrong assumption tha= t > >> > simdclones didn't return (probably was true at some point and bitr= otted). > > > > But to compute the VF we need to know the vector types! We're only > > calling vectorizable_* when the VF is final. That said, the code you q= uote: > > > >> >> > >> >>> see vect_get_vector_types_for_stmt: > >> >>> ... > >> >>> if (gimple_get_lhs (stmt) =3D=3D NULL_TREE > > > > is just for the case of a function without return value. For this case > > it's OK to do nothing - 'vectype' is the vector type of all vector defs > > a stmt produces. > > > > For calls with a LHS it should fall through to generic code doing > > get_vectype_for_scalar_type on the LHS type. > > I think that may work, but right now it will still go and look at the > arguments of the call and use the smallest type among them to adjust the > nunits (in 'vect_get_vector_types_for_stmt'). > > In fact (this is just for illustration) if I hack that function like this= : > --- a/gcc/tree-vect-stmts.cc > +++ b/gcc/tree-vect-stmts.cc > @@ -12745,8 +12745,11 @@ vect_get_vector_types_for_stmt (vec_info > *vinfo, stmt_vec_info stmt_info, > /* The number of units is set according to the smallest scalar > type (or the largest vector size, but we only support one > vector size per vectorization). */ > - scalar_type =3D vect_get_smallest_scalar_type (stmt_info, > - TREE_TYPE (vectype)); > + if (simd_clone_call_p (stmt_info->stmt)) > + scalar_type =3D TREE_TYPE (vectype); > + else > + scalar_type =3D vect_get_smallest_scalar_type (stmt_info, > + TREE_TYPE (vectype))= ; > if (scalar_type !=3D TREE_TYPE (vectype)) > { > if (dump_enabled_p ()) > > It will use the same types as before without (-m32), like I explained > before the -m32 turns the pointer inside MASK_CALL into a 32-bit pointer > so now the smallest size is 32-bits. This makes it pick V8SI instead of > the original V4DI (scalar return type is DImode). Changing the VF to 8, > thus unrolling the loop as it needs to make 2 calls, each handling 4 nuni= ts. Ah, but then vect_get_smallest_scalar_type should simply ignore that pointer in MASK_CALL. It should only look at the arguments relevant for vectorization. So diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc index 8daf7bd7dd3..70bb8595951 100644 --- a/gcc/tree-vect-data-refs.cc +++ b/gcc/tree-vect-data-refs.cc @@ -165,6 +165,8 @@ vect_get_smallest_scalar_type (stmt_vec_info stmt_info, tree scalar_type) } else if (internal_fn_mask_index (ifn) =3D=3D 0) i =3D 1; + else if (ifn =3D=3D IFN_MASK_CALL) + i =3D 1; } if (i < gimple_call_num_args (call)) { ? Richard. > >