diff options
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index eb7d7c9..da4d50d 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8628,6 +8628,24 @@ fold_unary (enum tree_code code, tree type, tree op0) } /* switch (code) */ } + +/* If the operation was a conversion do _not_ mark a resulting constant + with TREE_OVERFLOW if the original constant was not. These conversions + have implementation defined behavior and retaining the TREE_OVERFLOW + flag here would confuse later passes such as VRP. */ +tree +fold_unary_ignore_overflow (enum tree_code code, tree type, tree op0) +{ + tree res = fold_unary (code, type, op0); + if (res + && TREE_CODE (res) == INTEGER_CST + && TREE_CODE (op0) == INTEGER_CST + && CONVERT_EXPR_CODE_P (code)) + TREE_OVERFLOW (res) = TREE_OVERFLOW (op0); + + return res; +} + /* Fold a binary expression of code CODE and type TYPE with operands OP0 and OP1, containing either a MIN-MAX or a MAX-MIN combination. Return the folded expression if folding is successful. Otherwise, |