From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id 55CDB3858C74 for ; Fri, 17 Nov 2023 08:48:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 55CDB3858C74 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 55CDB3858C74 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700210883; cv=none; b=LrqT5YT423iRT8x3kVKqQKWBmyjPXIBQbTArM7tSfNJoaMW6velkbXD12HU232lNd6H4CGWltVl00ZHemSkdiCAAEz+XRg/L5YCXaTwTHi85CLzgzlrlGVWlyWlo89xIA/svVYf/a66Lq/d4MEyS95CyPOoJP3z2IBPrzQH7zrM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700210883; c=relaxed/simple; bh=crVxSmE36m6Orcx7IB+MNC1esbOUdtMOR87mIBCEXlY=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=ut8pQU6SJFX1QtWmHQJOrmldl7MPjfmM4JM+KF+1c/JPZzzMhTufBeAT9ZPlUH2SLne8FQhcTtKZQENP+AsaVGKS57Wt4lPEWBBI29luMvCqKjPvYVvgL41yRNetd5th7BiRzj33SJ6W0nQrYeTXiR66xCX9l9TXLZHqS/Ce0MI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-5094cb3a036so2601651e87.2 for ; Fri, 17 Nov 2023 00:48:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700210880; x=1700815680; darn=gcc.gnu.org; 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=1vGi+Nu5kSdFnDUO+TFFfn7p5Tt/1XNPUIGQ5j0Bl04=; b=IU1rmbi0b7a39Vgy8Tw6izKF0baLHfX0vcJqJRTnw83tcUXsltKei0vtwdZz/PlZQu ObLGJTzasiSKBONPQTvZ2jYXGSgqHlyZQsFgHrsCu2UVR5U32asBJdB871IxbOh0mcQP 808gegNMvwsWi/ZGQAzm6naHfxYaM+QkxrGV16uiQtqsv9AE7dw7yvm0ZL6WcX4S47sx EE2LW7bHXtqnN21PTXh2irGoMMxgOsD4+yMCVYqfl2J1tHMYxCjfDv+q4wLYQw23ISX3 76xRI46eSoCoNjlrWI72rRcj8i15eClZxx0o9vjx6AtTTOw4s4vAeoGF28mQmHeHKEp8 Y1ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700210880; x=1700815680; 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=1vGi+Nu5kSdFnDUO+TFFfn7p5Tt/1XNPUIGQ5j0Bl04=; b=SybQVcUX9fi3Bjta+2YWeDHfJndaUdISFidc39slcaUvUPEjERtGYtRvF88MvfS2IW dNaOYIDkuqQJ/B/wz8celaO3hE7pbVjB5LuqD7NQyIfjWlCzk4nlSgsbFqKnglukhKDp I3JQ6Cc3+qLOJdINq/bUqCL/18b9gDBSpTuShTocjfFUTUz86FDDe9tu0YoYJt3dikCo XN76c5YltIY+F0KF0HiBAGcizVOHgL+njgGdUcxFUCXw3FV4sGvp9aqR+Tn0YoQlD7l4 HKxpRPkDZux7AALRDKTJ4cSB2kUW7yfADeDcIRfqIvSi65dsnjIrdqYic1Ve8aFQ279+ FeNQ== X-Gm-Message-State: AOJu0Yx1vMIxMMuVDhehTl7hHTx+gcOOkZ9+TBpcNh39/xCB2h6nE2Hp EvJ4edfvSOKigQMzHH4FSsjUq5mSg9LFuwVV6HY= X-Google-Smtp-Source: AGHT+IHmUNWnjEco9aA4JpH1RlD92zSjPsAxqSIuRd0R7a/oa71VvVK07Fi4J/EeCJKxBqCzgEDR38Byk/6s3SAt8hk= X-Received: by 2002:a05:6512:3082:b0:50a:a243:3eb2 with SMTP id z2-20020a056512308200b0050aa2433eb2mr259526lfd.36.1700210879703; Fri, 17 Nov 2023 00:47:59 -0800 (PST) MIME-Version: 1.0 References: <0424a09b-6867-4be9-8207-9d92a6187191@gmail.com> In-Reply-To: <0424a09b-6867-4be9-8207-9d92a6187191@gmail.com> From: Richard Biener Date: Fri, 17 Nov 2023 09:47:47 +0100 Message-ID: Subject: Re: [PATCH] vect: Use statement vectype for conditional mask. To: Robin Dapp Cc: Richard Sandiford , gcc-patches , Tamar Christina Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,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, Nov 17, 2023 at 9:45=E2=80=AFAM Robin Dapp wr= ote: > > > But note you can explicitly specify a vector type as well, there's an > > overload for it, so we can fix the "invariant" case with the following > > (OK if you can test this on relevant targets) > > > > diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc > > index 3f59139cb01..936a3de9534 100644 > > --- a/gcc/tree-vect-loop.cc > > +++ b/gcc/tree-vect-loop.cc > > @@ -8450,12 +8450,14 @@ vect_transform_reduction (loop_vec_info loop_vi= nfo, > > value. */ > > bool cond_fn_p =3D code.is_internal_fn () > > && conditional_internal_fn_code (internal_fn (code)) !=3D ERROR_MA= RK; > > + int cond_index =3D -1; > > if (cond_fn_p) > > { > > gcc_assert (code =3D=3D IFN_COND_ADD || code =3D=3D IFN_COND_SUB > > || code =3D=3D IFN_COND_MUL || code =3D=3D IFN_COND_A= ND > > || code =3D=3D IFN_COND_IOR || code =3D=3D IFN_COND_X= OR); > > gcc_assert (op.num_ops =3D=3D 4 && (op.ops[1] =3D=3D op.ops[3]))= ; > > + cond_index =3D 0; > > } > > > > bool masked_loop_p =3D LOOP_VINFO_FULLY_MASKED_P (loop_vinfo); > > @@ -8486,12 +8488,13 @@ vect_transform_reduction (loop_vec_info loop_vi= nfo, > > vect_get_vec_defs (loop_vinfo, stmt_info, slp_node, ncopies, > > single_defuse_cycle && reduc_index =3D=3D 0 > > ? NULL_TREE : op.ops[0], &vec_oprnds0, > > + cond_index =3D=3D 0 ? truth_type_for (vectype_in) = : NULL_TREE, > > single_defuse_cycle && reduc_index =3D=3D 1 > > - ? NULL_TREE : op.ops[1], &vec_oprnds1, > > + ? NULL_TREE : op.ops[1], &vec_oprnds1, NULL_TREE, > > op.num_ops =3D=3D 4 > > || (op.num_ops =3D=3D 3 > > && !(single_defuse_cycle && reduc_index =3D=3D= 2)) > > - ? op.ops[2] : NULL_TREE, &vec_oprnds2); > > + ? op.ops[2] : NULL_TREE, &vec_oprnds2, NULL_TREE); > > Ah, yes that's what I meant. I had something along those lines: > > + if (!cond_fn_p) > + { > + vect_get_vec_defs (loop_vinfo, stmt_info, slp_node, ncopies, > + single_defuse_cycle && reduc_index =3D=3D 0 > + ? NULL_TREE : op.ops[0], &vec_oprnds0, > + single_defuse_cycle && reduc_index =3D=3D 1 > + ? NULL_TREE : op.ops[1], &vec_oprnds1, > + op.num_ops =3D=3D 3 > + && !(single_defuse_cycle && reduc_index =3D=3D 2= ) > + ? op.ops[2] : NULL_TREE, &vec_oprnds2); > + } > + else > + { > + /* For a conditional operation, pass the truth type as vectype for= the > + mask. */ > + gcc_assert (single_defuse_cycle && reduc_index =3D=3D 1); > + vect_get_vec_defs (loop_vinfo, stmt_info, slp_node, ncopies, > + op.ops[0], &vec_oprnds0, > + truth_type_for (vectype_in), > + NULL_TREE, &vec_oprnds1, NULL_TREE, > + op.ops[2], &vec_oprnds2, NULL_TREE); > + } > > Even though this has a bit of duplication now I prefer it slightly > because of the. I'd hope, once fully tested (it's already running > but I'm having connection problems so don't know about the results > yet), this could go in independently of the pattern fix? Yes, your version is also OK. Thanks, Richard. > > Regards > Robin >