> -----Original Message-----
> From: Richard Biener <[email protected]>
> Sent: 07 July 2026 12:32
> To: Tamar Christina <[email protected]>
> Cc: [email protected]; nd <[email protected]>
> Subject: Re: [patch 1/3]middle-end: enable ranger in gimple-isel
> 
> On Tue, 7 Jul 2026, Tamar Christina wrote:
> 
> > This enabled ranger for use in isel to do some ranged based foldings.
> >
> > Not much else to write about this one :)
> >
> > Bootstrapped Regtested on aarch64-none-linux-gnu,
> > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu
> > -m32, -m64 and no issues.
> >
> > Ok for master?
> >
> > Thanks,
> > Tamar
> >
> > gcc/ChangeLog:
> >
> >     * gimple-isel.cc (pass_gimple_isel::execute): Enable and disable ranger
> >     on fun.
> >
> > ---
> > diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc
> > index
> b193e27b183e1a83d73369b629c81ea0d7db43cd..0bd3a2f732922bc939c
> 9d5fb4a221764def6e756 100644
> > --- a/gcc/gimple-isel.cc
> > +++ b/gcc/gimple-isel.cc
> > @@ -40,6 +40,8 @@ along with GCC; see the file COPYING3.  If not see
> >  #include "gimple-fold.h"
> >  #include "internal-fn.h"
> >  #include "fold-const.h"
> > +#include "gimple-range.h"
> > +
> >
> >  /* Expand all ARRAY_REF(VIEW_CONVERT_EXPR) gimple assignments into
> calls to
> >     internal function based on vector type of selected expansion.
> > @@ -1352,6 +1354,9 @@ pass_gimple_isel::execute (struct function *fun)
> >    gimple_stmt_iterator gsi;
> >    basic_block bb;
> >    bool cfg_changed = false;
> > +  bool created_ranger = get_range_query (fun) == get_global_range_query
> ();
> > +  if (created_ranger)
> > +    enable_ranger (fun);
> 
> We shouldn't have an active ranger across passes, do we?  I do not
> see us folding stmts here, not .WHILE_ULT anyway, so I'm missing
> the point of this (in isolation).

I'm explicitly using the on demand querying for querying the operands
of the WHILE_ULT.  I placed it here since it's cheaper than enabling and
disabling it every time in the target hook?

> 
> That said, just enable_ranger()/disable_ranger() w/o checks is OK
> with me, hopefully all the cost is on-demand.

Fair, I thought I had to guard it since enable_ranger checks for an existing
range instance.  But I suppose since other passes should have cleaned
up their instances this shouldn't be needed and indeed I don't see it
checked in other places.   Should have grepped before.

Will respin.

Thanks,
Tamar
> 
> >    FOR_EACH_BB_FN (bb, fun)
> >      {
> > @@ -1390,6 +1395,8 @@ pass_gimple_isel::execute (struct function *fun)
> >     }
> >      }
> >
> > +  if (created_ranger)
> > +    disable_ranger (fun);
> >    return cfg_changed ? TODO_cleanup_cfg : 0;
> >  }
> >
> >
> >
> >
> 
> --
> Richard Biener <[email protected]>
> SUSE Software Solutions Germany GmbH,
> Frankenstrasse 146, 90461 Nuernberg, Germany;
> GF: Jochen Jaser, Andrew McDonald; (HRB 36809, AG Nuernberg)

Reply via email to