diff options
author | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-01-23 15:57:19 +0000 |
---|---|---|
committer | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-01-23 15:57:19 +0000 |
commit | cd30b839ee28c3631afbdbb1936b95cfc26ecfa3 (patch) | |
tree | aacb078bea4cd0815736d26fb8837d2a3a40112b /gcc/fold-const.c | |
parent | 54bc2b19cdad2b02c7ebbd46c98e1770f682b8fa (diff) | |
download | gcc-cd30b839ee28c3631afbdbb1936b95cfc26ecfa3.tar.gz |
2008-01-23 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/38932
* fold-const.c (fold_unary_no_overflow): New.
* tree.h (fold_unary_no_overflow): Declare.
* tree-ssa-ccp.c (ccp_fold): Use fold_unary_no_overflow.
* tree-ssa-sccvn.c (visit_reference_op_load,
simplify_unary_expression): Likewise.
testsuite:
2008-01-23 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/38932
* gcc.dg/pr38932.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143588 138bc75d-0d04-0410-961f-82ee72b054a4
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 eb7d7c91210..da4d50d5e94 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, |