From fd25e9579d7d7c3c97f0158d0b0b58845deaf7d5 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sun, 7 Dec 2003 12:57:13 +0000 Subject: [PATCH] re PR rtl-optimization/13318 (ICE: floating point exception in the loop optimizer) PR optimization/13318 * loop.c (express_from): Protect integer division from overflow. From-SVN: r74387 --- gcc/ChangeLog | 5 +++++ gcc/loop.c | 3 +++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/overflow-1.c | 25 +++++++++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/overflow-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c37ec9bc00a..ade64d8c973 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2003-12-07 Eric Botcazou + + PR optimization/13318 + * loop.c (express_from): Protect integer division from overflow. + 2003-12-07 Eric Botcazou PR optimization/13060 diff --git a/gcc/loop.c b/gcc/loop.c index 77567f868d4..373ff1478c4 100644 --- a/gcc/loop.c +++ b/gcc/loop.c @@ -7196,6 +7196,9 @@ express_from (struct induction *g1, struct induction *g2) && GET_CODE (g2->mult_val) == CONST_INT) { if (g1->mult_val == const0_rtx + || (g1->mult_val == constm1_rtx + && INTVAL (g2->mult_val) + == (HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1)) || INTVAL (g2->mult_val) % INTVAL (g1->mult_val) != 0) return NULL_RTX; mult = GEN_INT (INTVAL (g2->mult_val) / INTVAL (g1->mult_val)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3e1be98e256..b075f0e62c9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-12-07 Wolfgang Bangerth + + * gcc.dg/overflow-1.c: New test. + 2003-12-07 Eric Botcazou * g77.f-torture/compile/13060.f: New test. diff --git a/gcc/testsuite/gcc.dg/overflow-1.c b/gcc/testsuite/gcc.dg/overflow-1.c new file mode 100644 index 00000000000..db51a5ef129 --- /dev/null +++ b/gcc/testsuite/gcc.dg/overflow-1.c @@ -0,0 +1,25 @@ +/* PR optimization/13318 */ +/* Origin: */ +/* Reduced testcase: Wolfgang Bangerth */ + +/* Verify that the big multiplier doesn't cause an integer + overflow in the loop optimizer. */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct S { + int key; + int rnext,rprev; +}; + +void foo(struct S* H) +{ + int i, k; + for (i=0; i<2; i++){ + struct S* cell=H+k; + cell->key=i*(0xffffffffUL/2); + cell->rnext=k+(1-i); + cell->rprev=k+(1-i); + } +} -- 2.30.2