https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125942

            Bug ID: 125942
           Summary: gsi_insert iterator
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: internal-improvement
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

>From https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125917#c2 :
```
Just to mention in more places - I'd like to have a gimple_insert_iterator
that carries before/after, GSI_{NEW_STMT,CONTINUE_LINKING,...} in addition
to the gsi to de-bloat code inserting stmts.  It should also be able to
insert on edges.
```

A example is asan.cc:
```
      gsi_insert_before (iter, g, GSI_SAME_STMT);
      ...
      gsi_insert_before (iter, g, GSI_SAME_STMT);
...
      gsi_insert_before (iter, g, GSI_SAME_STMT);
...
  gsi_insert_before (iter, g, GSI_SAME_STMT);
```

Having it just be like:
gsi_insert_iterator insert_i = gsi_insert_before_iterator (GSI_SAME_STMT,
iter);
...
gsi_insert (insert_i, g);
...
gsi_insert (insert_i, g);
...
gsi_insert (insert_i, g);
...
gsi_insert (insert_i, g);

etc.

Would make it easier and not keep track and such.

And maybe even:
gsi_insert_iterator insert_i = gsi_insert_at_begining_bb (bb);
gsi_insert (insert_i, g);

Which inserts at the beginning of the basic block.  This shows up in
tree-ssa-phiopt and a few other places too.

Reply via email to