summaryrefslogtreecommitdiff
path: root/gcc/wide-int.cc
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-03 22:11:21 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-03 22:11:21 +0000
commitea796d8b75afdd39f78cd134fc643ba992c40aed (patch)
tree3f9c19a1394d9950b851dd20a8814dd2e5cfd361 /gcc/wide-int.cc
parent68e4cca165f2ad7056f1f3c3b3fb067a08e696af (diff)
downloadlinaro-gcc-ea796d8b75afdd39f78cd134fc643ba992c40aed.tar.gz
linaro-gcc-ea796d8b75afdd39f78cd134fc643ba992c40aed.tar.bz2
linaro-gcc-ea796d8b75afdd39f78cd134fc643ba992c40aed.zip
PR tree-optimization/61682
* wide-int.cc (wi::mul_internal): Handle high correctly for umul_ppmm using cases and when one of the operands is equal to 1. * gcc.c-torture/execute/pr61682.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212273 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/wide-int.cc')
-rw-r--r--gcc/wide-int.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/gcc/wide-int.cc b/gcc/wide-int.cc
index ed7f01bd19e..c33d10ea20d 100644
--- a/gcc/wide-int.cc
+++ b/gcc/wide-int.cc
@@ -1,5 +1,5 @@
/* Operations with very long integers.
- Copyright (C) 2012-2013 Free Software Foundation, Inc.
+ Copyright (C) 2012-2014 Free Software Foundation, Inc.
Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
This file is part of GCC.
@@ -1282,6 +1282,12 @@ wi::mul_internal (HOST_WIDE_INT *val, const HOST_WIDE_INT *op1val,
&& wi::fits_uhwi_p (op1)
&& wi::fits_uhwi_p (op2))
{
+ /* This case never overflows. */
+ if (high)
+ {
+ val[0] = 0;
+ return 1;
+ }
umul_ppmm (val[1], val[0], op1.ulow (), op2.ulow ());
return 1 + (val[1] != 0 || val[0] < 0);
}
@@ -1294,6 +1300,8 @@ wi::mul_internal (HOST_WIDE_INT *val, const HOST_WIDE_INT *op1val,
umul_ppmm (upper, val[0], op1.ulow (), op2.ulow ());
if (needs_overflow)
*overflow = (upper != 0);
+ if (high)
+ val[0] = upper;
return 1;
}
}
@@ -1302,12 +1310,22 @@ wi::mul_internal (HOST_WIDE_INT *val, const HOST_WIDE_INT *op1val,
/* Handle multiplications by 1. */
if (op1 == 1)
{
+ if (high)
+ {
+ val[0] = wi::neg_p (op2, sgn) ? -1 : 0;
+ return 1;
+ }
for (i = 0; i < op2len; i++)
val[i] = op2val[i];
return op2len;
}
if (op2 == 1)
{
+ if (high)
+ {
+ val[0] = wi::neg_p (op1, sgn) ? -1 : 0;
+ return 1;
+ }
for (i = 0; i < op1len; i++)
val[i] = op1val[i];
return op1len;