diff mbox

"gimple-classes-v2-option-3" git branch committed to svn trunk as r217787

Message ID 1416435844.3562.78.camel@surprise
State New
Headers show

Commit Message

David Malcolm Nov. 19, 2014, 10:24 p.m. UTC
On Wed, 2014-11-19 at 22:36 +0100, Richard Biener wrote:
> On November 19, 2014 10:09:56 PM CET, Andrew MacLeod <amacleod@redhat.com> wrote:
> >On 11/19/2014 03:43 PM, Richard Biener wrote:
> >> On November 19, 2014 8:26:23 PM CET, Andrew MacLeod
> ><amacleod@redhat.com> wrote:
> >>> On 11/19/2014 01:12 PM, David Malcolm wrote:
> >>>
> >>>> (A) could become:
> >>>>
> >>>>     greturn *stmt = gsi->as_a_greturn ();
> >>>>
> >>>> (B) could become:
> >>>>
> >>>>     stmt = gsi->dyn_cast <gcall *> ();
> >>>>     if (!stmt)
> >>>> or:
> >>>>
> >>>>     stmt = gsi->dyn_cast_gcall ();
> >>>>     if (!stmt)
> >>>>
> >>>> or maybe:
> >>>>
> >>>>     stmt = gsi->is_a_gcall ();
> >>>>     if (!stmt)
> >>>>
> >>>> An earlier version of my patches had casting methods within the
> >>>> gimple_statement_base class, which were rejected; the above
> >proposals
> >>>> would instead put them within gimple_stmt_iterator.
> >>>>
> >>> I would like all gsi routines to be consistent, not a mix of
> >functions
> >>> and methods.
> >>> so something like
> >>>
> >>> stmt = gsi_as_call (gsi);
> >>> stmt = gsi_dyn_call (gsi);
> >>>
> >>> or we need to change gsi_stmt() and friends into methods and access
> >>> them
> >>> as gsi->stmt ()..  which is possibly better, but that much more
> >>> intrusive again (another 2000+ locations).
> >>> If we switched to methods everywhere for gsi, I'd prefer something
> >like
> >>> gsi->as_a_call ()
> >>> gsi->is_a_call ()
> >>> gsi->dyn_cast_call ()
> >>>
> >>> I think its more readable... and it removes a dependency on the
> >>> implementation.. so if we ever decide to change the name of 'gcall'
> >>> down
> >>> the road to using a namespace, and make it gimple::call or whatever,
> >we
> >>>
> >>> wont have to change every single gsi-> location which has a
> >templated
> >>> use of the type.
> >>>
> >>> I'm also think this sort of thing could probably wait until next
> >stage
> >>> 1..
> >>>
> >>> my 2 cents...
> >> Why not as_a <gassign *> (*gsi)?  It would
> >> Add operator* to gsi of course.
> >>
> >> Richard.
> >>
> >>
> >
> >I could live with that form too.
> >
> >we often have an instance of gimple_stmt_iterator rather than a pointer
> >
> >to it, so wouldn't  "operator gimple *()" to implicitly call gsi_stmt()
> >
> >when needed work better?     (or "operator gimple ()" before the next 
> >change) ..
> 
> Not sure.  The * matches how iterators work in STL...
> 
> Note that for the cases where we pass a pointer to an iterator we can change those to use references to avoid writing **gsi.
> 
> Richard.
> 
> >Andrew

I had a go at adding an operator * to gimple_stmt_iterator, using it
everywhere that we do an as_a<> or dyn_cast<> on the result of a
gsi_stmt, to abbreviate the gsi_stmt call down to one character.

Patch attached; only lightly smoketested; am posting it for the sake of
discussion.

I don't think this API will make the non-C++-fans happier; I think the
objection to the work I just merged is that it's adding more C++ than
those people are comfortable with.

So although the attached patch makes things shorter (good), it's taking
things in a "more C++" direction (questionable).  I'd hoped to paper
over the C++ somewhat.

I suspect that any API which requires the of < > characters within the
implementation of a gimple pass to mean a template is going to give
those less happy with C++ a visceral "ugh" reaction.  I wonder if
there's a way to spell these things that's concise and which doesn't
involve <> ?

Comments

Andrew MacLeod Nov. 19, 2014, 11:05 p.m. UTC | #1
On 11/19/2014 05:24 PM, David Malcolm wrote:
> On Wed, 2014-11-19 at 22:36 +0100, Richard Biener wrote:
>> On November 19, 2014 10:09:56 PM CET, Andrew MacLeod <amacleod@redhat.com> wrote:
>>> On 11/19/2014 03:43 PM, Richard Biener wrote:
>>>> On November 19, 2014 8:26:23 PM CET, Andrew MacLeod
>>> <amacleod@redhat.com> wrote:
>>>>> On 11/19/2014 01:12 PM, David Malcolm wrote:
>>>>>
>>>>>> (A) could become:
>>>>>>
>>>>>>      greturn *stmt = gsi->as_a_greturn ();
>>>>>>
>>>>>> (B) could become:
>>>>>>
>>>>>>      stmt = gsi->dyn_cast <gcall *> ();
>>>>>>      if (!stmt)
>>>>>> or:
>>>>>>
>>>>>>      stmt = gsi->dyn_cast_gcall ();
>>>>>>      if (!stmt)
>>>>>>
>>>>>> or maybe:
>>>>>>
>>>>>>      stmt = gsi->is_a_gcall ();
>>>>>>      if (!stmt)
>>>>>>
>>>>>> An earlier version of my patches had casting methods within the
>>>>>> gimple_statement_base class, which were rejected; the above
>>> proposals
>>>>>> would instead put them within gimple_stmt_iterator.
>>>>>>
>>>>> I would like all gsi routines to be consistent, not a mix of
>>> functions
>>>>> and methods.
>>>>> so something like
>>>>>
>>>>> stmt = gsi_as_call (gsi);
>>>>> stmt = gsi_dyn_call (gsi);
>>>>>
>>>>> or we need to change gsi_stmt() and friends into methods and access
>>>>> them
>>>>> as gsi->stmt ()..  which is possibly better, but that much more
>>>>> intrusive again (another 2000+ locations).
>>>>> If we switched to methods everywhere for gsi, I'd prefer something
>>> like
>>>>> gsi->as_a_call ()
>>>>> gsi->is_a_call ()
>>>>> gsi->dyn_cast_call ()
>>>>>
>>>>> I think its more readable... and it removes a dependency on the
>>>>> implementation.. so if we ever decide to change the name of 'gcall'
>>>>> down
>>>>> the road to using a namespace, and make it gimple::call or whatever,
>>> we
>>>>> wont have to change every single gsi-> location which has a
>>> templated
>>>>> use of the type.
>>>>>
>>>>> I'm also think this sort of thing could probably wait until next
>>> stage
>>>>> 1..
>>>>>
>>>>> my 2 cents...
>>>> Why not as_a <gassign *> (*gsi)?  It would
>>>> Add operator* to gsi of course.
>>>>
>>>> Richard.
>>>>
>>>>
>>> I could live with that form too.
>>>
>>> we often have an instance of gimple_stmt_iterator rather than a pointer
>>>
>>> to it, so wouldn't  "operator gimple *()" to implicitly call gsi_stmt()
>>>
>>> when needed work better?     (or "operator gimple ()" before the next
>>> change) ..
>> Not sure.  The * matches how iterators work in STL...
>>
>> Note that for the cases where we pass a pointer to an iterator we can change those to use references to avoid writing **gsi.
>>
>> Richard.
>>
>>> Andrew
> I had a go at adding an operator * to gimple_stmt_iterator, using it
> everywhere that we do an as_a<> or dyn_cast<> on the result of a
> gsi_stmt, to abbreviate the gsi_stmt call down to one character.
>
> Patch attached; only lightly smoketested; am posting it for the sake of
> discussion.
>
> I don't think this API will make the non-C++-fans happier; I think the
> objection to the work I just merged is that it's adding more C++ than
> those people are comfortable with.
>
> So although the attached patch makes things shorter (good), it's taking
> things in a "more C++" direction (questionable).  I'd hoped to paper
> over the C++ somewhat.
>
> I suspect that any API which requires the of < > characters within the
> implementation of a gimple pass to mean a template is going to give
> those less happy with C++ a visceral "ugh" reaction.  I wonder if
> there's a way to spell these things that's concise and which doesn't
> involve <> ?
>
wasnt that my last  thought?   is_a_call(), as_a_call() and 
dyn_cast_call () ?

