summaryrefslogtreecommitdiff
path: root/gcc/tree-eh.c
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-11 18:14:48 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-11 18:14:48 +0000
commitdb97ad4157917ee22e26683eac93acea1f2b8cea (patch)
tree8ae61f65db968c0c276e91209918fc11f50b63e4 /gcc/tree-eh.c
parent504d3463155888e30ae12775390b578c7723a827 (diff)
downloadgcc-db97ad4157917ee22e26683eac93acea1f2b8cea.tar.gz
* builtins.c (fold_builtin_fputs): Don't bother converting the
return type to integer_type_node, as we've already checked that the result will be ignored. * tree-eh.c (tree_could_trap_p): Add support for -ftrapv such that signed addition, subtraction, multiplication, division, remainder, negation and absolute value may potentially trap. * fold-const.c (fold_ignored_result): New function to strip non-side-effecting tree nodes from an expression whose result is ignored. (fold_convert): Call fold_ignored_result when casting a value to VOID_TYPE. (omit_one_operand): Call fold_ignored_result on the "omitted" operand when building a COMPOUND_EXPR. (pedantic_omit_one_operand): Likewise. * tree.h (fold_ignored_result): Prototype here. * tree-ssa-ccp.c (ccp_fold_builtin): Call fold_ignored_result when we're going to ignore the result. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84525 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-eh.c')
-rw-r--r--gcc/tree-eh.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 8ff1bfa55b7..b0638c00108 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -1705,6 +1705,7 @@ tree_could_trap_p (tree expr)
bool honor_nans = false;
bool honor_snans = false;
bool fp_operation = false;
+ bool honor_trapv = false;
tree t, base, idx;
if (TREE_CODE_CLASS (code) == '<'
@@ -1718,6 +1719,8 @@ tree_could_trap_p (tree expr)
honor_nans = flag_trapping_math && !flag_finite_math_only;
honor_snans = flag_signaling_nans != 0;
}
+ else if (INTEGRAL_TYPE_P (t) && TYPE_TRAP_SIGNED (t))
+ honor_trapv = true;
}
switch (code)
@@ -1765,7 +1768,7 @@ tree_could_trap_p (tree expr)
case ROUND_MOD_EXPR:
case TRUNC_MOD_EXPR:
case RDIV_EXPR:
- if (honor_snans)
+ if (honor_snans || honor_trapv)
return true;
if (fp_operation && flag_trapping_math)
return true;
@@ -1804,7 +1807,19 @@ tree_could_trap_p (tree expr)
case NEGATE_EXPR:
case ABS_EXPR:
case CONJ_EXPR:
- /* These operations don't trap even with floating point. */
+ /* These operations don't trap with floating point. */
+ if (honor_trapv)
+ return true;
+ return false;
+
+ case PLUS_EXPR:
+ case MINUS_EXPR:
+ case MULT_EXPR:
+ /* Any floating arithmetic may trap. */
+ if (fp_operation && flag_trapping_math)
+ return true;
+ if (honor_trapv)
+ return true;
return false;
default: