> -----Original Message-----
> From: Richard Guenther [mailto:richard.guent...@gmail.com]
> Sent: Friday, September 02, 2011 5:07 PM
> To: Jiangning Liu
> Cc: gcc@gcc.gnu.org
> Subject: Re: Is VRP is too conservative to identify boolean value 0 and
> 1?
> 
> On Fri, Sep 2, 2011 at 7:58 AM, Jiangning Liu <jiangning....@arm.com>
> wrote:
> > Hi,
> >
> > For the following small case,
> >
> > int f(int i, int j)
> > {
> >        if (i==1 && j==2)
> >                return i;
> >        else
> >                return j;
> > }
> >
> > with -O2 option, GCC has vrp2 dump like below,
> >
> > ======================
> >
> > Value ranges after VRP:
> >
> > i_1: VARYING
> > i_2(D): VARYING
> > D.1249_3: [0, +INF]
> > j_4(D): VARYING
> > D.1250_5: [0, +INF]
> > D.1251_6: [0, +INF]
> > j_10: [2, 2]  EQUIVALENCES: { j_4(D) } (1 elements)
> >
> >
> > Removing basic block 3
> > f (int i, int j)
> > {
> >  _Bool D.1251;
> >  _Bool D.1250;
> >  _Bool D.1249;
> >
> > <bb 2>:
> >  D.1249_3 = i_2(D) == 1;
> >  D.1250_5 = j_4(D) == 2;
> >  D.1251_6 = D.1250_5 & D.1249_3;
> >  if (D.1251_6 != 0)
> >    goto <bb 3>;
> >  else
> >    goto <bb 4>;
> >
> > <bb 3>:
> >
> > <bb 4>:
> >  # i_1 = PHI <1(3), j_4(D)(2)>
> >  return i_1;
> >
> > }
> >
> > ========================
> >
> > Variable D.1249_3, D.1250_5 and D.1251_6 should be boolean values, so
> the
> > their value ranges should be
> >
> > D.1249_3: [0, 1]
> > D.1250_5: [0, 1]
> > D.1251_6: [0, 1]
> >
> > So why current VRP can't find out this value range?
> 
> It does - it just prints it as [0, +INF], they are bools with
> TYPE_MAX_VALUE
> == 1 after all.

Richard,

May I use REG_EXPR(rtx of D.1249_3) in xxx.md file to detect whether
D.1249_3 is a bool or not? 

Some comments in GCC says REG_EXPR may be lost in back-end. True?

If we do have REG_EXPR info for some cases in back-end, is it guaranteed to
be correct? May I implementing back-end peephole optimization depending on
REG_EXPR?

Thanks,
-Jiangning

> 
> Richard.
> 
> >
> > I'm asking this question because the optimizations in back-end need
> this
> > info to do advanced optimization.
> >
> > Thanks,
> > -Jiangning
> >
> >
> >




Reply via email to