diff options
author | Roger Sayle <roger@eyesopen.com> | 2004-12-12 22:33:00 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2004-12-12 22:33:00 +0000 |
commit | eeae0768ac4bd7bccefe58bc07f346cedf0d4e7d (patch) | |
tree | 294ffedba611547c46c5786e5e3325797cbf6763 | |
parent | d9f235fcf81e7dc146af573e603e6a2b5959c4a2 (diff) | |
download | gcc-eeae0768ac4bd7bccefe58bc07f346cedf0d4e7d.zip gcc-eeae0768ac4bd7bccefe58bc07f346cedf0d4e7d.tar.gz gcc-eeae0768ac4bd7bccefe58bc07f346cedf0d4e7d.tar.bz2 |
re PR middle-end/12454 (large number of if ();else if cause)
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.
From-SVN: r92067
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/cp-gimplify.c | 10 |
2 files changed, 14 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1abbc26..55b467c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 1d10b58..4f38739 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -85,9 +85,10 @@ genericize_eh_spec_block (tree *stmt_p) 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); @@ -96,7 +97,12 @@ gimplify_if_stmt (tree *stmt_p) 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; } |