RE: Is VRP is too conservative to identify boolean value 0 and 1?
> -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 > 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; > > > > : > > 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 ; > > else > > goto ; > > > > : > > > > : > > # 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 > > > > > >
RE: Is VRP is too conservative to identify boolean value 0 and 1?
Andrew, I realize I needn't back-end solution for my case at all, and in middle end I can directly use the _Bool type info! Appreciate your reply! Thanks, -Jiangning > -Original Message- > From: Andrew Pinski [mailto:pins...@gmail.com] > Sent: Friday, September 02, 2011 2:27 PM > To: Jiangning Liu > Cc: gcc@gcc.gnu.org > Subject: Re: Is VRP is too conservative to identify boolean value 0 and > 1? > > On Thu, Sep 1, 2011 at 10:58 PM, Jiangning Liu > wrote: > > D.1249_3: [0, 1] > > D.1250_5: [0, 1] > > D.1251_6: [0, 1] > > Those are equivalent to [0, MAX] as _Bool only has two different > values, 0 and 1 (MAX). Can you explain more about the optimization > which you are working on that needs the ranges as (int)[0,1] rather > than (_Bool)[0,MAX] ? > > Thanks, > Andrew Pinski
Re: Is VRP is too conservative to identify boolean value 0 and 1?
On Fri, Sep 2, 2011 at 7:58 AM, Jiangning Liu 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; > > : > 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 ; > else > goto ; > > : > > : > # 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. > > I'm asking this question because the optimizations in back-end need this > info to do advanced optimization. > > Thanks, > -Jiangning > > >
Re: Is VRP is too conservative to identify boolean value 0 and 1?
On Thu, Sep 1, 2011 at 10:58 PM, Jiangning Liu wrote: > D.1249_3: [0, 1] > D.1250_5: [0, 1] > D.1251_6: [0, 1] Those are equivalent to [0, MAX] as _Bool only has two different values, 0 and 1 (MAX). Can you explain more about the optimization which you are working on that needs the ranges as (int)[0,1] rather than (_Bool)[0,MAX] ? Thanks, Andrew Pinski
Is VRP is too conservative to identify boolean value 0 and 1?
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; : 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 ; else goto ; : : # 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? I'm asking this question because the optimizations in back-end need this info to do advanced optimization. Thanks, -Jiangning