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
+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>
* dwarf2out.c (output_cfi): Add 'for_eh' parameter, use PTR_SIZE
break;
case DIV:
- if (arg1s == 0)
+ if (arg1s == 0
+ || (arg0s == (HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1)
+ && arg1s == -1))
return 0;
val = arg0s / arg1s;
break;
case MOD:
- if (arg1s == 0)
+ if (arg1s == 0
+ || (arg0s == (HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1)
+ && arg1s == -1))
return 0;
val = arg0s % arg1s;
break;
case UDIV:
- if (arg1 == 0)
+ if (arg1 == 0
+ || (arg0s == (HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1)
+ && arg1s == -1))
return 0;
val = (unsigned HOST_WIDE_INT) arg0 / arg1;
break;
case UMOD:
- if (arg1 == 0)
+ if (arg1 == 0
+ || (arg0s == (HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1)
+ && arg1s == -1))
return 0;
val = (unsigned HOST_WIDE_INT) arg0 % arg1;
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>
* gcc.c-torture/compile/20010326-1.c: New test.
--- /dev/null
+/* 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);
+}