This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/31130] [4.3 Regression] VRP no longer derives range for division after negation
- From: "ian at airs dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Mar 2007 17:08:20 -0000
- Subject: [Bug tree-optimization/31130] [4.3 Regression] VRP no longer derives range for division after negation
- References: <bug-31130-10053@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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