diff options
author | Jakub Jelinek <jakub@redhat.com> | 2008-09-08 23:30:23 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2008-09-08 23:30:23 +0200 |
commit | 7f4b6d207c7b950f54cf32b06b2835e960ba8c77 (patch) | |
tree | c73044cbbaa13e7957e4b102844ffd851a3c9f04 /gcc | |
parent | 99b96649c17e6a2f9b5e1427603d164ad752c15b (diff) | |
download | gcc-7f4b6d207c7b950f54cf32b06b2835e960ba8c77.zip gcc-7f4b6d207c7b950f54cf32b06b2835e960ba8c77.tar.gz gcc-7f4b6d207c7b950f54cf32b06b2835e960ba8c77.tar.bz2 |
re PR middle-end/37414 (ICE with -ffast-math)
PR middle-end/37414
* predict.c (optimize_function_for_size_p): Don't segfault if
FUN is NULL.
* fold-const.c (LOGICAL_OP_NON_SHORT_CIRCUIT, fold_truthop,
tree_swap_operands_p): Don't test cfun != NULL before calling
optimize_function_for_s*_p.
* g++.dg/opt/init2.C: New test.
From-SVN: r140122
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/fold-const.c | 6 | ||||
-rw-r--r-- | gcc/predict.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/opt/init2.C | 6 |
5 files changed, 23 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2242afc..60ff6e9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2008-09-08 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/37414 + * predict.c (optimize_function_for_size_p): Don't segfault if + FUN is NULL. + * fold-const.c (LOGICAL_OP_NON_SHORT_CIRCUIT, fold_truthop, + tree_swap_operands_p): Don't test cfun != NULL before calling + optimize_function_for_s*_p. + 2008-09-08 Eric Botcazou <ebotcazou@adacore.com> * ira-color.c (ira_reuse_stack_slot): Set slot_num on success at the diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 7c4c522..aea7a65 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -5110,7 +5110,7 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) #ifndef LOGICAL_OP_NON_SHORT_CIRCUIT #define LOGICAL_OP_NON_SHORT_CIRCUIT \ - (BRANCH_COST (!cfun || optimize_function_for_speed_p (cfun), \ + (BRANCH_COST (optimize_function_for_speed_p (cfun), \ false) >= 2) #endif @@ -5359,7 +5359,7 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) that can be merged. Avoid doing this if the RHS is a floating-point comparison since those can trap. */ - if (BRANCH_COST (!cfun || optimize_function_for_speed_p (cfun), + if (BRANCH_COST (optimize_function_for_speed_p (cfun), false) >= 2 && ! FLOAT_TYPE_P (TREE_TYPE (rl_arg)) && simple_operand_p (rl_arg) @@ -6682,7 +6682,7 @@ tree_swap_operands_p (const_tree arg0, const_tree arg1, bool reorder) if (TREE_CONSTANT (arg0)) return 1; - if (cfun && optimize_function_for_size_p (cfun)) + if (optimize_function_for_size_p (cfun)) return 0; if (reorder && flag_evaluation_order diff --git a/gcc/predict.c b/gcc/predict.c index b69934f..5ed6c43 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -203,7 +203,8 @@ bool optimize_function_for_size_p (struct function *fun) { return (optimize_size - || fun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED); + || (fun && (fun->function_frequency + == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED))); } /* Return true when current function should always be optimized for speed. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dc19015..f5aec00 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2008-09-08 Jakub Jelinek <jakub@redhat.com> + PR middle-end/37414 + * g++.dg/opt/init2.C: New test. + PR middle-end/37337 * g++.dg/tree-ssa/pr37337.C: New test. diff --git a/gcc/testsuite/g++.dg/opt/init2.C b/gcc/testsuite/g++.dg/opt/init2.C new file mode 100644 index 0000000..3c3bc93 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/init2.C @@ -0,0 +1,6 @@ +// PR middle-end/37414 +// { dg-do compile } +// { dg-options "-O2 -ffast-math" } + +double x = 6.0; +double y = x * x; |