[tuples] Avoid label_cont and jump to it if THEN sequence doesn't falltru
Jakub Jelinek
jakub@redhat.com
Fri Jul 18 13:08:00 GMT 2008
Hi!
This patch fixes
FAIL: g++.dg/warn/Wreturn-type-2.C (test for excess errors)
by omitting unnecessary goto which confuses fallthru detection. The
difference is e.g.:
if (x != y) goto <D.1> else goto <D.2>;
<D.1>:
...
return;
- goto <D.3>;
<D.2>:
...
return;
- <D.3>:
whenever the THEN sequence can't fallthru and the else sequence is
not empty (and isn't a simple goto which has been put already into
the GIMPLE_COND).
Bootstrapped/regtested on x86_64-linux, will commit momentarily.
2008-07-18 Jakub Jelinek <jakub@redhat.com>
* gimplify.c (gimplify_cond_expr): If COND_EXPR has both non-trivial
THEN and ELSE statements and the THEN sequence can't fallthru, avoid
adding label_cont and jump to it.
--- gcc/gimplify.c.jj 2008-07-17 18:10:18.000000000 +0200
+++ gcc/gimplify.c 2008-07-18 10:39:38.000000000 +0200
@@ -2988,9 +2988,12 @@ gimplify_cond_expr (tree *expr_p, gimple
gimplify_seq_add_stmt (&seq, gimple_build_label (label_true));
have_then_clause_p = gimplify_stmt (&TREE_OPERAND (expr, 1), &seq);
/* For if (...) { code; } else {} or
- if (...) { code; } else goto label;
+ if (...) { code; } else goto label; or
+ if (...) { code; return; } else { ... }
label_cont isn't needed. */
- if (!have_else_clause_p && TREE_OPERAND (expr, 2) != NULL_TREE)
+ if (!have_else_clause_p
+ && TREE_OPERAND (expr, 2) != NULL_TREE
+ && gimple_seq_may_fallthru (seq))
{
label_cont = create_artificial_label ();
gimplify_seq_add_stmt (&seq, gimple_build_goto (label_cont));
Jakub
More information about the Gcc-patches
mailing list