From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id 11A5E3858C53 for ; Fri, 21 Jul 2023 08:36:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 11A5E3858C53 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-x22f.google.com with SMTP id 38308e7fff4ca-2b7430bda8bso25350491fa.0 for ; Fri, 21 Jul 2023 01:36:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689928563; x=1690533363; 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=Fqr5Wlv5KdBfKz2b2Ss6P9wVUtSssVpbHGenfE+qLhk=; b=R3afJwwH3HVS8lPm9SGgs2bbx4WSfLkTUWUbKzPQ7LsHrrQ7JlEFxEgyuxJ8Nf3OKy XBhcmV2XuNI/ENxk+Ki4h9aVyw7VebwqFe6+o22Juwc0Gb/0FYg3HeGjlURuekxVmYj+ TrwBAxdbaTkDroVZpF5xuR2N8RQu7ANdkh60J8xyWjsmR5sWgAe876QFLLj8eh+gafUA YkhEoMO8B8vQGoAP78V9m211CLkY7lEhMZRAcN5faatTyTY9yEvAlTd1qC5B3AzBP7lj z+zE7ng/fFf0RDJ14a7mqptL9nNwjUeUP0ESe6aHnK2EpIDyHVBuvX/80XFbGc4brHB6 wxzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689928563; x=1690533363; 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=Fqr5Wlv5KdBfKz2b2Ss6P9wVUtSssVpbHGenfE+qLhk=; b=mIO7gixz3UR7V028FjS4uYe9LfonolirDIP1eV/cmI2yIMAOumpyvwnq4CbPxrL6FM thJdVMU2Bg4ewNMRJt4Xu99AG5XuFU0S1yx0WyDr9PbwfPCSVg6E26OrcfBRnpYfjPh6 zp9DgJg6KBkiAwgPGsccGEovnfYCIYwB21s49W6u7iJzk2gH/PlLsf879Wmq10SIEqFZ eI1KhP+tnYJYQKetx8z03yWV4m4SmuVYo0DfXXrlkLGKeibiuYaGTDhCxTh1hcDZ+Kl4 fs0f0VnZOVxRJSXRlbm6B3Pcz2gO08rn/NB3wCyYWJJkjDluzKP6aWG4FQ5L+pKpp6i9 hgRw== X-Gm-Message-State: ABy/qLb677mrJ35jN0Qs2B4WAu5c2i4bhPTAc/is+WrGkiCLQU6h5Ks3 Xe1HN7ympuD3iW3vOHyPK9LSBsIP9gdQJW6W5KU7hOYA X-Google-Smtp-Source: APBJJlFGzQm1nmf4HNDKZjrL/M7wpeFnW2RSmQS5zVWDLPQBz8xHCjoukiVvQvoNbxcXTyuhFSXiwEhWGjrDrKTKE10= X-Received: by 2002:a2e:9f50:0:b0:2b7:33a6:f2c0 with SMTP id v16-20020a2e9f50000000b002b733a6f2c0mr1103766ljk.4.1689928563145; Fri, 21 Jul 2023 01:36:03 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Fri, 21 Jul 2023 10:35:51 +0200 Message-ID: Subject: Re: Improve loop dumping 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.6 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, Jul 21, 2023 at 9:57=E2=80=AFAM Jan Hubicka via Gcc-patches wrote: > > Hi, > we have flow_loop_dump and print_loop. While print_loop was extended to d= ump > stuff from loop structure we added over years (loop info), flow_loop_dump= was not. > -fdump-tree-all files contains flow_loop_dump which makes it hard to see = what > metadata we have attached to loop. > > This patch unifies dumping of these fields from both functions. For exam= ple for: > int a[100]; > main() > { > for (int i =3D 0; i < 10; i++) > a[i]=3Di; > } > we now print: > ;; Loop 0 > ;; header 0, latch 1 > ;; depth 0, outer -1 > ;; nodes: 0 1 2 3 4 5 > ;; > ;; Loop 1 > ;; header 4, latch 3 > ;; depth 1, outer 0, finite_p > ;; upper_bound 10 > ;; likely_upper_bound 10 > ;; estimate 10 > ;; iterations by profile: 10.001101 (unreliable) > > finite_p, upper_bound, likely_upper_bound estimate and iterations by prof= ile is new. > > Bootstrap/regtest on x86_64 in progress. OK if it passes? OK. > Honza > > gcc/ChangeLog: > > * cfgloop.cc (flow_loop_dump): Use print_loop_info. > * cfgloop.h (print_loop_info): Declare. > * tree-cfg.cc (print_loop_info): Break out from ...; add > printing of missing fields and profile > (print_loop): ... here. > > diff --git a/gcc/cfgloop.cc b/gcc/cfgloop.cc > index 020e5734d95..9ca85e648a7 100644 > --- a/gcc/cfgloop.cc > +++ b/gcc/cfgloop.cc > @@ -135,17 +135,12 @@ flow_loop_dump (const class loop *loop, FILE *file, > fprintf (file, "\n"); > } > > - fprintf (file, ";; depth %d, outer %ld\n", > + fprintf (file, ";; depth %d, outer %ld", > loop_depth (loop), (long) (loop_outer (loop) > ? loop_outer (loop)->num : -1)); > + print_loop_info (file, loop, ";; "); > > - bool reliable; > - sreal iterations; > - if (loop->num && expected_loop_iterations_by_profile (loop, &iteration= s, &reliable)) > - fprintf (file, ";; profile-based iteration count: %f %s\n", > - iterations.to_double (), reliable ? "(reliable)" : "(unrelia= ble)"); > - > - fprintf (file, ";; nodes:"); > + fprintf (file, "\n;; nodes:"); > bbs =3D get_loop_body (loop); > for (i =3D 0; i < loop->num_nodes; i++) > fprintf (file, " %d", bbs[i]->index); > diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h > index 4d2fd4b6af5..269694c7962 100644 > --- a/gcc/cfgloop.h > +++ b/gcc/cfgloop.h > @@ -411,6 +411,7 @@ extern unsigned expected_loop_iterations (class loop = *); > extern rtx doloop_condition_get (rtx_insn *); > > void mark_loop_for_removal (loop_p); > +void print_loop_info (FILE *file, const class loop *loop, const char *); > > /* Induction variable analysis. */ > > diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc > index 7ccc2a5a5a7..a6c97a04662 100644 > --- a/gcc/tree-cfg.cc > +++ b/gcc/tree-cfg.cc > @@ -8479,6 +8479,55 @@ print_loops_bb (FILE *file, basic_block bb, int in= dent, int verbosity) > } > } > > +/* Print loop information. */ > + > +void > +print_loop_info (FILE *file, const class loop *loop, const char *prefix) > +{ > + if (loop->can_be_parallel) > + fprintf (file, ", can_be_parallel"); > + if (loop->warned_aggressive_loop_optimizations) > + fprintf (file, ", warned_aggressive_loop_optimizations"); > + if (loop->dont_vectorize) > + fprintf (file, ", dont_vectorize"); > + if (loop->force_vectorize) > + fprintf (file, ", force_vectorize"); > + if (loop->in_oacc_kernels_region) > + fprintf (file, ", in_oacc_kernels_region"); > + if (loop->finite_p) > + fprintf (file, ", finite_p"); > + if (loop->unroll) > + fprintf (file, "\n%sunroll %d", prefix, loop->unroll); > + if (loop->nb_iterations) > + { > + fprintf (file, "\n%sniter ", prefix); > + print_generic_expr (file, loop->nb_iterations); > + } > + > + if (loop->any_upper_bound) > + { > + fprintf (file, "\n%supper_bound ", prefix); > + print_decu (loop->nb_iterations_upper_bound, file); > + } > + if (loop->any_likely_upper_bound) > + { > + fprintf (file, "\n%slikely_upper_bound ", prefix); > + print_decu (loop->nb_iterations_likely_upper_bound, file); > + } > + > + if (loop->any_estimate) > + { > + fprintf (file, "\n%sestimate ", prefix); > + print_decu (loop->nb_iterations_estimate, file); > + } > + bool reliable; > + sreal iterations; > + if (loop->num && expected_loop_iterations_by_profile (loop, &iteration= s, &reliable)) > + fprintf (file, "\n%siterations by profile: %f %s", prefix, > + iterations.to_double (), reliable ? "(reliable)" : "(unrelia= ble)"); > + > +} > + > static void print_loop_and_siblings (FILE *, class loop *, int, int); > > /* Pretty print LOOP on FILE, indented INDENT spaces. Following > @@ -8511,27 +8560,7 @@ print_loop (FILE *file, class loop *loop, int inde= nt, int verbosity) > fprintf (file, ", latch =3D %d", loop->latch->index); > else > fprintf (file, ", multiple latches"); > - fprintf (file, ", niter =3D "); > - print_generic_expr (file, loop->nb_iterations); > - > - if (loop->any_upper_bound) > - { > - fprintf (file, ", upper_bound =3D "); > - print_decu (loop->nb_iterations_upper_bound, file); > - } > - if (loop->any_likely_upper_bound) > - { > - fprintf (file, ", likely_upper_bound =3D "); > - print_decu (loop->nb_iterations_likely_upper_bound, file); > - } > - > - if (loop->any_estimate) > - { > - fprintf (file, ", estimate =3D "); > - print_decu (loop->nb_iterations_estimate, file); > - } > - if (loop->unroll) > - fprintf (file, ", unroll =3D %d", loop->unroll); > + print_loop_info (file, loop, s_indent); > fprintf (file, ")\n"); > > /* Print loop's body. */