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. > > I'm asking this question because the optimizations in back-end need this > info to do advanced optimization. > > Thanks, > -Jiangning > > >