This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is VRP is too conservative to identify boolean value 0 and 1?
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Jiangning Liu <jiangning dot liu at arm dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 2 Sep 2011 11:07:26 +0200
- Subject: Re: Is VRP is too conservative to identify boolean value 0 and 1?
- References: <4e60730d.09852a0a.5b36.ffff99beSMTPIN_ADDED@mx.google.com>
On Fri, Sep 2, 2011 at 7:58 AM, Jiangning Liu <jiangning.liu@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
>
>
>