This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Is VRP is too conservative to identify boolean value 0 and 1?
- From: "Jiangning Liu" <jiangning dot liu at arm dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Fri, 2 Sep 2011 13:58:27 +0800
- Subject: 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;
<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?
I'm asking this question because the optimizations in back-end need this
info to do advanced optimization.
Thanks,
-Jiangning