aboutsummaryrefslogtreecommitdiff
path: root/libgcc/libgcc2.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-10-13 19:19:12 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-10-13 19:19:12 +0200
commite7176f75d6b2dd56059dad5920c770dade79df95 (patch)
tree7ac0495b4cd1c60e5a022d19c0de3ce667bdd725 /libgcc/libgcc2.c
parent8de7190350263d381df5c12cfbbfb4191b8d3973 (diff)
downloadgcc-e7176f75d6b2dd56059dad5920c770dade79df95.zip
gcc-e7176f75d6b2dd56059dad5920c770dade79df95.tar.gz
gcc-e7176f75d6b2dd56059dad5920c770dade79df95.tar.bz2
re PR target/82274 (__builtin_mul_overflow fails to detect overflow for int64_t when compiled with -m32)
PR target/82274 * internal-fn.c (expand_mul_overflow): If both operands have the same highpart of -1 or 0 and the topmost bit of lowpart is different, overflow is if res <= 0 rather than res < 0. * libgcc2.c (__mulvDI3): If both operands have the same highpart of -1 and the topmost bit of lowpart is 0, multiplication overflows even if both lowparts are 0. * gcc.dg/pr82274-1.c: New test. * gcc.dg/pr82274-2.c: New test. From-SVN: r253734
Diffstat (limited to 'libgcc/libgcc2.c')
-rw-r--r--libgcc/libgcc2.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c
index 5d3c69f..83f865a 100644
--- a/libgcc/libgcc2.c
+++ b/libgcc/libgcc2.c
@@ -375,7 +375,8 @@ __mulvDI3 (DWtype u, DWtype v)
}
else
{
- if (uu.s.high == (Wtype) -1 && vv.s.high == (Wtype) - 1)
+ if ((uu.s.high & vv.s.high) == (Wtype) -1
+ && (uu.s.low | vv.s.low) != 0)
{
DWunion ww = {.ll = (UDWtype) (UWtype) uu.s.low
* (UDWtype) (UWtype) vv.s.low};