On Tue, 25 Apr 2023, Richard Sandiford wrote:

> juzhe.zh...@rivai.ai writes:
> > diff --git a/gcc/tree-ssa-loop-manip.cc b/gcc/tree-ssa-loop-manip.cc
> > index a52277abdbf..54845a62298 100644
> > --- a/gcc/tree-ssa-loop-manip.cc
> > +++ b/gcc/tree-ssa-loop-manip.cc
> > @@ -59,14 +59,14 @@ static bitmap_obstack loop_renamer_obstack;
> >  void
> >  create_iv (tree base, tree step, tree var, class loop *loop,
> >        gimple_stmt_iterator *incr_pos, bool after,
> > -      tree *var_before, tree *var_after)
> > +      tree *var_before, tree *var_after, enum tree_code code)
> 
> The comment needs to be updated to describe the new interface.
> 
> This is personal preference, but: I think the interface would be
> clearer if the code argument came between the base and step,
> so that the order matches a SCEV.  The code could no longer be
> a default argument, and so all callers would need to be updated,
> but IMO that's OK.  Not sure what others think though.

Just a quick comment - I think decrementing IVs are already supported,
you just have to make 'step' negative (or large positive).  If you
really think using MINUS_EXPR is better or even required for
VLA step please add an assert that 'code' is either PLUS_EXPR or
MINUS_EXPR.

Note that for INTEGER_CST step we rewrite x - CST to x + -CST
during folding.

Going over v3 now.

Richard.

Reply via email to