Commit b0835578 by Diego Novillo Committed by Diego Novillo

simplify-rtx.c (simplify_binary_operation): Check for overflow when folding…

simplify-rtx.c (simplify_binary_operation): Check for overflow when folding integer division and modulo operations.

2001-04-04  Diego Novillo  <dnovillo@redhat.com>

	* simplify-rtx.c (simplify_binary_operation): Check for overflow
	when folding integer division and modulo operations.

2001-04-04  Diego Novillo  <dnovillo@redhat.com>

	* gcc.c-torture/compile/20010404-1.c: New test.

From-SVN: r41105
parent 12f0b96b
2001-04-04 Diego Novillo <dnovillo@redhat.com>
* simplify-rtx.c (simplify_binary_operation): Check for overflow
when folding integer division and modulo operations.
2001-04-04 Andrew MacLeod <amacleod@redhat.com> 2001-04-04 Andrew MacLeod <amacleod@redhat.com>
* dwarf2out.c (output_cfi): Add 'for_eh' parameter, use PTR_SIZE * dwarf2out.c (output_cfi): Add 'for_eh' parameter, use PTR_SIZE
......
...@@ -1407,25 +1407,33 @@ simplify_binary_operation (code, mode, op0, op1) ...@@ -1407,25 +1407,33 @@ simplify_binary_operation (code, mode, op0, op1)
break; break;
case DIV: case DIV:
if (arg1s == 0) if (arg1s == 0
|| (arg0s == (HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1)
&& arg1s == -1))
return 0; return 0;
val = arg0s / arg1s; val = arg0s / arg1s;
break; break;
case MOD: case MOD:
if (arg1s == 0) if (arg1s == 0
|| (arg0s == (HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1)
&& arg1s == -1))
return 0; return 0;
val = arg0s % arg1s; val = arg0s % arg1s;
break; break;
case UDIV: case UDIV:
if (arg1 == 0) if (arg1 == 0
|| (arg0s == (HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1)
&& arg1s == -1))
return 0; return 0;
val = (unsigned HOST_WIDE_INT) arg0 / arg1; val = (unsigned HOST_WIDE_INT) arg0 / arg1;
break; break;
case UMOD: case UMOD:
if (arg1 == 0) if (arg1 == 0
|| (arg0s == (HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1)
&& arg1s == -1))
return 0; return 0;
val = (unsigned HOST_WIDE_INT) arg0 % arg1; val = (unsigned HOST_WIDE_INT) arg0 % arg1;
break; break;
......
2001-04-04 Diego Novillo <dnovillo@redhat.com>
* gcc.c-torture/compile/20010404-1.c: New test.
2001-04-04 Jakub Jelinek <jakub@redhat.com> 2001-04-04 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/compile/20010326-1.c: New test. * gcc.c-torture/compile/20010326-1.c: New test.
......
/* This testcase caused a floating point exception in the compiler when
compiled with -O2. The crash occurs when trying to simplify division
and modulo operations. */
#include <limits.h>
extern void bar (int);
void foo ()
{
int a = INT_MIN;
int b = -1;
bar (a / b);
bar (a % b);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment