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
This commit is contained in:
Jakub Jelinek 2008-09-08 23:30:23 +02:00 committed by Jakub Jelinek
parent 99b96649c1
commit 7f4b6d207c
5 changed files with 23 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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. */

View File

@ -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.

View File

@ -0,0 +1,6 @@
// PR middle-end/37414
// { dg-do compile }
// { dg-options "-O2 -ffast-math" }
double x = 6.0;
double y = x * x;