From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 1B1763858C53 for ; Fri, 10 Nov 2023 09:33:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1B1763858C53 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 1B1763858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699608838; cv=none; b=qXdTChUzX3hyVYN9qMz2CVZBICrh6tTwOU1HfaVlqmNiwKjv6iSDuOHMpferb3NF6+qDH12o7XfhrpzF5wYV8VdNf3nDbpY8P9n4dIdf46+0Jtxf57ArF/SXYQ7iyPU1tZ1pOXJ0Da5LG3eltW517dIYLIg34xblAMNSR8yUtLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699608838; c=relaxed/simple; bh=8LSsi1aJ1hRe9o5zmP7femtEwYrF+72LQ2otVnHG9+Q=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=S58YyDF7x0R5S2W5qa9p3JkqAmvBfmMw1KfxVow4MgPRELB5vdbNBHDJd1cmli1YJmYnW1mdvxSm3TL+YmIs7IRvCBIPXIqE1EimKV1KIBdsWDYR/suVaqn//o919b4rIhxSvXh1l4p+6DvpbmFlTp9qu0EwqDm6SStbH9bgzBc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-507975d34e8so2579668e87.1 for ; Fri, 10 Nov 2023 01:33:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699608835; x=1700213635; 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=mWGC2eTf6mPZsYlTi3sl1yvjlKst3GuXVQa+ca3brqk=; b=ZewSRMT4Efgn5tcMQST5cZggqhhK8bwnl+yJiLt8r0FzWjqqrzGhZWa6/x6a3AUm8y x0Iz7660is5QG/A5IqsJV+M7GIpHmE4Mt9Pi/98yIjgE/f281PDn6p1hx1yNpc+Tw7v/ f6dmhJ9L2BQ7KBl+HGn8/8oOTFwU0bKC3W4o0D0qq8XriyVnYll7WUrGKmrYsmUm2Fr4 h5spgbZGOXklHn6H3mNDoGkzKjetPXh0IunUxnIswnHnW9dMwDttJKF25nOnUhcRpv4H ui1EpdyJR1J9D+RWa7FBeHTInwcGvzCAH+37c7yrWaZvO6/trW7Ic6oc1EQfgf+oQeYL D40Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699608835; x=1700213635; 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=mWGC2eTf6mPZsYlTi3sl1yvjlKst3GuXVQa+ca3brqk=; b=AWVDJ0DcDOb8MGbntVXEowsB49m0iV/aLTPyU3rerJ7TQMUGPO00GDq+iAhrRCuAiq 9MqVlXWTRH7g4+sM/r/NfdAl1YATd6cUCUDztplPUP6opJ70DMS4snIOubl9kLoQ8mT1 2NCoyTSaBIw6AnG6d1/8AlF107AbZDJOXVQlsfoxcBb8HsWGawyRWh0RfO1tgxbaJkOO ZeT6nAs+IADyUTl5OLUjITMuO9z7MJh5exsMwBXS7o32IumX5TLJM+gznw22ZJMHO5OK JORzPvPXedIFkwvjuB4c/n+4EKHssNVm7YfvOsKNN7iZZpb5ybmMSp53AJ8OiScISdej GSag== X-Gm-Message-State: AOJu0YwP7oJmwIMJUAyR5fbBe7IUr2R1pwwIMXM7FMaNZZvatmbR/o1j NKzMLaFfgbQJMWyGI8/iH17i6A/q81ZCGw4lyDIadmx8gos= X-Google-Smtp-Source: AGHT+IEhJc5ctZypqhmQGFybKnOUI/x4ysxtmHCiTXU5enAtpj9Nn1QZzf6o3isafKyG3TX0vcG+6pYYcfSRgrxP30s= X-Received: by 2002:a05:6512:b93:b0:509:cbfa:1c31 with SMTP id b19-20020a0565120b9300b00509cbfa1c31mr2349528lfv.40.1699608835397; Fri, 10 Nov 2023 01:33:55 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Fri, 10 Nov 2023 10:33:43 +0100 Message-ID: Subject: Re: [PATCH] vect: Use statement vectype for conditional mask. To: Robin Dapp Cc: 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 Wed, Nov 8, 2023 at 5:18=E2=80=AFPM Robin Dapp wro= te: > > Hi, > > as Tamar reported in PR112406 we still ICE on aarch64 in SPEC2017 > when creating COND_OPs in ifcvt. > > The problem is that we fail to deduce the mask's type from the statement > vectype and then end up with a non-matching mask in expand. This patch > checks if the current op is equal to the mask operand and, if so, uses > the truth type from the stmt_vectype. Is that a valid approach? > > Bootstrapped and regtested on aarch64, x86 is running. > > Besides, the testcase is Tamar's reduced example, originally from > SPEC. I hope it's ok to include it as is (as imagick is open source > anyway). For the fortran testcase we don't even run into this but hit an internal def and assert on gcc_assert (STMT_VINFO_VEC_STMTS (def_stmt_info).length () =3D=3D nco= pies); I think this shows missing handling of .COND_* in the bool pattern recognit= ion as we get the 'bool' condition as boolean data vector rather than a mask. = The same is true for the testcase with the invariant condition. This causes us= to select the wrong vector type here. The "easiest" might be to look at how COND_EXPR is handled in vect_recog_bool_pattern and friends and handle .COND_* IFNs the same for the mask operand. Richard. > Regards > Robin > > gcc/ChangeLog: > > PR middle-end/112406 > > * tree-vect-stmts.cc (vect_get_vec_defs_for_operand): Handle > masks of conditional ops. > > gcc/testsuite/ChangeLog: > > * gcc.dg/pr112406.c: New test. > --- > gcc/testsuite/gcc.dg/pr112406.c | 37 +++++++++++++++++++++++++++++++++ > gcc/tree-vect-stmts.cc | 20 +++++++++++++++++- > 2 files changed, 56 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.dg/pr112406.c > > diff --git a/gcc/testsuite/gcc.dg/pr112406.c b/gcc/testsuite/gcc.dg/pr112= 406.c > new file mode 100644 > index 00000000000..46459c68c4a > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr112406.c > @@ -0,0 +1,37 @@ > +/* { dg-do compile { target { aarch64*-*-* } } } */ > +/* { dg-options "-march=3Darmv8-a+sve -w -Ofast" } */ > + > +typedef struct { > + int red > +} MagickPixelPacket; > + > +GetImageChannelMoments_image, GetImageChannelMoments_image_0, > + GetImageChannelMoments___trans_tmp_1, GetImageChannelMoments_M11_0, > + GetImageChannelMoments_pixel_3, GetImageChannelMoments_y, > + GetImageChannelMoments_p; > + > +double GetImageChannelMoments_M00_0, GetImageChannelMoments_M00_1, > + GetImageChannelMoments_M01_1; > + > +MagickPixelPacket GetImageChannelMoments_pixel; > + > +SetMagickPixelPacket(int color, MagickPixelPacket *pixel) { > + pixel->red =3D color; > +} > + > +GetImageChannelMoments() { > + for (; GetImageChannelMoments_y; GetImageChannelMoments_y++) { > + SetMagickPixelPacket(GetImageChannelMoments_p, > + &GetImageChannelMoments_pixel); > + GetImageChannelMoments_M00_1 +=3D GetImageChannelMoments_pixel.red; > + if (GetImageChannelMoments_image) > + GetImageChannelMoments_M00_1++; > + GetImageChannelMoments_M01_1 +=3D > + GetImageChannelMoments_y * GetImageChannelMoments_pixel_3; > + if (GetImageChannelMoments_image_0) > + GetImageChannelMoments_M00_0++; > + GetImageChannelMoments_M01_1 +=3D > + GetImageChannelMoments_y * GetImageChannelMoments_p++; > + } > + GetImageChannelMoments___trans_tmp_1 =3D atan(GetImageChannelMoments_M= 11_0); > +} > diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc > index 65883e04ad7..6793b01bf44 100644 > --- a/gcc/tree-vect-stmts.cc > +++ b/gcc/tree-vect-stmts.cc > @@ -1238,10 +1238,28 @@ vect_get_vec_defs_for_operand (vec_info *vinfo, s= tmt_vec_info stmt_vinfo, > tree stmt_vectype =3D STMT_VINFO_VECTYPE (stmt_vinfo); > tree vector_type; > > + /* For a COND_OP the mask operand's type must not be deduced from = the > + scalar type but from the statement's vectype. */ > + bool use_stmt_vectype =3D false; > + gcall *call; > + if ((call =3D dyn_cast (STMT_VINFO_STMT (stmt_vinfo))) > + && gimple_call_internal_p (call)) > + { > + internal_fn ifn =3D gimple_call_internal_fn (call); > + int mask_idx =3D -1; > + if (ifn !=3D IFN_LAST > + && (mask_idx =3D internal_fn_mask_index (ifn)) !=3D -1) > + { > + tree maskop =3D gimple_call_arg (call, mask_idx); > + if (op =3D=3D maskop) > + use_stmt_vectype =3D true; > + } > + } > + > if (vectype) > vector_type =3D vectype; > else if (VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (op)) > - && VECTOR_BOOLEAN_TYPE_P (stmt_vectype)) > + && (use_stmt_vectype || VECTOR_BOOLEAN_TYPE_P (stmt_vectyp= e))) > vector_type =3D truth_type_for (stmt_vectype); > else > vector_type =3D get_vectype_for_scalar_type (loop_vinfo, TREE_TYP= E (op)); > -- > 2.41.0