summaryrefslogtreecommitdiff
path: root/gcc/simplify-rtx.c
diff options
context:
space:
mode:
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2001-04-05 02:27:47 +0000
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2001-04-05 02:27:47 +0000
commit194d4e232df38645d9f6e3477d76c99fa9857f98 (patch)
tree102c5ecab55ff14b05898ff73ce3c22e9dd1cd40 /gcc/simplify-rtx.c
parentb7020468e1444096c922207d24cf353f749a58bc (diff)
downloadgcc-194d4e232df38645d9f6e3477d76c99fa9857f98.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@41105 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r--gcc/simplify-rtx.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index dd7d2e1e6b5..af8b708977c 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -1407,25 +1407,33 @@ simplify_binary_operation (code, mode, op0, op1)
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;