summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2011-08-18 11:30:42 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2011-08-18 11:30:42 +0000
commit4c9cf7af89d0800e1f8fdeeba03ea41cdc3115f1 (patch)
treefbdfd26aa897edd883893073cf2f3b2ed9769b4a /gcc
parent97919ae7b65c192b0fdb6dfa6abdebd63a3f4ba9 (diff)
downloadgcc-4c9cf7af89d0800e1f8fdeeba03ea41cdc3115f1.tar.gz
re PR tree-optimization/49963 (ICE: in abs_hwi, at hwint.c:108)
2011-08-18 Paolo Carlini <paolo.carlini@oracle.com> Joseph Myers <joseph@codesourcery.com> PR tree-optimization/49963 * hwint.c (absu_hwi): Define. * hwint.h (absu_hwi): Declare. * fold-const.c (fold_plusminus_mult_expr): Use absu_hwi instead of abs_hwi. * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Likewise. * tree-ssa-loop-prefetch.c (prune_ref_by_group_reuse): Likewise. Co-Authored-By: Joseph Myers <joseph@codesourcery.com> From-SVN: r177848
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/fold-const.c4
-rw-r--r--gcc/hwint.c8
-rw-r--r--gcc/hwint.h1
-rw-r--r--gcc/tree-ssa-loop-prefetch.c2
-rw-r--r--gcc/tree-ssa-math-opts.c10
6 files changed, 28 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8e768f8538a..c46e1ee08b3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2011-08-18 Paolo Carlini <paolo.carlini@oracle.com>
+ Joseph Myers <joseph@codesourcery.com>
+
+ PR tree-optimization/49963
+ * hwint.c (absu_hwi): Define.
+ * hwint.h (absu_hwi): Declare.
+ * fold-const.c (fold_plusminus_mult_expr): Use absu_hwi instead
+ of abs_hwi.
+ * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Likewise.
+ * tree-ssa-loop-prefetch.c (prune_ref_by_group_reuse): Likewise.
+
2011-08-18 Richard Guenther <rguenther@suse.de>
* expr.c (get_inner_reference): Sign-extend the constant
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index a73b1e6a9ba..dcd6989b285 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -7036,7 +7036,7 @@ fold_plusminus_mult_expr (location_t loc, enum tree_code code, tree type,
int11 = TREE_INT_CST_LOW (arg11);
/* Move min of absolute values to int11. */
- if (abs_hwi (int01) < abs_hwi (int11))
+ if (absu_hwi (int01) < absu_hwi (int11))
{
tmp = int01, int01 = int11, int11 = tmp;
alt0 = arg00, arg00 = arg10, arg10 = alt0;
@@ -7046,7 +7046,7 @@ fold_plusminus_mult_expr (location_t loc, enum tree_code code, tree type,
else
maybe_same = arg11;
- if (exact_log2 (abs_hwi (int11)) > 0 && int01 % int11 == 0
+ if (exact_log2 (absu_hwi (int11)) > 0 && int01 % int11 == 0
/* The remainder should not be a constant, otherwise we
end up folding i * 4 + 2 to (i * 2 + 1) * 2 which has
increased the number of multiplications necessary. */
diff --git a/gcc/hwint.c b/gcc/hwint.c
index a128dc134f9..533133c7b4d 100644
--- a/gcc/hwint.c
+++ b/gcc/hwint.c
@@ -109,6 +109,14 @@ abs_hwi (HOST_WIDE_INT x)
return x >= 0 ? x : -x;
}
+/* Compute the absolute value of X as an unsigned type. */
+
+unsigned HOST_WIDE_INT
+absu_hwi (HOST_WIDE_INT x)
+{
+ return x >= 0 ? (unsigned HOST_WIDE_INT)x : -(unsigned HOST_WIDE_INT)x;
+}
+
/* Compute the greatest common divisor of two numbers A and B using
Euclid's algorithm. */
diff --git a/gcc/hwint.h b/gcc/hwint.h
index fa77b112349..c8b3c31bfb7 100644
--- a/gcc/hwint.h
+++ b/gcc/hwint.h
@@ -233,6 +233,7 @@ exact_log2 (unsigned HOST_WIDE_INT x)
#define HOST_WIDE_INT_MAX (~(HOST_WIDE_INT_MIN))
extern HOST_WIDE_INT abs_hwi (HOST_WIDE_INT);
+extern unsigned HOST_WIDE_INT absu_hwi (HOST_WIDE_INT);
extern HOST_WIDE_INT gcd (HOST_WIDE_INT, HOST_WIDE_INT);
extern HOST_WIDE_INT pos_mul_hwi (HOST_WIDE_INT, HOST_WIDE_INT);
extern HOST_WIDE_INT mul_hwi (HOST_WIDE_INT, HOST_WIDE_INT);
diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c
index 82634cce078..c5ad1c4765f 100644
--- a/gcc/tree-ssa-loop-prefetch.c
+++ b/gcc/tree-ssa-loop-prefetch.c
@@ -795,7 +795,7 @@ prune_ref_by_group_reuse (struct mem_ref *ref, struct mem_ref *by,
prefetch_before = (hit_from - delta_r + step - 1) / step;
/* Do not reduce prefetch_before if we meet beyond cache size. */
- if (prefetch_before > (unsigned) abs_hwi (L2_CACHE_SIZE_BYTES / step))
+ if (prefetch_before > absu_hwi (L2_CACHE_SIZE_BYTES / step))
prefetch_before = PREFETCH_ALL;
if (prefetch_before < ref->prefetch_before)
ref->prefetch_before = prefetch_before;
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 63cc175eadd..db4ec44c331 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -1231,7 +1231,7 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *gsi, location_t loc,
/* Attempt to fold powi(arg0, abs(n/2)) into multiplies. If not
possible or profitable, give up. Skip the degenerate case when
n is 1 or -1, where the result is always 1. */
- if (abs_hwi (n) != 1)
+ if (absu_hwi (n) != 1)
{
powi_x_ndiv2 = gimple_expand_builtin_powi (gsi, loc, arg0,
abs_hwi (n / 2));
@@ -1243,7 +1243,7 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *gsi, location_t loc,
result of the optimal multiply sequence just calculated. */
sqrt_arg0 = build_and_insert_call (gsi, loc, &target, sqrtfn, arg0);
- if (abs_hwi (n) == 1)
+ if (absu_hwi (n) == 1)
result = sqrt_arg0;
else
result = build_and_insert_binop (gsi, loc, target, MULT_EXPR,
@@ -1285,7 +1285,7 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *gsi, location_t loc,
/* Attempt to fold powi(arg0, abs(n/3)) into multiplies. If not
possible or profitable, give up. Skip the degenerate case when
abs(n) < 3, where the result is always 1. */
- if (abs_hwi (n) >= 3)
+ if (absu_hwi (n) >= 3)
{
powi_x_ndiv3 = gimple_expand_builtin_powi (gsi, loc, arg0,
abs_hwi (n / 3));
@@ -1298,14 +1298,14 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *gsi, location_t loc,
either cbrt(x) or cbrt(x) * cbrt(x). */
cbrt_x = build_and_insert_call (gsi, loc, &target, cbrtfn, arg0);
- if (abs_hwi (n) % 3 == 1)
+ if (absu_hwi (n) % 3 == 1)
powi_cbrt_x = cbrt_x;
else
powi_cbrt_x = build_and_insert_binop (gsi, loc, target, MULT_EXPR,
cbrt_x, cbrt_x);
/* Multiply the two subexpressions, unless powi(x,abs(n)/3) = 1. */
- if (abs_hwi (n) < 3)
+ if (absu_hwi (n) < 3)
result = powi_cbrt_x;
else
result = build_and_insert_binop (gsi, loc, target, MULT_EXPR,