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 4C7B13858D20 for ; Fri, 23 Jun 2023 10:03:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4C7B13858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4f954d78bf8so515187e87.3 for ; Fri, 23 Jun 2023 03:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687514626; x=1690106626; 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=mi57XB5lzVwzaapZACDHcF2fw545w5ge6QD1+mledlk=; b=ZNtr3g0lceiHCMLllIPEE12sijQaAcuxYLfozgQWy8hEubqVT4LTpCxjZ0z/Hbw/j/ Z2+5CuICRMY1cBsGwVTABz0IQBpM207H9FgIkzwFAiUzkfaialRUjgC+V+jD3I49IQK1 AqtafFa/7wzafqTSxL9uIYn25Zkwj05S3wjIwyqEDLqqtq5f9WuRcjMY/PiUv0nA8bYw IvNpnZb6vtiP2Z8N7n/5/7w1MXLIX1Ox0iS8WQTjMKhlAfgpbE+xu8Ue0mIkGInveIko XTqrop+58UtGmAAdHluv5g8d7hv+nc0JeK12/p8SlkmujkPF/WRW3RUugd+mb3ao+lor +AGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687514626; x=1690106626; 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=mi57XB5lzVwzaapZACDHcF2fw545w5ge6QD1+mledlk=; b=EongX1QWHzhlxFRSyIMzk5MC847tCH7JLmfO8Qtl7YqB+KAyeSBJ6S0WLGz0EFiFkX JC6zdeNxtdZC6C03OgW33pI5RCO/KBgIIMlAHNJmzvtjh0hVipTTZ37pKtVujvMxZCU/ Ry25bzf15vwJXNwHSNpFqfHoADVh5LRFpe4dkwINNiOMPzIDpsrxM44ikyuW0OR9GELE btSj51dqHw400XSFrBqpyMO5q4UpTtGuieccdZwcT8B9TEdhz5/DyGkuneIJlFPeiF0z F18/zobmfTgNL42FpcZRZfL0AX5QQV7ALQlJGePRCCSv+3ndfkdSVUsxY7AS+J5Cyogb uQBQ== X-Gm-Message-State: AC+VfDxDBRFKJuMBa6/qnKAyzaqUaSoJ4loe+mJOaFsYRnlN/PNUOVo2 +tivpKx+X+uNdrj6fDU+c6VS0qT/bpnBRPtCE80UaceX5HoU6ZgNCcc= X-Google-Smtp-Source: ACHHUZ5kGSLo+P1CuWm6YWz1IXfcyCVrNaoyvdbhRhRNGjwNJokqdUNYfW0fZ2zCVQHyXGcVjcGLr5ibcc+AoCk+LdM= X-Received: by 2002:a19:7712:0:b0:4f8:752f:371f with SMTP id s18-20020a197712000000b004f8752f371fmr8042108lfc.51.1687514625555; Fri, 23 Jun 2023 03:03:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Prathamesh Kulkarni Date: Fri, 23 Jun 2023 15:33:10 +0530 Message-ID: Subject: Re: [SVE][match.pd] Fix ICE observed in PR110280 To: Richard Biener Cc: gcc Patches , Richard Sandiford Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,WEIRD_PORT autolearn=no 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, 23 Jun 2023 at 14:58, Richard Biener w= rote: > > On Fri, Jun 23, 2023 at 11:09=E2=80=AFAM Prathamesh Kulkarni > wrote: > > > > On Thu, 22 Jun 2023 at 18:06, Richard Biener wrote: > > > > > > On Thu, Jun 22, 2023 at 11:08=E2=80=AFAM Prathamesh Kulkarni > > > wrote: > > > > > > > > On Tue, 20 Jun 2023 at 16:47, Richard Biener wrote: > > > > > > > > > > On Tue, Jun 20, 2023 at 11:56=E2=80=AFAM Prathamesh Kulkarni via = Gcc-patches > > > > > wrote: > > > > > > > > > > > > Hi Richard, > > > > > > For the following reduced test-case taken from PR: > > > > > > > > > > > > #include "arm_sve.h" > > > > > > svuint32_t l() { > > > > > > alignas(16) const unsigned int lanes[4] =3D {0, 0, 0, 0}; > > > > > > return svld1rq_u32(svptrue_b8(), lanes); > > > > > > } > > > > > > > > > > > > compiling with -O3 -mcpu=3Dgeneric+sve results in following ICE= : > > > > > > during GIMPLE pass: fre > > > > > > pr110280.c: In function 'l': > > > > > > pr110280.c:5:1: internal compiler error: in eliminate_stmt, at > > > > > > tree-ssa-sccvn.cc:6890 > > > > > > 5 | } > > > > > > | ^ > > > > > > 0x865fb1 eliminate_dom_walker::eliminate_stmt(basic_block_def*, > > > > > > gimple_stmt_iterator*) > > > > > > ../../gcc/gcc/tree-ssa-sccvn.cc:6890 > > > > > > 0x120bf4d eliminate_dom_walker::before_dom_children(basic_block= _def*) > > > > > > ../../gcc/gcc/tree-ssa-sccvn.cc:7324 > > > > > > 0x120bf4d eliminate_dom_walker::before_dom_children(basic_block= _def*) > > > > > > ../../gcc/gcc/tree-ssa-sccvn.cc:7257 > > > > > > 0x1aeec77 dom_walker::walk(basic_block_def*) > > > > > > ../../gcc/gcc/domwalk.cc:311 > > > > > > 0x11fd924 eliminate_with_rpo_vn(bitmap_head*) > > > > > > ../../gcc/gcc/tree-ssa-sccvn.cc:7504 > > > > > > 0x1214664 do_rpo_vn_1 > > > > > > ../../gcc/gcc/tree-ssa-sccvn.cc:8616 > > > > > > 0x1215ba5 execute > > > > > > ../../gcc/gcc/tree-ssa-sccvn.cc:8702 > > > > > > > > > > > > cc1 simplifies: > > > > > > lanes[0] =3D 0; > > > > > > lanes[1] =3D 0; > > > > > > lanes[2] =3D 0; > > > > > > lanes[3] =3D 0; > > > > > > _1 =3D { -1, ... }; > > > > > > _7 =3D svld1rq_u32 (_1, &lanes); > > > > > > > > > > > > to: > > > > > > _9 =3D MEM [(unsigned int * {ref-all= })&lanes]; > > > > > > _7 =3D VEC_PERM_EXPR <_9, _9, { 0, 1, 2, 3, ... }>; > > > > > > > > > > > > and then fre1 dump shows: > > > > > > Applying pattern match.pd:8675, generic-match-5.cc:9025 > > > > > > Match-and-simplified VEC_PERM_EXPR <_9, _9, { 0, 1, 2, 3, ... }= > to { > > > > > > 0, 0, 0, 0 } > > > > > > RHS VEC_PERM_EXPR <_9, _9, { 0, 1, 2, 3, ... }> simplified to {= 0, 0, 0, 0 } > > > > > > > > > > > > The issue seems to be with the following pattern: > > > > > > (simplify > > > > > > (vec_perm vec_same_elem_p@0 @0 @1) > > > > > > @0) > > > > > > > > > > > > which simplifies above VEC_PERM_EXPR to: > > > > > > _7 =3D {0, 0, 0, 0} > > > > > > which is incorrect since _9 and mask have different vector leng= ths. > > > > > > > > > > > > The attached patch amends the pattern to simplify above VEC_PER= M_EXPR > > > > > > only if operand and mask have same number of elements, which se= ems to fix > > > > > > the issue, and we're left with the following in .optimized dump= : > > > > > > [local count: 1073741824]: > > > > > > _2 =3D VEC_PERM_EXPR <{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 1,= 2, 3, ... }>; > > > > > > > > > > it would be nice to have this optimized. > > > > > > > > > > - > > > > > (simplify > > > > > (vec_perm vec_same_elem_p@0 @0 @1) > > > > > - @0) > > > > > + (if (known_eq (TYPE_VECTOR_SUBPARTS (TREE_TYPE (@0)), > > > > > + TYPE_VECTOR_SUBPARTS (TREE_TYPE (@1)))) > > > > > + @0)) > > > > > > > > > > that looks good I think. Maybe even better use 'type' instead of= TREE_TYPE (@1) > > > > > since that's more obviously the return type in which case > > > > > > > > > > (if (types_match (type, TREE_TYPE (@0)) > > > > > > > > > > would be more to the point. > > > > > > > > > > But can't you to simplify this in the !known_eq case do a simple > > > > > > > > > > { build_vector_from_val (type, the-element); } > > > > > > > > > > ? The 'vec_same_elem_p' predicate doesn't get you at the element= , > > > > > > > > > > (with { tree el =3D uniform_vector_p (@0); } > > > > > (if (el) > > > > > { build_vector_from_val (type, el); }))) > > > > > > > > > > would be the cheapest workaround. > > > > Hi Richard, > > > > Thanks for the suggestions. Using build_vector_from_val simplifies = it to: > > > > [local count: 1073741824]: > > > > return { 0, ... }; > > > > > > > > Patch is bootstrapped+tested on aarch64-linux-gnu, in progress on > > > > x86_64-linux-gnu. > > > > OK to commit ? > > > > > > Can you retain the case of matching type? Like > > > > > > (if (types_match (type, TREE_TYPE (@0)) > > > @0 > > > (with > > > { > > > tree elem =3D uniform_vector_p (@0); > > > } > > > (if (elem) > > > { build_vector_from_val (type, elem); })))) > > > > > > ? Because uniform_vector_p is strictly less powerful than (vec_same_= elem_p ...) > > > > > > OK with that change. > > Thanks, does the attached patch look OK ? > > OK. Thanks, pushed to trunk in 85d8e0d8d5342ec8b4e6a54e22741c30b33c6f04. Thanks, Prathamesh > > > Bootstrapped+tested on aarch64-linux-gnu and x86_64-linux-gnu. > > > > Thanks, > > Prathamesh > > > > > > Richard. > > > > > > > > > > > > > > Thanks, > > > > Prathamesh > > > > > > > > > > > return _2; > > > > > > > > > > > > code-gen: > > > > > > l: > > > > > > mov z0.b, #0 > > > > > > ret > > > > > > > > > > > > Patch is bootstrapped+tested on aarch64-linux-gnu. > > > > > > OK to commit ? > > > > > > > > > > > > Thanks, > > > > > > Prathamesh