I think lack of <> in identifiers helps us old brains parse faster 
:-)    <> are like ()... many many years of causing a certain kind of 
break in mental processing. I'm accustomed to single <> these days, but 
once you get into multiple <>'s I quickly loose track.  I find the same 
thing with ()... hence I'm not a lisp fan :-)

I dont think 'operator *' c++ifies it too much, but I still think 
operator gimple() would be easier...  no extra character at all, and no 
odd looking dereference of a non-pointer object or double dereference of 
a pointer.  I cant think of how that could get us into trouble... it'll 
always map to the stmt the iterator currently points to.

Andrew
Richard Biener Nov. 20, 2014, 1:08 p.m. UTC | #2
On Thu, Nov 20, 2014 at 12:05 AM, Andrew MacLeod <amacleod@redhat.com> wrote:
> On 11/19/2014 05:24 PM, David Malcolm wrote:
>>
>> On Wed, 2014-11-19 at 22:36 +0100, Richard Biener wrote:
>>>
>>> On November 19, 2014 10:09:56 PM CET, Andrew MacLeod
>>> <amacleod@redhat.com> wrote:
>>>>
>>>> On 11/19/2014 03:43 PM, Richard Biener wrote:
>>>>>
>>>>> On November 19, 2014 8:26:23 PM CET, Andrew MacLeod
>>>>
>>>> <amacleod@redhat.com> wrote:
>>>>>>
>>>>>> On 11/19/2014 01:12 PM, David Malcolm wrote:
>>>>>>
>>>>>>> (A) could become:
>>>>>>>
>>>>>>>      greturn *stmt = gsi->as_a_greturn ();
>>>>>>>
>>>>>>> (B) could become:
>>>>>>>
>>>>>>>      stmt = gsi->dyn_cast <gcall *> ();
>>>>>>>      if (!stmt)
>>>>>>> or:
>>>>>>>
>>>>>>>      stmt = gsi->dyn_cast_gcall ();
>>>>>>>      if (!stmt)
>>>>>>>
>>>>>>> or maybe:
>>>>>>>
>>>>>>>      stmt = gsi->is_a_gcall ();
>>>>>>>      if (!stmt)
>>>>>>>
>>>>>>> An earlier version of my patches had casting methods within the
>>>>>>> gimple_statement_base class, which were rejected; the above
>>>>
>>>> proposals
>>>>>>>
>>>>>>> would instead put them within gimple_stmt_iterator.
>>>>>>>
>>>>>> I would like all gsi routines to be consistent, not a mix of
>>>>
>>>> functions
>>>>>>
>>>>>> and methods.
>>>>>> so something like
>>>>>>
>>>>>> stmt = gsi_as_call (gsi);
>>>>>> stmt = gsi_dyn_call (gsi);
>>>>>>
>>>>>> or we need to change gsi_stmt() and friends into methods and access
>>>>>> them
>>>>>> as gsi->stmt ()..  which is possibly better, but that much more
>>>>>> intrusive again (another 2000+ locations).
>>>>>> If we switched to methods everywhere for gsi, I'd prefer something
>>>>
>>>> like
>>>>>>
>>>>>> gsi->as_a_call ()
>>>>>> gsi->is_a_call ()
>>>>>> gsi->dyn_cast_call ()
>>>>>>
>>>>>> I think its more readable... and it removes a dependency on the
>>>>>> implementation.. so if we ever decide to change the name of 'gcall'
>>>>>> down
>>>>>> the road to using a namespace, and make it gimple::call or whatever,
>>>>
>>>> we
>>>>>>
>>>>>> wont have to change every single gsi-> location which has a
>>>>
>>>> templated
>>>>>>
>>>>>> use of the type.
>>>>>>
>>>>>> I'm also think this sort of thing could probably wait until next
>>>>
>>>> stage
>>>>>>
>>>>>> 1..
>>>>>>
>>>>>> my 2 cents...
>>>>>
>>>>> Why not as_a <gassign *> (*gsi)?  It would
>>>>> Add operator* to gsi of course.
>>>>>
>>>>> Richard.
>>>>>
>>>>>
>>>> I could live with that form too.
>>>>
>>>> we often have an instance of gimple_stmt_iterator rather than a pointer
>>>>
>>>> to it, so wouldn't  "operator gimple *()" to implicitly call gsi_stmt()
>>>>
>>>> when needed work better?     (or "operator gimple ()" before the next
>>>> change) ..
>>>
>>> Not sure.  The * matches how iterators work in STL...
>>>
>>> Note that for the cases where we pass a pointer to an iterator we can
>>> change those to use references to avoid writing **gsi.
>>>
>>> Richard.
>>>
>>>> Andrew
>>
>> I had a go at adding an operator * to gimple_stmt_iterator, using it
>> everywhere that we do an as_a<> or dyn_cast<> on the result of a
>> gsi_stmt, to abbreviate the gsi_stmt call down to one character.
>>
>> Patch attached; only lightly smoketested; am posting it for the sake of
>> discussion.
>>
>> I don't think this API will make the non-C++-fans happier; I think the
>> objection to the work I just merged is that it's adding more C++ than
>> those people are comfortable with.
>>
>> So although the attached patch makes things shorter (good), it's taking
>> things in a "more C++" direction (questionable).  I'd hoped to paper
>> over the C++ somewhat.
>>
>> I suspect that any API which requires the of < > characters within the
>> implementation of a gimple pass to mean a template is going to give
>> those less happy with C++ a visceral "ugh" reaction.  I wonder if
>> there's a way to spell these things that's concise and which doesn't
>> involve <> ?
>>
> wasnt that my last  thought?   is_a_call(), as_a_call() and dyn_cast_call ()
> ?
>
> I think lack of <> in identifiers helps us old brains parse faster :-)    <>
> are like ()... many many years of causing a certain kind of break in mental
> processing. I'm accustomed to single <> these days, but once you get into
> multiple <>'s I quickly loose track.  I find the same thing with ()... hence
> I'm not a lisp fan :-)

