This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hello,
The two following tests fail on i586-pc-linux-gnu:
FAIL: gcc.c-torture/execute/loop-2c.c execution, -Os
FAIL: gcc.c-torture/execute/loop-2d.c execution, -Os
The failures are caused by a mis-optimization of the loop:
unsigned int i;
for (p = &a[b], i = b; --i < ~0; )
*--p = i * 3 + o;
See http://gcc.gnu.org/ml/gcc/2002-05/msg00813.html
As I said in the thread, I first tried to make the loop optimizer
able to detect such a case for which a biv wraps around. But I couldn't
come up with anything else than a massive pessimization (loop.c already
contains two '??? Turn this off due to possible overflow' notes).
This testcase can obviously be better handled at the semantics level,
because i < ~0 is nothing else than i != ~0, and this latter variant
is not prone to the same optimization bug. After looking into the
constant folding code, I found that the transformation is already
implemented (fold-const.c: 6734 and below) but it is shadowed by
another one (fold-const.c: 6493 and below).
The attached patch disables the first transformation for a subset of
the cases for which the second one is valid.
Bootstrapped/regtested (C/C++) on i586-pc-linux-gnu (gcc-3_1-branch),
the two aforementioned failures being fixed.
2002-05-14 Eric Botcazou <ebotcazou@multimania.com>
* fold-const.c (fold) [LT_EXPR]: Don't apply the
'X < CST' to 'X <= (CST-1)' transformation when
X is an integer and CST is the highest possible
positive constante.
--
Eric Botcazou
ebotcazou@multimania.com
Attachment:
fold-const.diff
Description: Binary data
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |