diff options
author | Richard Guenther <rguenther@suse.de> | 2012-04-13 12:22:16 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2012-04-13 12:22:16 +0000 |
commit | 95df37bf8bded356f45539ecaa8bff3078d9cf86 (patch) | |
tree | a1b22ec581d09f617460923d197f29eb753d4509 /gcc/tree-if-conv.c | |
parent | d0bcb5c33fec86bb2f2beac24c112f1fd0e96cda (diff) | |
download | gcc-95df37bf8bded356f45539ecaa8bff3078d9cf86.zip gcc-95df37bf8bded356f45539ecaa8bff3078d9cf86.tar.gz gcc-95df37bf8bded356f45539ecaa8bff3078d9cf86.tar.bz2 |
re PR tree-optimization/52969 (ICE in in get_expr_operands, at tree-ssa-operands.c:1035 with -ftree-loop-if-convert-stores)
2012-04-13 Richard Guenther <rguenther@suse.de>
PR tree-optimization/52969
* tree-if-conv.c (predicate_mem_writes): Properly gimplify
the condition for the COND_EXPR and handle predicate negation
by swapping the COND_EXPR arms.
* gcc.dg/torture/pr52969.c: New testcase.
From-SVN: r186416
Diffstat (limited to 'gcc/tree-if-conv.c')
-rw-r--r-- | gcc/tree-if-conv.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index 55616d5..c86a4aa5 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -1543,11 +1543,19 @@ predicate_mem_writes (loop_p loop) gimple_stmt_iterator gsi; basic_block bb = ifc_bbs[i]; tree cond = bb_predicate (bb); + bool swap; gimple stmt; if (is_true_predicate (cond)) continue; + swap = false; + if (TREE_CODE (cond) == TRUTH_NOT_EXPR) + { + swap = true; + cond = TREE_OPERAND (cond, 0); + } + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) if ((stmt = gsi_stmt (gsi)) && gimple_assign_single_p (stmt) @@ -1559,6 +1567,15 @@ predicate_mem_writes (loop_p loop) lhs = ifc_temp_var (type, unshare_expr (lhs), &gsi); rhs = ifc_temp_var (type, unshare_expr (rhs), &gsi); + if (swap) + { + tree tem = lhs; + lhs = rhs; + rhs = tem; + } + cond = force_gimple_operand_gsi_1 (&gsi, unshare_expr (cond), + is_gimple_condexpr, NULL_TREE, + true, GSI_SAME_STMT); rhs = build3 (COND_EXPR, type, unshare_expr (cond), rhs, lhs); gimple_assign_set_rhs1 (stmt, ifc_temp_var (type, rhs, &gsi)); update_stmt (stmt); |