Fix another testsuite failure on i586-pc-linux-gnu
Eric Botcazou
ebotcazou@libertysurf.fr
Thu May 16 14:42:00 GMT 2002
Hello,
The following test fails on i586-pc-linux-gnu:
FAIL: gcc.c-torture/execute/loop-3c.c execution, -Os
The failure is caused by a mis-optimization of the loop:
int i;
i = m;
do
{
a[sh >>= 1] = ((unsigned)i << 3) + (char*)a;
i += 4;
}
while (i < INT_MAX/2 + 1 + 4 * 4);
The loop optimizer replaces the biv i by the giv i*8 (i<<3).
Therefore the loop comparison becomes:
while (j < (INT_MAX/2 + 1 + 4 * 4) * 8)
which of course badly overflows when folding. Then for some well-chosen
values of m (e.g INT_MAX/2 + INT_MAX/4 + 2), the loop is executed several
times while it shouldn't.
The proposed fix is to explicitly check for the overflow in that case.
Bootstrapped/regtested (C/C++) on i586-pc-linux-gnu (gcc-3_1-branch),
the aforementioned failure being fixed.
2002-05-16 Eric Botcazou <ebotcazou@multimania.com>
* expmed.c (const_mult_add_overflow_p): New.
* loop.c (maybe_eliminate_biv_1) [COMPARE]: Use it.
Don't eliminate the biv if the giv has a constant
multiplier and the rhs argument of the comparison
does satisfy the predicate. Use expand_mult_add
to compute the replacement constant.
--
Eric Botcazou
ebotcazou@multimania.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: loop-opt.diff
Type: application/octet-stream
Size: 3989 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20020516/6b52ed91/attachment.obj>
More information about the Gcc-patches
mailing list