summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-01-29 19:10:25 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-01-29 19:10:25 +0000
commit1b927e1cb81240f4d6c73eb7cdec45246f6a3c72 (patch)
tree56e5cd4a6dc56809fa98da6b09135f74ba2ad785 /gcc/fold-const.c
parent87e27de18fdbc0c21dcbc3108b52cdea8183acad (diff)
downloadgcc-1b927e1cb81240f4d6c73eb7cdec45246f6a3c72.tar.gz
2009-01-29 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk r143767 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@143769 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c18
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,