diff options
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index dda3102..ed98822 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -5275,8 +5275,16 @@ fold (expr) { if (TREE_CODE (arg0) == INTEGER_CST) { - if (! TREE_UNSIGNED (type) - && TREE_INT_CST_HIGH (arg0) < 0) + /* If the value is unsigned, then the absolute value is + the same as the ordinary value. */ + if (TREE_UNSIGNED (type)) + return arg0; + /* Similarly, if the value is non-negative. */ + else if (INT_CST_LT (integer_minus_one_node, arg0)) + return arg0; + /* If the value is negative, then the absolute value is + its negation. */ + else { unsigned HOST_WIDE_INT low; HOST_WIDE_INT high; |