From c817ff638d06871d090753c47f0a960a70df47f2 Mon Sep 17 00:00:00 2001 From: "David E. O'Brien" Date: Tue, 11 Dec 2007 03:35:39 +0000 Subject: [PATCH] Do not fold -C*ABS to ABS<-C*n> (i.e., do not move negative constants inside ABS expression). Obtained from: Richard Guenther Approved by: core --- contrib/gcc/fold-const.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/gcc/fold-const.c b/contrib/gcc/fold-const.c index 5db1d843e4f0..ea16eae741b7 100644 --- a/contrib/gcc/fold-const.c +++ b/contrib/gcc/fold-const.c @@ -5661,6 +5661,9 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type, } break; } + /* If the constant is negative, we cannot simplify this. */ + if (tree_int_cst_sgn (c) == -1) + break; /* FALLTHROUGH */ case NEGATE_EXPR: if ((t1 = extract_muldiv (op0, c, code, wide_type, strict_overflow_p))