public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/kubaneko/heads/histogram)] new create_iv
@ 2023-02-16 16:28 Ondrej Kubanek
0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2023-02-16 16:28 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:98550c8d575fb45b974009619ac35f63ed516731
commit 98550c8d575fb45b974009619ac35f63ed516731
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 410a8516370..3310620d61f 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [gcc(refs/users/kubaneko/heads/histogram)] new create_iv
@ 2023-02-23 23:22 Ondrej Kubanek
0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2023-02-23 23:22 UTC (permalink / raw)
To: gcc-cvs
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [gcc(refs/users/kubaneko/heads/histogram)] new create_iv
@ 2022-11-22 20:43 Ondrej Kubanek
0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2022-11-22 20:43 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:add65e4443356d735c2e667995d6b467d59ef65d
commit add65e4443356d735c2e667995d6b467d59ef65d
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 410a8516370..3310620d61f 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-23 23:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-16 16:28 [gcc(refs/users/kubaneko/heads/histogram)] new create_iv Ondrej Kubanek
-- strict thread matches above, loose matches on Subject: below --
2023-02-23 23:22 Ondrej Kubanek
2022-11-22 20:43 Ondrej Kubanek
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).