[gcc(refs/users/kubaneko/heads/histogram)] new create_iv
Ondrej Kubanek
kubaneko@gcc.gnu.org
Thu Feb 23 23:22:22 GMT 2023
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
More information about the Gcc-cvs
mailing list