aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/double-int.c4
-rw-r--r--gcc/expr.c2
-rw-r--r--gcc/simplify-rtx.c2
-rw-r--r--gcc/stor-layout.c12
-rw-r--r--gcc/tree-ssa-loop-ivopts.c6
-rw-r--r--gcc/tree.c2
7 files changed, 27 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index acdfadb..9c7fffe 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2012-08-13 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/53968
+ * tree.c (integer_pow2p): Avoid undefined signed overflows.
+ * simplify-rtx.c (neg_const_int): Likewise.
+ * expr.c (fixup_args_size_notes): Likewise.
+ * stor-layout.c (set_min_and_max_values_for_integral_type): Likewise.
+ * double-int.c (mul_double_wide_with_sign): Likewise.
+ (double_int_mask): Likewise.
+ * tree-ssa-loop-ivopts.c (get_address_cost): Likewise.
+
2012-08-13 Richard Guenther <rguenther@suse.de>
PR tree-optimization/54200
diff --git a/gcc/double-int.c b/gcc/double-int.c
index 1204dc7..ea518e3 100644
--- a/gcc/double-int.c
+++ b/gcc/double-int.c
@@ -170,7 +170,7 @@ mul_double_wide_with_sign (unsigned HOST_WIDE_INT l1, HOST_WIDE_INT h1,
{
k = i + j;
/* This product is <= 0xFFFE0001, the sum <= 0xFFFF0000. */
- carry += arg1[i] * arg2[j];
+ carry += (unsigned HOST_WIDE_INT) arg1[i] * arg2[j];
/* Since prod[p] < 0xFFFF, this sum <= 0xFFFFFFFF. */
carry += prod[k];
prod[k] = LOWPART (carry);
@@ -625,7 +625,7 @@ double_int_mask (unsigned prec)
else
{
mask.high = 0;
- mask.low = ((unsigned HOST_WIDE_INT) 2 << (prec - 1)) - 1;
+ mask.low = prec ? ((unsigned HOST_WIDE_INT) 2 << (prec - 1)) - 1 : 0;
}
return mask;
diff --git a/gcc/expr.c b/gcc/expr.c
index 69e043d..4e7eb5fb 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -3828,7 +3828,7 @@ fixup_args_size_notes (rtx prev, rtx last, int end_args_size)
add_reg_note (insn, REG_ARGS_SIZE, GEN_INT (args_size));
#ifdef STACK_GROWS_DOWNWARD
- this_delta = -this_delta;
+ this_delta = -(unsigned HOST_WIDE_INT) this_delta;
#endif
args_size -= this_delta;
}
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index f56a5ed..16dbd8a 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -66,7 +66,7 @@ static rtx simplify_binary_operation_1 (enum rtx_code, enum machine_mode,
static rtx
neg_const_int (enum machine_mode mode, const_rtx i)
{
- return gen_int_mode (- INTVAL (i), mode);
+ return gen_int_mode (-(unsigned HOST_WIDE_INT) INTVAL (i), mode);
}
/* Test whether expression, X, is an immediate constant that represents
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index ddec141..53554a9 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -1,7 +1,7 @@
/* C-compiler utilities for types and variables storage layout
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1996, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
- 2011 Free Software Foundation, Inc.
+ 2011, 2012 Free Software Foundation, Inc.
This file is part of GCC.
@@ -2568,10 +2568,14 @@ set_min_and_max_values_for_integral_type (tree type,
= build_int_cst_wide (type,
(precision - HOST_BITS_PER_WIDE_INT > 0
? -1
- : ((HOST_WIDE_INT) 1 << (precision - 1)) - 1),
+ : (HOST_WIDE_INT)
+ (((unsigned HOST_WIDE_INT) 1
+ << (precision - 1)) - 1)),
(precision - HOST_BITS_PER_WIDE_INT - 1 > 0
- ? (((HOST_WIDE_INT) 1
- << (precision - HOST_BITS_PER_WIDE_INT - 1))) - 1
+ ? (HOST_WIDE_INT)
+ ((((unsigned HOST_WIDE_INT) 1
+ << (precision - HOST_BITS_PER_WIDE_INT
+ - 1))) - 1)
: 0));
}
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index c44567f..81271a7 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1,5 +1,5 @@
/* Induction variable optimizations.
- Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+ Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
This file is part of GCC.
@@ -3173,7 +3173,7 @@ get_address_cost (bool symbol_present, bool var_present,
for (i = width; i >= 0; i--)
{
- off = -((HOST_WIDE_INT) 1 << i);
+ off = -((unsigned HOST_WIDE_INT) 1 << i);
XEXP (addr, 1) = gen_int_mode (off, address_mode);
if (memory_address_addr_space_p (mem_mode, addr, as))
break;
@@ -3182,7 +3182,7 @@ get_address_cost (bool symbol_present, bool var_present,
for (i = width; i >= 0; i--)
{
- off = ((HOST_WIDE_INT) 1 << i) - 1;
+ off = ((unsigned HOST_WIDE_INT) 1 << i) - 1;
XEXP (addr, 1) = gen_int_mode (off, address_mode);
if (memory_address_addr_space_p (mem_mode, addr, as))
break;
diff --git a/gcc/tree.c b/gcc/tree.c
index 6e864c3..279850a 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1849,7 +1849,7 @@ int
integer_pow2p (const_tree expr)
{
int prec;
- HOST_WIDE_INT high, low;
+ unsigned HOST_WIDE_INT high, low;
STRIP_NOPS (expr);