I think we want to have a consistent style across GCC even if seen as
ugly to some people.  Thus having (member) functions for conversion in
some cases
and as_a <> templates in others is bad.  C++ was supposed to make
grok GCC easier for newbies - this is exactly making it harder (not that
I believe in this story at all...)

> I dont think 'operator *' c++ifies it too much, but I still think operator
> gimple() would be easier...  no extra character at all, and no odd looking
> dereference of a non-pointer object or double dereference of a pointer.  I
> cant think of how that could get us into trouble... it'll always map to the
> stmt the iterator currently points to.

I dislike conversion operators.  Why is 'operator *' bad?  It's exactly
how iterators are supposed to work - after all the gsi stuff was modeled
after STL iterators!

So that's a definitive "no" from me to is_a_call () as_a_call () etc.

Richard.

> Andrew
Andrew MacLeod Nov. 20, 2014, 1:49 p.m. UTC | #3
On 11/20/2014 08:08 AM, Richard Biener wrote:
> On Thu, Nov 20, 2014 at 12:05 AM, Andrew MacLeod <amacleod@redhat.com> wrote:
>> On 11/19/2014 05:24 PM, David Malcolm wrote:
>>> On Wed, 2014-11-19 at 22:36 +0100, Richard Biener wrote:
>>>> On November 19, 2014 10:09:56 PM CET, Andrew MacLeod
>>>> <amacleod@redhat.com> wrote:
>>>>> On 11/19/2014 03:43 PM, Richard Biener wrote:
>>>>>> On November 19, 2014 8:26:23 PM CET, Andrew MacLeod
>>>>> <amacleod@redhat.com> wrote:
>>>>>>> On 11/19/2014 01:12 PM, David Malcolm wrote:
>>>>>>>
>>>>>>>> (A) could become:
>>>>>>>>
>>>>>>>>       greturn *stmt = gsi->as_a_greturn ();
>>>>>>>>
>>>>>>>> (B) could become:
>>>>>>>>
>>>>>>>>       stmt = gsi->dyn_cast <gcall *> ();
>>>>>>>>       if (!stmt)
>>>>>>>> or:
>>>>>>>>
>>>>>>>>       stmt = gsi->dyn_cast_gcall ();
>>>>>>>>       if (!stmt)
>>>>>>>>
>>>>>>>> or maybe:
>>>>>>>>
>>>>>>>>       stmt = gsi->is_a_gcall ();
>>>>>>>>       if (!stmt)
>>>>>>>>
>>>>>>>> An earlier version of my patches had casting methods within the
>>>>>>>> gimple_statement_base class, which were rejected; the above
>>>>> proposals
>>>>>>>> would instead put them within gimple_stmt_iterator.
>>>>>>>>
>>>>>>> I would like all gsi routines to be consistent, not a mix of
>>>>> functions
>>>>>>> and methods.
>>>>>>> so something like
>>>>>>>
>>>>>>> stmt = gsi_as_call (gsi);
>>>>>>> stmt = gsi_dyn_call (gsi);
>>>>>>>
>>>>>>> or we need to change gsi_stmt() and friends into methods and access
>>>>>>> them
>>>>>>> as gsi->stmt ()..  which is possibly better, but that much more
>>>>>>> intrusive again (another 2000+ locations).
>>>>>>> If we switched to methods everywhere for gsi, I'd prefer something
>>>>> like
>>>>>>> gsi->as_a_call ()
>>>>>>> gsi->is_a_call ()
>>>>>>> gsi->dyn_cast_call ()
>>>>>>>
>>>>>>> I think its more readable... and it removes a dependency on the
>>>>>>> implementation.. so if we ever decide to change the name of 'gcall'
>>>>>>> down
>>>>>>> the road to using a namespace, and make it gimple::call or whatever,
>>>>> we
>>>>>>> wont have to change every single gsi-> location which has a
>>>>> templated
>>>>>>> use of the type.
>>>>>>>
>>>>>>> I'm also think this sort of thing could probably wait until next
>>>>> stage
>>>>>>> 1..
>>>>>>>
>>>>>>> my 2 cents...
>>>>>> Why not as_a <gassign *> (*gsi)?  It would
>>>>>> Add operator* to gsi of course.
>>>>>>
>>>>>> Richard.
>>>>>>
>>>>>>
>>>>> I could live with that form too.
>>>>>
>>>>> we often have an instance of gimple_stmt_iterator rather than a pointer
>>>>>
>>>>> to it, so wouldn't  "operator gimple *()" to implicitly call gsi_stmt()
>>>>>
>>>>> when needed work better?     (or "operator gimple ()" before the next
>>>>> change) ..
>>>> Not sure.  The * matches how iterators work in STL...
>>>>
>>>> Note that for the cases where we pass a pointer to an iterator we can
>>>> change those to use references to avoid writing **gsi.
>>>>
>>>> Richard.
>>>>
>>>>> Andrew
>>> I had a go at adding an operator * to gimple_stmt_iterator, using it
>>> everywhere that we do an as_a<> or dyn_cast<> on the result of a
>>> gsi_stmt, to abbreviate the gsi_stmt call down to one character.
>>>
>>> Patch attached; only lightly smoketested; am posting it for the sake of
>>> discussion.
>>>
>>> I don't think this API will make the non-C++-fans happier; I think the
>>> objection to the work I just merged is that it's adding more C++ than
>>> those people are comfortable with.
>>>
>>> So although the attached patch makes things shorter (good), it's taking
>>> things in a "more C++" direction (questionable).  I'd hoped to paper
>>> over the C++ somewhat.
>>>
>>> I suspect that any API which requires the of < > characters within the
>>> implementation of a gimple pass to mean a template is going to give
>>> those less happy with C++ a visceral "ugh" reaction.  I wonder if
>>> there's a way to spell these things that's concise and which doesn't
>>> involve <> ?
>>>
>> wasnt that my last  thought?   is_a_call(), as_a_call() and dyn_cast_call ()
>> ?
>>
>> I think lack of <> in identifiers helps us old brains parse faster :-)    <>
>> are like ()... many many years of causing a certain kind of break in mental
>> processing. I'm accustomed to single <> these days, but once you get into
>> multiple <>'s I quickly loose track.  I find the same thing with ()... hence
>> I'm not a lisp fan :-)
> I think we want to have a consistent style across GCC even if seen as
> ugly to some people.  Thus having (member) functions for conversion in
> some cases
> and as_a <> templates in others is bad.  C++ was supposed to make
> grok GCC easier for newbies - this is exactly making it harder (not that
> I believe in this story at all...)
>
>> I dont think 'operator *' c++ifies it too much, but I still think operator
>> gimple() would be easier...  no extra character at all, and no odd looking
>> dereference of a non-pointer object or double dereference of a pointer.  I
>> cant think of how that could get us into trouble... it'll always map to the
>> stmt the iterator currently points to.
> I dislike conversion operators.  Why is 'operator *' bad?  It's exactly
> how iterators are supposed to work - after all the gsi stuff was modeled
> after STL iterators!
>
> So that's a definitive "no" from me to is_a_call () as_a_call () etc.
>
> Richard.
>
Fine by me, Just running through the options to make sure we know what 
we are getting :-)

Andrew
diff mbox

Patch

diff --git a/gcc/asan.c b/gcc/asan.c
index be28ede..d06d60c 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1902,7 +1902,7 @@  instrument_builtin_call (gimple_stmt_iterator *iter)
     return false;
 
   bool iter_advanced_p = false;
-  gcall *call = as_a <gcall *> (gsi_stmt (*iter));
+  gcall *call = as_a <gcall *> (**iter);
 
   gcc_checking_assert (gimple_call_builtin_p (call, BUILT_IN_NORMAL));
 
diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index 7055c4a..c6a17d7 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -1433,7 +1433,7 @@  afdo_vpt_for_early_inline (stmt_set *promoted_stmts)
 
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       {
-        gcall *stmt = dyn_cast <gcall *> (gsi_stmt (gsi));
+        gcall *stmt = dyn_cast <gcall *> (*gsi);
         /* IC_promotion and early_inline_2 is done in multiple iterations.
            No need to promoted the stmt if its in promoted_stmts (means
            it is already been promoted in the previous iterations).  */
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 45c13b4..15b7c5c 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -2015,7 +2015,7 @@  label_rtx_for_bb (basic_block bb ATTRIBUTE_UNUSED)
     {
       glabel *lab_stmt;
 
-      lab_stmt = dyn_cast <glabel *> (gsi_stmt (gsi));
+      lab_stmt = dyn_cast <glabel *> (*gsi);
       if (!lab_stmt)
 	break;
 
@@ -4985,7 +4985,7 @@  expand_gimple_basic_block (basic_block bb, bool disable_tail_calls)
   if (!gsi_end_p (gsi)
       && gimple_code (gsi_stmt (gsi)) == GIMPLE_RETURN)
     {
-      greturn *ret_stmt = as_a <greturn *> (gsi_stmt (gsi));
+      greturn *ret_stmt = as_a <greturn *> (*gsi);
 
       gcc_assert (single_succ_p (bb));
       gcc_assert (single_succ (bb) == EXIT_BLOCK_PTR_FOR_FN (cfun));
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 8e0c9e0..1e325a8 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -2024,7 +2024,7 @@  static bool
 gimple_fold_builtin_snprintf_chk (gimple_stmt_iterator *gsi,
 				  enum built_in_function fcode)
 {
-  gcall *stmt = as_a <gcall *> (gsi_stmt (*gsi));
+  gcall *stmt = as_a <gcall *> (**gsi);
   tree dest, size, len, fn, fmt, flag;
   const char *fmt_str;
 
@@ -2104,7 +2104,7 @@  static bool
 gimple_fold_builtin_sprintf_chk (gimple_stmt_iterator *gsi,
 				 enum built_in_function fcode)
 {
-  gcall *stmt = as_a <gcall *> (gsi_stmt (*gsi));
+  gcall *stmt = as_a <gcall *> (**gsi);
   tree dest, size, len, fn, fmt, flag;
   const char *fmt_str;
   unsigned nargs = gimple_call_num_args (stmt);
@@ -2327,7 +2327,7 @@  gimple_fold_builtin_sprintf (gimple_stmt_iterator *gsi)
 static bool
 gimple_fold_builtin_snprintf (gimple_stmt_iterator *gsi)
 {
-  gcall *stmt = as_a <gcall *> (gsi_stmt (*gsi));
+  gcall *stmt = as_a <gcall *> (**gsi);
   tree dest = gimple_call_arg (stmt, 0);
   tree destsize = gimple_call_arg (stmt, 1);
   tree fmt = gimple_call_arg (stmt, 2);
@@ -2621,7 +2621,7 @@  arith_overflowed_p (enum tree_code code, const_tree type,
 static bool
 gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace)
 {
-  gcall *stmt = as_a <gcall *> (gsi_stmt (*gsi));
+  gcall *stmt = as_a <gcall *> (**gsi);
   tree callee;
   bool changed = false;
   unsigned i;
diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h
index fb6cc07..eb4ae40 100644
--- a/gcc/gimple-iterator.h
+++ b/gcc/gimple-iterator.h
@@ -33,6 +33,8 @@  struct gimple_stmt_iterator
      block/sequence is removed.  */
   gimple_seq *seq;
   basic_block bb;
+
+  gimple operator * ();
 };
 
 /* Iterator over GIMPLE_PHI statements.  */
@@ -331,4 +333,11 @@  gsi_seq (gimple_stmt_iterator i)
   return *i.seq;
 }
 
+inline gimple
+gimple_stmt_iterator::operator * ()
+{
+  return gsi_stmt (*this);
+}
+
+
 #endif /* GCC_GIMPLE_ITERATOR_H */
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 402a921..63215fd 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -400,7 +400,7 @@  static void
 lower_gimple_bind (gimple_stmt_iterator *gsi, struct lower_data *data)
 {
   tree old_block = data->block;
-  gbind *stmt = as_a <gbind *> (gsi_stmt (*gsi));
+  gbind *stmt = as_a <gbind *> (**gsi);
   tree new_block = gimple_bind_block (stmt);
 
   if (new_block)
@@ -473,8 +473,7 @@  lower_try_catch (gimple_stmt_iterator *gsi, struct lower_data *data)
       for (; !gsi_end_p (i); gsi_next (&i))
 	{
 	  data->cannot_fallthru = false;
-	  lower_sequence (gimple_catch_handler_ptr (
-                            as_a <gcatch *> (gsi_stmt (i))),
+	  lower_sequence (gimple_catch_handler_ptr (as_a <gcatch *> (*i)),
 			  data);
 	  if (!data->cannot_fallthru)
 	    cannot_fallthru = false;
@@ -538,7 +537,7 @@  gimple_try_catch_may_fallthru (gtry *stmt)
       for (; !gsi_end_p (i); gsi_next (&i))
 	{
 	  if (gimple_seq_may_fallthru (gimple_catch_handler (
-					 as_a <gcatch *> (gsi_stmt (i)))))
+					 as_a <gcatch *> (*i))))
 	    return true;
 	}
       return false;
@@ -648,7 +647,7 @@  gimple_seq_may_fallthru (gimple_seq seq)
 static void
 lower_gimple_return (gimple_stmt_iterator *gsi, struct lower_data *data)
 {
-  greturn *stmt = as_a <greturn *> (gsi_stmt (*gsi));
+  greturn *stmt = as_a <greturn *> (**gsi);
   gimple t;
   int i;
   return_statements_t tmp_rs;
diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c
index 6dc63fd..ad194b1 100644
--- a/gcc/gimple-ssa-isolate-paths.c
+++ b/gcc/gimple-ssa-isolate-paths.c
@@ -216,7 +216,7 @@  isolate_path (basic_block bb, basic_block duplicate,
     {
       if (ret_zero)
 	{
-	  greturn *ret = as_a <greturn *> (gsi_stmt (si2));
+	  greturn *ret = as_a <greturn *> (*si2);
 	  tree zero = build_zero_cst (TREE_TYPE (gimple_return_retval (ret)));
 	  gimple_return_set_retval (ret, zero);
 	  update_stmt (ret);
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index 134b33f..dc909cf 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -320,7 +320,7 @@  verify_non_ssa_vars (struct split_point *current, bitmap non_ssa_vars,
       {
         gimple_stmt_iterator bsi;
         for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
-	  if (glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (bsi)))
+	  if (glabel *label_stmt = dyn_cast <glabel *> (*bsi))
 	    {
 	      if (test_nonssa_use (label_stmt,
 				   gimple_label_label (label_stmt),
@@ -787,7 +787,7 @@  find_retval (basic_block return_bb)
 {
   gimple_stmt_iterator bsi;
   for (bsi = gsi_start_bb (return_bb); !gsi_end_p (bsi); gsi_next (&bsi))
-    if (greturn *return_stmt = dyn_cast <greturn *> (gsi_stmt (bsi)))
+    if (greturn *return_stmt = dyn_cast <greturn *> (*bsi))
       return gimple_return_retval (return_stmt);
     else if (gimple_code (gsi_stmt (bsi)) == GIMPLE_ASSIGN
 	     && !gimple_clobber_p (gsi_stmt (bsi)))
@@ -1541,8 +1541,7 @@  split_function (struct split_point *split_point)
 		      gimple_stmt_iterator bsi;
 		      for (bsi = gsi_start_bb (return_bb); !gsi_end_p (bsi);
 			   gsi_next (&bsi))
-			if (greturn *return_stmt
-			      = dyn_cast <greturn *> (gsi_stmt (bsi)))
+			if (greturn *return_stmt = dyn_cast <greturn *> (*bsi))
 			  {
 			    gimple_return_set_retval (return_stmt, retval);
 			    break;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 15aa140..fe00974 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2074,7 +2074,7 @@  scan_omp_parallel (gimple_stmt_iterator *gsi, omp_context *outer_ctx)
 {
   omp_context *ctx;
   tree name;
-  gomp_parallel *stmt = as_a <gomp_parallel *> (gsi_stmt (*gsi));
+  gomp_parallel *stmt = as_a <gomp_parallel *> (**gsi);
 
   /* Ignore parallel directives with empty bodies, unless there
      are copyin clauses.  */
@@ -2151,7 +2151,7 @@  scan_omp_task (gimple_stmt_iterator *gsi, omp_context *outer_ctx)
 {
   omp_context *ctx;
   tree name, t;
-  gomp_task *stmt = as_a <gomp_task *> (gsi_stmt (*gsi));
+  gomp_task *stmt = as_a <gomp_task *> (**gsi);
 
   /* Ignore task directives with empty bodies.  */
   if (optimize > 0
@@ -5867,7 +5867,7 @@  expand_omp_for_generic (struct omp_region *region,
       /* Code to control the increment and predicate for the sequential
 	 loop goes in the CONT_BB.  */
       gsi = gsi_last_bb (cont_bb);
-      gomp_continue *cont_stmt = as_a <gomp_continue *> (gsi_stmt (gsi));
+      gomp_continue *cont_stmt = as_a <gomp_continue *> (*gsi);
       gcc_assert (gimple_code (cont_stmt) == GIMPLE_OMP_CONTINUE);
       vmain = gimple_omp_continue_control_use (cont_stmt);
       vback = gimple_omp_continue_control_def (cont_stmt);
@@ -6287,7 +6287,7 @@  expand_omp_for_static_nochunk (struct omp_region *region,
       /* The code controlling the sequential loop replaces the
 	 GIMPLE_OMP_CONTINUE.  */
       gsi = gsi_last_bb (cont_bb);
-      gomp_continue *cont_stmt = as_a <gomp_continue *> (gsi_stmt (gsi));
+      gomp_continue *cont_stmt = as_a <gomp_continue *> (*gsi);
       gcc_assert (gimple_code (cont_stmt) == GIMPLE_OMP_CONTINUE);
       vmain = gimple_omp_continue_control_use (cont_stmt);
       vback = gimple_omp_continue_control_def (cont_stmt);
@@ -6677,7 +6677,7 @@  expand_omp_for_static_chunk (struct omp_region *region,
       /* The code controlling the sequential loop goes in CONT_BB,
 	 replacing the GIMPLE_OMP_CONTINUE.  */
       gsi = gsi_last_bb (cont_bb);
-      gomp_continue *cont_stmt = as_a <gomp_continue *> (gsi_stmt (gsi));
+      gomp_continue *cont_stmt = as_a <gomp_continue *> (*gsi);
       vmain = gimple_omp_continue_control_use (cont_stmt);
       vback = gimple_omp_continue_control_def (cont_stmt);
 
@@ -7498,7 +7498,7 @@  expand_omp_sections (struct omp_region *region)
   /* The call to GOMP_sections_start goes in ENTRY_BB, replacing the
      GIMPLE_OMP_SECTIONS statement.  */
   si = gsi_last_bb (entry_bb);
-  sections_stmt = as_a <gomp_sections *> (gsi_stmt (si));
+  sections_stmt = as_a <gomp_sections *> (*si);
   gcc_assert (gimple_code (sections_stmt) == GIMPLE_OMP_SECTIONS);
   vin = gimple_omp_sections_control (sections_stmt);
   if (!is_combined_parallel (region))
@@ -8955,7 +8955,7 @@  lower_omp_sections (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   gbind *new_stmt, *bind;
   gimple_seq ilist, dlist, olist, new_body;
 
-  stmt = as_a <gomp_sections *> (gsi_stmt (*gsi_p));
+  stmt = as_a <gomp_sections *> (**gsi_p);
 
   push_gimplify_context ();
 
@@ -9163,7 +9163,7 @@  lower_omp_single (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block;
   gimple t;
-  gomp_single *single_stmt = as_a <gomp_single *> (gsi_stmt (*gsi_p));
+  gomp_single *single_stmt = as_a <gomp_single *> (**gsi_p);
   gbind *bind;
   gimple_seq bind_body, bind_body_tail = NULL, dlist;
 
@@ -9338,7 +9338,7 @@  lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block;
   tree name, lock, unlock;
-  gomp_critical *stmt = as_a <gomp_critical *> (gsi_stmt (*gsi_p));
+  gomp_critical *stmt = as_a <gomp_critical *> (**gsi_p);
   gbind *bind;
   location_t loc = gimple_location (stmt);
   gimple_seq tbody;
@@ -9492,7 +9492,7 @@  lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree *rhs_p, block;
   struct omp_for_data fd, *fdp = NULL;
-  gomp_for *stmt = as_a <gomp_for *> (gsi_stmt (*gsi_p));
+  gomp_for *stmt = as_a <gomp_for *> (**gsi_p);
   gbind *new_stmt;
   gimple_seq omp_for_body, body, dlist;
   size_t i;
@@ -10134,7 +10134,7 @@  lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree clauses;
   tree child_fn, t, c;
-  gomp_target *stmt = as_a <gomp_target *> (gsi_stmt (*gsi_p));
+  gomp_target *stmt = as_a <gomp_target *> (**gsi_p);
   gbind *tgt_bind = NULL, *bind;
   gimple_seq tgt_body = NULL, olist, ilist, new_body;
   location_t loc = gimple_location (stmt);
@@ -10444,7 +10444,7 @@  lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 static void
 lower_omp_teams (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
-  gomp_teams *teams_stmt = as_a <gomp_teams *> (gsi_stmt (*gsi_p));
+  gomp_teams *teams_stmt = as_a <gomp_teams *> (**gsi_p);
   push_gimplify_context ();
 
   tree block = make_node (BLOCK);
diff --git a/gcc/predict.c b/gcc/predict.c
index 779af11..0825341 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2246,7 +2246,7 @@  tree_estimate_probability_bb (basic_block bb)
 	  gimple_stmt_iterator gi;
 	  for (gi = gsi_start_bb (e->dest); !gsi_end_p (gi); gsi_next (&gi))
 	    {
-	      glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (gi));
+	      glabel *label_stmt = dyn_cast <glabel *> (*gi);
 	      tree decl;
 
 	      if (!label_stmt)
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index d3a6f10..6261731 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -1612,7 +1612,7 @@  static void
 lower_transaction (gimple_stmt_iterator *gsi, struct walk_stmt_info *wi)
 {
   gimple g;
-  gtransaction *stmt = as_a <gtransaction *> (gsi_stmt (*gsi));
+  gtransaction *stmt = as_a <gtransaction *> (**gsi);
   unsigned int *outer_state = (unsigned int *) wi->info;
   unsigned int this_state = 0;
   struct walk_stmt_info this_wi;
@@ -2362,7 +2362,7 @@  static bool
 expand_call_tm (struct tm_region *region,
 		gimple_stmt_iterator *gsi)
 {
-  gcall *stmt = as_a <gcall *> (gsi_stmt (*gsi));
+  gcall *stmt = as_a <gcall *> (**gsi);
   tree lhs = gimple_call_lhs (stmt);
   tree fn_decl;
   struct cgraph_node *node;
@@ -5106,7 +5106,7 @@  ipa_tm_transform_calls_redirect (struct cgraph_node *node,
 				 gimple_stmt_iterator *gsi,
 				 bool *need_ssa_rename_p)
 {
-  gcall *stmt = as_a <gcall *> (gsi_stmt (*gsi));
+  gcall *stmt = as_a <gcall *> (**gsi);
   struct cgraph_node *new_node;
   struct cgraph_edge *e = node->get_edge (stmt);
   tree fndecl = gimple_call_fndecl (stmt);
diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c
index 188a295..1321274 100644
--- a/gcc/tree-call-cdce.c
+++ b/gcc/tree-call-cdce.c
@@ -927,7 +927,7 @@  pass_call_cdce::execute (function *fun)
       /* Collect dead call candidates.  */
       for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
         {
-	  gcall *stmt = dyn_cast <gcall *> (gsi_stmt (i));
+	  gcall *stmt = dyn_cast <gcall *> (*i);
           if (stmt && is_call_dce_candidate (stmt))
             {
               if (dump_file && (dump_flags & TDF_DETAILS))
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index e78554f..f664ee6 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -943,7 +943,7 @@  make_edges (void)
 	{
 	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	    {
-	      glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (gsi));
+	      glabel *label_stmt = dyn_cast <glabel *> (*gsi);
 	      tree target;
 
 	      if (!label_stmt)
@@ -1407,7 +1407,7 @@  cleanup_dead_labels (void)
       for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
 	{
 	  tree label;
-	  glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (i));
+	  glabel *label_stmt = dyn_cast <glabel *> (*i);
 
 	  if (!label_stmt)
 	    break;
@@ -1550,7 +1550,7 @@  cleanup_dead_labels (void)
       for (i = gsi_start_bb (bb); !gsi_end_p (i); )
 	{
 	  tree label;
-	  glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (i));
+	  glabel *label_stmt = dyn_cast <glabel *> (*i);
 
 	  if (!label_stmt)
 	    break;
@@ -1706,7 +1706,7 @@  gimple_can_merge_blocks_p (basic_block a, basic_block b)
        gsi_next (&gsi))
     {
       tree lab;
-      glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (gsi));
+      glabel *label_stmt = dyn_cast <glabel *> (*gsi);
       if (!label_stmt)
 	break;
       lab = gimple_label_label (label_stmt);
@@ -5422,7 +5422,7 @@  gimple_block_label (basic_block bb)
 
   for (i = s; !gsi_end_p (i); first = false, gsi_next (&i))
     {
-      stmt = dyn_cast <glabel *> (gsi_stmt (i));
+      stmt = dyn_cast <glabel *> (*i);
       if (!stmt)
 	break;
       label = gimple_label_label (stmt);
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 3e38691..ee784be 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -1195,7 +1195,7 @@  chkp_get_registered_bounds (tree ptr)
 static void
 chkp_add_bounds_to_ret_stmt (gimple_stmt_iterator *gsi)
 {
-  greturn *ret = as_a <greturn *> (gsi_stmt (*gsi));
+  greturn *ret = as_a <greturn *> (**gsi);
   tree retval = gimple_return_retval (ret);
   tree ret_decl = DECL_RESULT (cfun->decl);
   tree bounds;
@@ -1634,7 +1634,7 @@  chkp_instrument_normal_builtin (tree fndecl)
 static void
 chkp_add_bounds_to_call_stmt (gimple_stmt_iterator *gsi)
 {
-  gcall *call = as_a <gcall *> (gsi_stmt (*gsi));
+  gcall *call = as_a <gcall *> (**gsi);
   unsigned arg_no = 0;
   tree fndecl = gimple_call_fndecl (call);
   tree fntype;
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index a2d3639..fb69511 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -1435,7 +1435,7 @@  expand_complex_comparison (gimple_stmt_iterator *gsi, tree ar, tree ai,
 static void
 expand_complex_asm (gimple_stmt_iterator *gsi)
 {
-  gasm *stmt = as_a <gasm *> (gsi_stmt (*gsi));
+  gasm *stmt = as_a <gasm *> (**gsi);
   unsigned int i;
 
   for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 8180ff7..575294a 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -1806,7 +1806,7 @@  lower_catch (struct leh_state *state, gtry *tp)
       gcatch *catch_stmt;
       gimple_seq handler;
 
-      catch_stmt = as_a <gcatch *> (gsi_stmt (gsi));
+      catch_stmt = as_a <gcatch *> (*gsi);
       c = gen_eh_region_catch (try_region, gimple_catch_types (catch_stmt));
 
       handler = gimple_catch_handler (catch_stmt);
@@ -4011,7 +4011,7 @@  unsplit_eh (eh_landing_pad lp)
      for a different region.  */
   for (gsi = gsi_start_bb (e_out->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (gsi));
+      glabel *label_stmt = dyn_cast <glabel *> (*gsi);
       tree lab;
       int lp_nr;
 
@@ -4283,7 +4283,7 @@  cleanup_empty_eh_unsplit (basic_block bb, edge e_out, eh_landing_pad lp)
   lab = NULL;
   for (gsi = gsi_start_bb (e_out->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      glabel *stmt = dyn_cast <glabel *> (gsi_stmt (gsi));
+      glabel *stmt = dyn_cast <glabel *> (*gsi);
       int lp_nr;
 
       if (!stmt)
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 835edd1..f4ba9d7 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -5003,7 +5003,7 @@  mark_local_labels_stmt (gimple_stmt_iterator *gsip,
 		        struct walk_stmt_info *wi)
 {
   copy_body_data *id = (copy_body_data *) wi->info;
-  glabel *stmt = dyn_cast <glabel *> (gsi_stmt (*gsip));
+  glabel *stmt = dyn_cast <glabel *> (**gsip);
 
   if (stmt)
     {
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 4d31837..9e25049 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -2146,7 +2146,7 @@  convert_nl_goto_receiver (gimple_stmt_iterator *gsi, bool *handled_ops_p,
   struct nesting_info *const info = (struct nesting_info *) wi->info;
   tree label, new_label;
   gimple_stmt_iterator tmp_gsi;
-  glabel *stmt = dyn_cast <glabel *> (gsi_stmt (*gsi));
+  glabel *stmt = dyn_cast <glabel *> (**gsi);
 
   if (!stmt)
     {
diff --git a/gcc/tree-nrv.c b/gcc/tree-nrv.c
index 182039e..28a8e04 100644
--- a/gcc/tree-nrv.c
+++ b/gcc/tree-nrv.c
@@ -394,7 +394,7 @@  pass_return_slot::execute (function *fun)
 	  gcall *stmt;
 	  bool slot_opt_p;
 
-	  stmt = dyn_cast <gcall *> (gsi_stmt (gsi));
+	  stmt = dyn_cast <gcall *> (*gsi);
 	  if (stmt
 	      && gimple_call_lhs (stmt)
 	      && !gimple_call_return_slot_opt_p (stmt)
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 8e4b94c..3822516 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -4900,7 +4900,7 @@  convert_callers (struct cgraph_node *node, tree old_decl,
         {
 	  gcall *stmt;
 	  tree call_fndecl;
-	  stmt = dyn_cast <gcall *> (gsi_stmt (gsi));
+	  stmt = dyn_cast <gcall *> (*gsi);
 	  if (!stmt)
 	    continue;
 	  call_fndecl = gimple_call_fndecl (stmt);
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 0e806f4..67e3fcb 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -891,7 +891,7 @@  rewrite_reciprocal (gimple_stmt_iterator *bsi)
   tree real_one;
   gimple_stmt_iterator gsi;
 
-  stmt = as_a <gassign *> (gsi_stmt (*bsi));
+  stmt = as_a <gassign *> (**bsi);
   lhs = gimple_assign_lhs (stmt);
   type = TREE_TYPE (lhs);
 
@@ -929,7 +929,7 @@  rewrite_bittest (gimple_stmt_iterator *bsi)
   tree lhs, name, t, a, b;
   use_operand_p use;
 
-  stmt = as_a <gassign *> (gsi_stmt (*bsi));
+  stmt = as_a <gassign *> (**bsi);
   lhs = gimple_assign_lhs (stmt);
 
   /* Verify that the single use of lhs is a comparison against zero.  */
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index db6f25f..550ab42 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -1229,7 +1229,7 @@  tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
   /* Finally create the new counter for number of iterations and add the new
      exit instruction.  */
   bsi = gsi_last_nondebug_bb (exit_bb);
-  exit_if = as_a <gcond *> (gsi_stmt (bsi));
+  exit_if = as_a <gcond *> (*bsi);
   create_iv (exit_base, exit_step, NULL_TREE, loop,
 	     &bsi, false, &ctr_before, &ctr_after);
   gimple_cond_set_code (exit_if, exit_cmp);
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 6ee2c39..c6b7861 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -155,10 +155,10 @@  single_non_singleton_phi_for_edges (gimple_seq seq, edge e0, edge e1)
   gimple_stmt_iterator i;
   gphi *phi = NULL;
   if (gimple_seq_singleton_p (seq))
-    return as_a <gphi *> (gsi_stmt (gsi_start (seq)));
+    return as_a <gphi *> (*gsi_start (seq));
   for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
     {
-      gphi *p = as_a <gphi *> (gsi_stmt (i));
+      gphi *p = as_a <gphi *> (*i);
       /* If the PHI arguments are equal then we can skip this PHI. */
       if (operand_equal_for_phi_arg_p (gimple_phi_arg_def (p, e0->dest_idx),
 				       gimple_phi_arg_def (p, e1->dest_idx)))
@@ -334,7 +334,7 @@  tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads)
 	     so try that first. */
 	  for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (&gsi))
 	    {
-	      phi = as_a <gphi *> (gsi_stmt (gsi));
+	      phi = as_a <gphi *> (*gsi);
 	      arg0 = gimple_phi_arg_def (phi, e1->dest_idx);
 	      arg1 = gimple_phi_arg_def (phi, e2->dest_idx);
 	      if (value_replacement (bb, bb1, e1, e2, phi, arg0, arg1) == 2)
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index 94a34ee..be0bf53 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -748,7 +748,7 @@  bool
 update_gimple_call (gimple_stmt_iterator *si_p, tree fn, int nargs, ...)
 {
   va_list ap;
-  gcall *new_stmt, *stmt = as_a <gcall *> (gsi_stmt (*si_p));
+  gcall *new_stmt, *stmt = as_a <gcall *> (**si_p);
 
   gcc_assert (is_gimple_call (stmt));
   va_start (ap, nargs);
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index e065f1a..71fa304 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -6842,7 +6842,7 @@  compute_points_to_sets (void)
 	  gcall *stmt;
 	  struct pt_solution *pt;
 
-	  stmt = dyn_cast <gcall *> (gsi_stmt (gsi));
+	  stmt = dyn_cast <gcall *> (*gsi);
 	  if (!stmt)
 	    continue;
 
@@ -7255,7 +7255,7 @@  ipa_pta_execute (void)
 	      varinfo_t vi, fi;
 	      tree decl;
 
-	      stmt = dyn_cast <gcall *> (gsi_stmt (gsi));
+	      stmt = dyn_cast <gcall *> (*gsi);
 	      if (!stmt)
 		continue;
 
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 037dfbc..b20942e 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -932,7 +932,7 @@  optimize_tail_call (struct tailcall *t, bool opt_tailcalls)
 
   if (opt_tailcalls)
     {
-      gcall *stmt = as_a <gcall *> (gsi_stmt (t->call_gsi));
+      gcall *stmt = as_a <gcall *> (*t->call_gsi);
 
       gimple_call_set_tail (stmt, true);
       cfun->tail_call_marked = true;
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index 246ca62..3089731 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -846,7 +846,7 @@  expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
 static void
 expand_vector_condition (gimple_stmt_iterator *gsi)
 {
-  gassign *stmt = as_a <gassign *> (gsi_stmt (*gsi));
+  gassign *stmt = as_a <gassign *> (**gsi);
   tree type = gimple_expr_type (stmt);
   tree a = gimple_assign_rhs1 (stmt);
   tree a1 = a;
@@ -1015,7 +1015,7 @@  expand_vector_operation (gimple_stmt_iterator *gsi, tree type, tree compute_type
 static void
 optimize_vector_constructor (gimple_stmt_iterator *gsi)
 {
-  gassign *stmt = as_a <gassign *> (gsi_stmt (*gsi));
+  gassign *stmt = as_a <gassign *> (**gsi);
   tree lhs = gimple_assign_lhs (stmt);
   tree rhs = gimple_assign_rhs1 (stmt);
   tree type = TREE_TYPE (rhs);
@@ -1230,7 +1230,7 @@  vector_element (gimple_stmt_iterator *gsi, tree vect, tree idx, tree *ptmpvec)
 static void
 lower_vec_perm (gimple_stmt_iterator *gsi)
 {
-  gassign *stmt = as_a <gassign *> (gsi_stmt (*gsi));
+  gassign *stmt = as_a <gassign *> (**gsi);
   tree mask = gimple_assign_rhs3 (stmt);
   tree vec0 = gimple_assign_rhs1 (stmt);
   tree vec1 = gimple_assign_rhs2 (stmt);
@@ -1410,7 +1410,7 @@  expand_vector_operations_1 (gimple_stmt_iterator *gsi)
   tree new_rhs;
 
   /* Only consider code == GIMPLE_ASSIGN. */
-  gassign *stmt = dyn_cast <gassign *> (gsi_stmt (*gsi));
+  gassign *stmt = dyn_cast <gassign *> (**gsi);
   if (!stmt)
     return;
 
diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index 5da0b18..a371e2c 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -1435,7 +1435,7 @@  instrument_nonnull_arg (gimple_stmt_iterator *gsi)
 static void
 instrument_nonnull_return (gimple_stmt_iterator *gsi)
 {
-  greturn *stmt = as_a <greturn *> (gsi_stmt (*gsi));
+  greturn *stmt = as_a <greturn *> (**gsi);
   location_t loc[2];
   tree arg = gimple_return_retval (stmt);
   /* infer_nonnull_range needs flag_delete_null_pointer_checks set,
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 7aac67d..72801e6 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -831,7 +831,7 @@  gimple_divmod_fixed_value_transform (gimple_stmt_iterator *si)
   gcov_type prob;
   gassign *stmt;
 
-  stmt = dyn_cast <gassign *> (gsi_stmt (*si));
+  stmt = dyn_cast <gassign *> (**si);
   if (!stmt)
     return false;
 
@@ -994,7 +994,7 @@  gimple_mod_pow2_value_transform (gimple_stmt_iterator *si)
   gcov_type prob;
   gassign *stmt;
 
-  stmt = dyn_cast <gassign *> (gsi_stmt (*si));
+  stmt = dyn_cast <gassign *> (**si);
   if (!stmt)
     return false;
 
@@ -1168,7 +1168,7 @@  gimple_mod_subtract_transform (gimple_stmt_iterator *si)
   gcov_type count1, count2;
   gassign *stmt;
 
-  stmt = dyn_cast <gassign *> (gsi_stmt (*si));
+  stmt = dyn_cast <gassign *> (**si);
   if (!stmt)
     return false;
 
@@ -1582,7 +1582,7 @@  gimple_ic_transform (gimple_stmt_iterator *gsi)
   gcov_type val, count, all, bb_all;
   struct cgraph_node *direct_call;
 
-  stmt = dyn_cast <gcall *> (gsi_stmt (*gsi));
+  stmt = dyn_cast <gcall *> (**gsi);
   if (!stmt)
     return false;
 
@@ -1810,7 +1810,7 @@  gimple_stringops_transform (gimple_stmt_iterator *gsi)
   tree tree_val;
   int size_arg;
 
-  stmt = dyn_cast <gcall *> (gsi_stmt (*gsi));
+  stmt = dyn_cast <gcall *> (**gsi);
   if (!stmt)
     return false;
   fndecl = gimple_call_fndecl (stmt);