* trans-stmt.c (gfc_trans_if_1): Use fold_buildN and build_int_cst.
(gfc_trans_arithmetic_if): Likewise.
(gfc_trans_simple_do): Likewise.
(gfc_trans_do): Likewise.
(gfc_trans_do_while): Likewise.
(gfc_trans_logical_select): Likewise.
(gfc_trans_forall_loop): Likewise.
(generate_loop_for_temp_to_lhs): Likewise.
(generate_loop_for_rhs_to_temp): Likewise.
(gfc_trans_allocate): Likewise.
* trans.c (gfc_add_expr_to_block): Do not fold expr again.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109756
138bc75d-0d04-0410-961f-
82ee72b054a4
2006-01-16 Richard Guenther <rguenther@suse.de>
2006-01-16 Richard Guenther <rguenther@suse.de>
+ * trans-stmt.c (gfc_trans_if_1): Use fold_buildN and build_int_cst.
+ (gfc_trans_arithmetic_if): Likewise.
+ (gfc_trans_simple_do): Likewise.
+ (gfc_trans_do): Likewise.
+ (gfc_trans_do_while): Likewise.
+ (gfc_trans_logical_select): Likewise.
+ (gfc_trans_forall_loop): Likewise.
+ (generate_loop_for_temp_to_lhs): Likewise.
+ (generate_loop_for_rhs_to_temp): Likewise.
+ (gfc_trans_allocate): Likewise.
+ * trans.c (gfc_add_expr_to_block): Do not fold expr again.
+
+2006-01-16 Richard Guenther <rguenther@suse.de>
+
* trans-expr.c (gfc_conv_function_call): Use fold_build2.
* trans-stmt.c (gfc_trans_goto): Likewise. Use build_int_cst.
* trans.c (gfc_trans_runtime_check): Don't fold the condition
* trans-expr.c (gfc_conv_function_call): Use fold_build2.
* trans-stmt.c (gfc_trans_goto): Likewise. Use build_int_cst.
* trans.c (gfc_trans_runtime_check): Don't fold the condition
elsestmt = build_empty_stmt ();
/* Build the condition expression and add it to the condition block. */
elsestmt = build_empty_stmt ();
/* Build the condition expression and add it to the condition block. */
- stmt = build3_v (COND_EXPR, if_se.expr, stmt, elsestmt);
+ stmt = fold_build3 (COND_EXPR, void_type_node, if_se.expr, stmt, elsestmt);
gfc_add_expr_to_block (&if_se.pre, stmt);
gfc_add_expr_to_block (&if_se.pre, stmt);
branch2 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label2));
if (code->label->value != code->label3->value)
branch2 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label2));
if (code->label->value != code->label3->value)
- tmp = build2 (LT_EXPR, boolean_type_node, se.expr, zero);
+ tmp = fold_build2 (LT_EXPR, boolean_type_node, se.expr, zero);
- tmp = build2 (NE_EXPR, boolean_type_node, se.expr, zero);
+ tmp = fold_build2 (NE_EXPR, boolean_type_node, se.expr, zero);
- branch1 = build3_v (COND_EXPR, tmp, branch1, branch2);
+ branch1 = fold_build3 (COND_EXPR, void_type_node, tmp, branch1, branch2);
}
else
branch1 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label));
}
else
branch1 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label));
{
/* if (cond <= 0) take branch1 else take branch2. */
branch2 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label3));
{
/* if (cond <= 0) take branch1 else take branch2. */
branch2 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label3));
- tmp = build2 (LE_EXPR, boolean_type_node, se.expr, zero);
- branch1 = build3_v (COND_EXPR, tmp, branch1, branch2);
+ tmp = fold_build2 (LE_EXPR, boolean_type_node, se.expr, zero);
+ branch1 = fold_build3 (COND_EXPR, void_type_node, tmp, branch1, branch2);
}
/* Append the COND_EXPR to the evaluation of COND, and return. */
}
/* Append the COND_EXPR to the evaluation of COND, and return. */
}
/* Evaluate the loop condition. */
}
/* Evaluate the loop condition. */
- cond = build2 (EQ_EXPR, boolean_type_node, dovar, to);
+ cond = fold_build2 (EQ_EXPR, boolean_type_node, dovar, to);
cond = gfc_evaluate_now (cond, &body);
/* Increment the loop variable. */
cond = gfc_evaluate_now (cond, &body);
/* Increment the loop variable. */
- tmp = build2 (PLUS_EXPR, type, dovar, step);
+ tmp = fold_build2 (PLUS_EXPR, type, dovar, step);
gfc_add_modify_expr (&body, dovar, tmp);
/* The loop exit. */
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
gfc_add_modify_expr (&body, dovar, tmp);
/* The loop exit. */
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = fold_build3 (COND_EXPR, void_type_node,
+ cond, tmp, build_empty_stmt ());
gfc_add_expr_to_block (&body, tmp);
/* Finish the loop body. */
gfc_add_expr_to_block (&body, tmp);
/* Finish the loop body. */
cond = fold_build2 (LE_EXPR, boolean_type_node, dovar, to);
else
cond = fold_build2 (GE_EXPR, boolean_type_node, dovar, to);
cond = fold_build2 (LE_EXPR, boolean_type_node, dovar, to);
else
cond = fold_build2 (GE_EXPR, boolean_type_node, dovar, to);
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = fold_build3 (COND_EXPR, void_type_node,
+ cond, tmp, build_empty_stmt ());
gfc_add_expr_to_block (pblock, tmp);
/* Add the exit label. */
gfc_add_expr_to_block (pblock, tmp);
/* Add the exit label. */
exit_label = gfc_build_label_decl (NULL_TREE);
/* Start with the loop condition. Loop until count <= 0. */
exit_label = gfc_build_label_decl (NULL_TREE);
/* Start with the loop condition. Loop until count <= 0. */
- cond = build2 (LE_EXPR, boolean_type_node, count,
- convert (TREE_TYPE (count), integer_zero_node));
+ cond = fold_build2 (LE_EXPR, boolean_type_node, count,
+ build_int_cst (TREE_TYPE (count), 0));
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = fold_build3 (COND_EXPR, void_type_node,
+ cond, tmp, build_empty_stmt ());
gfc_add_expr_to_block (&body, tmp);
/* Put these labels where they can be found later. We put the
gfc_add_expr_to_block (&body, tmp);
/* Put these labels where they can be found later. We put the
/* Build "IF (! cond) GOTO exit_label". */
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
/* Build "IF (! cond) GOTO exit_label". */
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
- tmp = build3_v (COND_EXPR, cond.expr, tmp, build_empty_stmt ());
+ tmp = fold_build3 (COND_EXPR, void_type_node,
+ cond.expr, tmp, build_empty_stmt ());
gfc_add_expr_to_block (&block, tmp);
/* The main body of the loop. */
gfc_add_expr_to_block (&block, tmp);
/* The main body of the loop. */
- tree true_tree, false_tree;
+ tree true_tree, false_tree, stmt;
true_tree = build_empty_stmt ();
false_tree = build_empty_stmt ();
true_tree = build_empty_stmt ();
false_tree = build_empty_stmt ();
if (f != NULL)
false_tree = gfc_trans_code (f->next);
if (f != NULL)
false_tree = gfc_trans_code (f->next);
- gfc_add_expr_to_block (&block, build3_v (COND_EXPR, se.expr,
- true_tree, false_tree));
+ stmt = fold_build3 (COND_EXPR, void_type_node, se.expr,
+ true_tree, false_tree);
+ gfc_add_expr_to_block (&block, stmt);
}
return gfc_finish_block (&block);
}
return gfc_finish_block (&block);
gfc_init_block (&block);
/* The exit condition. */
gfc_init_block (&block);
/* The exit condition. */
- cond = build2 (LE_EXPR, boolean_type_node, count, integer_zero_node);
+ cond = fold_build2 (LE_EXPR, boolean_type_node,
+ count, build_int_cst (TREE_TYPE (count), 0));
tmp = build1_v (GOTO_EXPR, exit_label);
tmp = build1_v (GOTO_EXPR, exit_label);
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = fold_build3 (COND_EXPR, void_type_node,
+ cond, tmp, build_empty_stmt ());
gfc_add_expr_to_block (&block, tmp);
/* The main loop body. */
gfc_add_expr_to_block (&block, tmp);
/* The main loop body. */
while (tmp2)
{
tmp1 = gfc_build_array_ref (tmp2, count3);
while (tmp2)
{
tmp1 = gfc_build_array_ref (tmp2, count3);
- wheremaskexpr = build2 (TRUTH_AND_EXPR, TREE_TYPE (tmp1),
- wheremaskexpr, tmp1);
+ wheremaskexpr = fold_build2 (TRUTH_AND_EXPR, TREE_TYPE (tmp1),
+ wheremaskexpr, tmp1);
tmp2 = TREE_CHAIN (tmp2);
}
tmp2 = TREE_CHAIN (tmp2);
}
- tmp = build3_v (COND_EXPR, wheremaskexpr, tmp, build_empty_stmt ());
+ tmp = fold_build3 (COND_EXPR, void_type_node,
+ wheremaskexpr, tmp, build_empty_stmt ());
}
gfc_add_expr_to_block (&body, tmp);
}
gfc_add_expr_to_block (&body, tmp);
while (tmp2)
{
tmp1 = gfc_build_array_ref (tmp2, count3);
while (tmp2)
{
tmp1 = gfc_build_array_ref (tmp2, count3);
- wheremaskexpr = build2 (TRUTH_AND_EXPR, TREE_TYPE (tmp1),
- wheremaskexpr, tmp1);
+ wheremaskexpr = fold_build2 (TRUTH_AND_EXPR, TREE_TYPE (tmp1),
+ wheremaskexpr, tmp1);
tmp2 = TREE_CHAIN (tmp2);
}
tmp2 = TREE_CHAIN (tmp2);
}
- tmp = build3_v (COND_EXPR, wheremaskexpr, tmp, build_empty_stmt ());
+ tmp = fold_build3 (COND_EXPR, void_type_node,
+ wheremaskexpr, tmp, build_empty_stmt ());
}
gfc_add_expr_to_block (&body1, tmp);
}
gfc_add_expr_to_block (&body1, tmp);
if (code->expr)
{
tmp = build1_v (GOTO_EXPR, error_label);
if (code->expr)
{
tmp = build1_v (GOTO_EXPR, error_label);
- parm =
- build2 (NE_EXPR, boolean_type_node, stat, integer_zero_node);
- tmp = build3_v (COND_EXPR, parm, tmp, build_empty_stmt ());
+ parm = fold_build2 (NE_EXPR, boolean_type_node,
+ stat, build_int_cst (TREE_TYPE (stat), 0));
+ tmp = fold_build3 (COND_EXPR, void_type_node,
+ parm, tmp, build_empty_stmt ());
gfc_add_expr_to_block (&se.pre, tmp);
}
}
gfc_add_expr_to_block (&se.pre, tmp);
}
}
if (expr == NULL_TREE || IS_EMPTY_STMT (expr))
return;
if (expr == NULL_TREE || IS_EMPTY_STMT (expr))
return;
- if (TREE_CODE (expr) != STATEMENT_LIST
- && TREE_CODE_CLASS (TREE_CODE (expr)) != tcc_statement)
- expr = fold (expr);
-
if (block->head)
{
if (TREE_CODE (block->head) != STATEMENT_LIST)
if (block->head)
{
if (TREE_CODE (block->head) != STATEMENT_LIST)