public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Ondrej Kubanek <kubaneko@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/kubaneko/heads/histogram)] new create_iv Date: Thu, 23 Feb 2023 23:22:22 +0000 (GMT) [thread overview] Message-ID: <20230223232222.B3F7C385840F@sourceware.org> (raw) https://gcc.gnu.org/g:81285bf85e9aae5a45ba58fb11786bb8bab99486 commit 81285bf85e9aae5a45ba58fb11786bb8bab99486 Author: kubaneko <kubanek0ondrej@gmail.com> Date: Tue Nov 22 16:33:13 2022 +0000 new create_iv Diff: --- gcc/tree-ssa-loop-manip.cc | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/gcc/tree-ssa-loop-manip.cc b/gcc/tree-ssa-loop-manip.cc index 09acc1c94cc..3f721424b4c 100644 --- a/gcc/tree-ssa-loop-manip.cc +++ b/gcc/tree-ssa-loop-manip.cc @@ -67,7 +67,9 @@ create_iv (tree base, tree step, tree var, class loop *loop, gimple_seq stmts; tree vb, va; enum tree_code incr_op = PLUS_EXPR; - edge pe = loop_preheader_edge (loop); + edge pe = NULL; + edge e; + edge_iterator ei; if (var != NULL_TREE) { @@ -122,7 +124,11 @@ create_iv (tree base, tree step, tree var, class loop *loop, loop (i.e. the step should be loop invariant). */ step = force_gimple_operand (step, &stmts, true, NULL_TREE); if (stmts) - gsi_insert_seq_on_edge_immediate (pe, stmts); + { + if (!pe) + pe = loop_preheader_edge (loop); + gsi_insert_seq_on_edge_immediate (pe, stmts); + } stmt = gimple_build_assign (va, incr_op, vb, step); /* Prevent the increment from inheriting a bogus location if it is not put @@ -151,11 +157,23 @@ create_iv (tree base, tree step, tree var, class loop *loop, initial = force_gimple_operand (base, &stmts, true, var); if (stmts) - gsi_insert_seq_on_edge_immediate (pe, stmts); + { + if (!pe) + pe = loop_preheader_edge (loop); + gsi_insert_seq_on_edge_immediate (pe, stmts); + } phi = create_phi_node (vb, loop->header); - add_phi_arg (phi, initial, loop_preheader_edge (loop), UNKNOWN_LOCATION); - add_phi_arg (phi, va, loop_latch_edge (loop), UNKNOWN_LOCATION); + FOR_EACH_EDGE (e, ei, loop->header->preds) + { + if (e==loop_latch_edge (loop)){ + add_phi_arg (phi, va, loop_latch_edge (loop), UNKNOWN_LOCATION); + } + else + { + add_phi_arg (phi, initial, e, UNKNOWN_LOCATION); + } + } } /* Return the innermost superloop LOOP of USE_LOOP that is a superloop of
next reply other threads:[~2023-02-23 23:22 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-23 23:22 Ondrej Kubanek [this message] -- strict thread matches above, loose matches on Subject: below -- 2023-02-16 16:28 Ondrej Kubanek 2022-11-22 20:43 Ondrej Kubanek
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230223232222.B3F7C385840F@sourceware.org \ --to=kubaneko@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).