+2004-12-12 Roger Sayle <roger@eyesopen.com>
+
+ PR middle-end/12454
+ * cp-gimplify.c (gimplify_if_stmt): Optimize the case where the
+ condition is a constant and the unexecuted clause is empty.
+
2004-12-10 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/18731
static void
gimplify_if_stmt (tree *stmt_p)
{
- tree stmt, then_, else_;
+ tree stmt, cond, then_, else_;
stmt = *stmt_p;
+ cond = IF_COND (stmt);
then_ = THEN_CLAUSE (stmt);
else_ = ELSE_CLAUSE (stmt);
if (!else_)
else_ = build_empty_stmt ();
- stmt = build3 (COND_EXPR, void_type_node, IF_COND (stmt), then_, else_);
+ if (integer_nonzerop (cond) && !TREE_SIDE_EFFECTS (else_))
+ stmt = then_;
+ else if (integer_zerop (cond) && !TREE_SIDE_EFFECTS (then_))
+ stmt = else_;
+ else
+ stmt = build3 (COND_EXPR, void_type_node, cond, then_, else_);
*stmt_p = stmt;
}