This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/25643] VRP does not remove -fbounds-check for Fortran
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Jan 2008 14:23:01 -0000
- Subject: [Bug tree-optimization/25643] VRP does not remove -fbounds-check for Fortran
- References: <bug-25643-6528@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #12 from rguenth at gcc dot gnu dot org 2008-01-12 14:23 -------
Simplified C testcase (omitting the parts that are optimized). We cannot
figure out the number of iterations of this loop:
void f(int n, float *v)
{
int i;
if (n <= 0)
return;
else
{
i = 1;
do {
if (i > n) __builtin_abort ();
v[i] = 0.;
i++;
} while (i <= n);
}
}
Note that for this simplified testcase DOM figures out the redundant test,
but not if you use i != n as the exit test, as for n == 1 the assert
will trigger. If you look at the fortran IL, it does instead
} while (i++ != n);
which would be ok again, but is still not optimized.
Testcase:
extern void link_error (void);
int i, n;
int main()
{
if (i > n)
return;
if (i != n)
if (i >= n)
link_error ();
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25643