You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
-#include "errors.h"
#include "ggc.h"
#include "tree.h"
#include "rtl.h"
|| (e1->flags & EDGE_FALLTHRU) == 0)
continue;
- /* Also make that bb1 only have one pred and it is bb. */
+ /* Also make sure that bb1 only have one predecessor and that it
+ is bb. */
if (!single_pred_p (bb1)
|| single_pred (bb1) != bb)
continue;
arg0 = PHI_ARG_DEF_TREE (phi, e1->dest_idx);
arg1 = PHI_ARG_DEF_TREE (phi, e2->dest_idx);
- /* We know something is wrong if we cannot find the edges in the PHI
+ /* Something is wrong if we cannot find the arguments in the PHI
node. */
gcc_assert (arg0 != NULL && arg1 != NULL);
{
EDGE_SUCC (cond_block, 0)->flags |= EDGE_FALLTHRU;
EDGE_SUCC (cond_block, 0)->flags &= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
+ EDGE_SUCC (cond_block, 0)->probability = REG_BR_PROB_BASE;
+ EDGE_SUCC (cond_block, 0)->count += EDGE_SUCC (cond_block, 1)->count;
block_to_remove = EDGE_SUCC (cond_block, 1)->dest;
}
EDGE_SUCC (cond_block, 1)->flags |= EDGE_FALLTHRU;
EDGE_SUCC (cond_block, 1)->flags
&= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
+ EDGE_SUCC (cond_block, 1)->probability = REG_BR_PROB_BASE;
+ EDGE_SUCC (cond_block, 1)->count += EDGE_SUCC (cond_block, 0)->count;
block_to_remove = EDGE_SUCC (cond_block, 0)->dest;
}
if (TREE_CODE (cond) != SSA_NAME
&& !lang_hooks.types_compatible_p (TREE_TYPE (cond), TREE_TYPE (result)))
{
- new_var = make_rename_temp (TREE_TYPE (cond), NULL);
+ tree tmp;
+
+ if (!COMPARISON_CLASS_P (cond))
+ return false;
+
+ tmp = create_tmp_var (TREE_TYPE (cond), NULL);
+ add_referenced_tmp_var (tmp);
+ new_var = make_ssa_name (tmp, NULL);
old_result = cond;
cond = new_var;
}
if (old_result)
{
tree new1;
- if (!COMPARISON_CLASS_P (old_result))
- return false;
new1 = build2 (TREE_CODE (old_result), TREE_TYPE (old_result),
TREE_OPERAND (old_result, 0),
TREE_OPERAND (old_result, 1));
new1 = build2 (MODIFY_EXPR, TREE_TYPE (old_result), new_var, new1);
+ SSA_NAME_DEF_STMT (new_var) = new1;
+
bsi_insert_after (&bsi, new1, BSI_NEW_STMT);
}
tree cond1 = invert_truthvalue (cond);
cond = cond1;
+
/* If what we get back is a conditional expression, there is no
way that it can be gimple. */
if (TREE_CODE (cond) == COND_EXPR)
return false;
}
+ /* If COND is not something we can expect to be reducible to a GIMPLE
+ condition, return early. */
+ if (is_gimple_cast (cond))
+ cond1 = TREE_OPERAND (cond, 0);
+ if (TREE_CODE (cond1) == TRUTH_NOT_EXPR
+ && !is_gimple_val (TREE_OPERAND (cond1, 0)))
+ {
+ release_ssa_name (new_var1);
+ return false;
+ }
+
/* If what we get back is not gimple try to create it as gimple by
using a temporary variable. */
if (is_gimple_cast (cond)
&& !is_gimple_val (TREE_OPERAND (cond, 0)))
{
- tree temp = TREE_OPERAND (cond, 0);
- tree new_var_1 = make_rename_temp (TREE_TYPE (temp), NULL);
- new = build2 (MODIFY_EXPR, TREE_TYPE (new_var_1), new_var_1, temp);
- bsi_insert_after (&bsi, new, BSI_NEW_STMT);
- cond = fold_convert (TREE_TYPE (result), new_var_1);
- }
+ tree op0, tmp, cond_tmp;
- if (TREE_CODE (cond) == TRUTH_NOT_EXPR
- && !is_gimple_val (TREE_OPERAND (cond, 0)))
- {
- release_ssa_name (new_var1);
- return false;
+ /* Only "real" casts are OK here, not everything that is
+ acceptable to is_gimple_cast. Make sure we don't do
+ anything stupid here. */
+ gcc_assert (TREE_CODE (cond) == NOP_EXPR
+ || TREE_CODE (cond) == CONVERT_EXPR);
+
+ op0 = TREE_OPERAND (cond, 0);
+ tmp = create_tmp_var (TREE_TYPE (op0), NULL);
+ add_referenced_tmp_var (tmp);
+ cond_tmp = make_ssa_name (tmp, NULL);
+ new = build2 (MODIFY_EXPR, TREE_TYPE (cond_tmp), cond_tmp, op0);
+ SSA_NAME_DEF_STMT (cond_tmp) = new;
+
+ bsi_insert_after (&bsi, new, BSI_NEW_STMT);
+ cond = fold_convert (TREE_TYPE (result), cond_tmp);
}
new = build2 (MODIFY_EXPR, TREE_TYPE (new_var1), new_var1, cond);
return false;
/* We need BOUND <= LARGER. */
- if (!integer_nonzerop (fold (build2 (LE_EXPR, boolean_type_node,
- bound, larger))))
+ if (!integer_nonzerop (fold_build2 (LE_EXPR, boolean_type_node,
+ bound, larger)))
return false;
}
else if (operand_equal_for_phi_arg_p (arg_false, smaller))
return false;
/* We need BOUND >= SMALLER. */
- if (!integer_nonzerop (fold (build2 (GE_EXPR, boolean_type_node,
- bound, smaller))))
+ if (!integer_nonzerop (fold_build2 (GE_EXPR, boolean_type_node,
+ bound, smaller)))
return false;
}
else
return false;
/* We need BOUND >= LARGER. */
- if (!integer_nonzerop (fold (build2 (GE_EXPR, boolean_type_node,
- bound, larger))))
+ if (!integer_nonzerop (fold_build2 (GE_EXPR, boolean_type_node,
+ bound, larger)))
return false;
}
else if (operand_equal_for_phi_arg_p (arg_true, smaller))
return false;
/* We need BOUND <= SMALLER. */
- if (!integer_nonzerop (fold (build2 (LE_EXPR, boolean_type_node,
- bound, smaller))))
+ if (!integer_nonzerop (fold_build2 (LE_EXPR, boolean_type_node,
+ bound, smaller)))
return false;
}
else
result = duplicate_ssa_name (result, NULL);
if (negate)
- lhs = make_rename_temp (TREE_TYPE (result), NULL);
+ {
+ tree tmp = create_tmp_var (TREE_TYPE (result), NULL);
+ add_referenced_tmp_var (tmp);
+ lhs = make_ssa_name (tmp, NULL);
+ }
else
lhs = result;
/* Build the modify expression with abs expression. */
new = build2 (MODIFY_EXPR, TREE_TYPE (lhs),
lhs, build1 (ABS_EXPR, TREE_TYPE (lhs), rhs));
+ SSA_NAME_DEF_STMT (lhs) = new;
bsi = bsi_last (cond_bb);
bsi_insert_before (&bsi, new, BSI_NEW_STMT);
in the block. */
new = build2 (MODIFY_EXPR, TREE_TYPE (result),
result, build1 (NEGATE_EXPR, TREE_TYPE (lhs), lhs));
+ SSA_NAME_DEF_STMT (result) = new;
bsi_insert_after (&bsi, new, BSI_NEW_STMT);
}
- SSA_NAME_DEF_STMT (result) = new;
replace_phi_edge_with_variable (cond_bb, e1, phi, result);
/* Note that we optimized this PHI. */
| TODO_dump_func
| TODO_ggc_collect
| TODO_verify_ssa
- | TODO_update_ssa
| TODO_verify_flow
| TODO_verify_stmts, /* todo_flags_finish */
0 /* letter */