------- Comment #4 from ian at airs dot com 2007-03-12 17:08 -------
First test case:
int f(int a)
{
if (a < 0)
a = -a;
return a < 0;
}
As far as I can tell the behaviour of this test case in VRP is unchanged by the
patch in this PR. And the code is still fully optimized.
Second test case:
int f(int a)
{
if (a < 0)
a = -a;
if (a < 0)
a = -a;
return a < 0;
}
In my tests the second conditional is removed during the VRP pass with or
without the patch in this PR. It is cleaned up by jump threading.
Third test case:
extern void link_error ();
void foo (int a)
{
if (a < 0)
{
int y;
a *=-2;
y = a / 7;
if (y > 1 << 30)
link_error ();
}
}
int main()
{
return 0;
}
I agree that VRP does not sort this out, although the final generated code is
fine. I personally think the overflow infinity code does the right thing here.
Fourth test case:
extern void link_error ();
void foo (int a)
{
if (a < 0)
{
int y;
y = -a / 7;
if (y > 1 << 30)
link_error ();
}
}
This does give a warning with -Wstrict-overflow=4
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31130