From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by sourceware.org (Postfix) with ESMTPS id E17DD385697F for ; Fri, 4 Aug 2023 08:19:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E17DD385697F 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-x22a.google.com with SMTP id 38308e7fff4ca-2ba1e9b1fa9so4791161fa.3 for ; Fri, 04 Aug 2023 01:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691137171; x=1691741971; 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=6/JU7hW7B5tY6ZhnNBmYs2wGdoloveW6IoYJbgdK+bk=; b=Xn9wNq2qOuKNaYD49Y4QYR0THcNpDYexvkewakx32wedi7Rq5NeUcZlk177Szt1ZFY GXio6xRlm8CzGj3d3zlcgJwStDxVRNNH3hUrH8jljjhDfOzhg4m0jkavdOrraHtsU8dD eN5Ev623npypYZ5roffANvncQMrRNAuEX7e/DlapMjtdCj+ASujVyJQ0bEguYGeyAWPc Yq132+iZrJnm3lJcPGpmtOm0SHKK2EnVK7wnBjwMbbNJewL3G1A8gtjYBzfgXUmKnjjC 3ZIhYDKOxYbErqsKU69juEDKYgvVqb2ScUUQBdVtxllK1qqR6aSh+woOdt/zg1ETBtQB NO9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691137171; x=1691741971; 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=6/JU7hW7B5tY6ZhnNBmYs2wGdoloveW6IoYJbgdK+bk=; b=kbGCqCANK8elEOuJwMp6UKasdy+yzrG27wdAgs2BzLaYm6vNP4y+Sr6JBNM15rTbY8 kyRg6UjS88g1flHzMpju7oCyDsHmiOXAeVflzaRhz/+cHWUVJuTVykJgepT6CVQujFxR S4/YcwPFql7R4cfJOmFF//rhIKqLp/WAKy28Tpi6e3JMsbEfE9mcm4cyQO3kA6jJAHGk QTBc7aYidaL8cus6s4uz6uOOnFqK+o1Oj+QV9p4fAkrmuxrMzisclss+7n4Bd6EclARi KvOW6g4KPsaf0QmVzSwEhGOjJNckwEzyCEAjvU0AAnhTXjMzpO/uvbbOl4vymiX2+TME MMEQ== X-Gm-Message-State: AOJu0YzFrkzL4873xhRh/1kvaShGfwucjAD5An4dKcv4HdtqTL1cprPe d7Y3yZKX3iqPnbijNVguim40H/bqLNccyIvSFRY= X-Google-Smtp-Source: AGHT+IGFQQKS+q6aBHIP7igYTxYy5Ja8cWgCvFFaUkz90ETSG9uXZY2zNcwVCBwjz+A/yVr6M33ivAhHdQ7dRAhwAus= X-Received: by 2002:a2e:9099:0:b0:2b6:f21a:3dae with SMTP id l25-20020a2e9099000000b002b6f21a3daemr1070860ljg.44.1691137171137; Fri, 04 Aug 2023 01:19:31 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Fri, 4 Aug 2023 10:19:19 +0200 Message-ID: Subject: Re: Disable loop distribution for loops with estimated iterations 0 To: Jan Hubicka Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.3 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 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, Aug 4, 2023 at 9:16=E2=80=AFAM Jan Hubicka via Gcc-patches wrote: > > Hi, > this prevents useless loop distribiton produced in hmmer. With FDO we no= w > correctly work out that the loop created for last iteraiton is not going = to > iterate however loop distribution still produces a verioned loop that has= no > chance to survive loop vectorizer since we only keep distributed loops > when loop vectorization suceeds and it requires number of (header) iterat= ions > to exceed the vectorization factor. > > Bootstrapped/regtested x86_64-linux, OK? OK. But why does optimize_loop_for_speed_p () return true when the loop isn't expected to iterate? Wouldn't that be a better place to fix this and similar issues in other places then? Thanks, Richard. > gcc/ChangeLog: > > * tree-loop-distribution.cc (loop_distribution::execute): Disable > distribution for loops with estimated iterations 0. > > diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.c= c > index cf7c197aaf7..8ff2108f284 100644 > --- a/gcc/tree-loop-distribution.cc > +++ b/gcc/tree-loop-distribution.cc > @@ -3871,10 +3871,20 @@ loop_distribution::execute (function *fun) > > bool destroy_p; > int nb_generated_loops, nb_generated_calls; > + bool only_patterns =3D !optimize_loop_for_speed_p (loop) > + || !flag_tree_loop_distribution; > + /* do not try to distribute loops that are not expected to iter= ate. */ > + if (!only_patterns) > + { > + HOST_WIDE_INT iterations =3D estimated_loop_iterations_int = (loop); > + if (iterations < 0) > + iterations =3D likely_max_loop_iterations_int (loop); > + if (!iterations) > + only_patterns =3D true; > + } > nb_generated_loops > =3D distribute_loop (loop, work_list, cd, &nb_generated_calls= , > - &destroy_p, (!optimize_loop_for_speed_p (l= oop) > - || !flag_tree_loop_distributi= on)); > + &destroy_p, only_patterns); > if (destroy_p) > loops_to_be_destroyed.safe_push (loop); >