This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: Fix tree-optimization/20612
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 02 Apr 2005 13:05:35 -0500
- Subject: [PATCH]: Fix tree-optimization/20612
Simple changes.
The increment statement we want to use isn't always dominating the place
we want to use it.
Also, we were setting the loop wrong for one of the bb's.
Bootstrapped and regtested on i686-pc-linux-gnu, and powerpc-linux-gnu
Okay for mainline?
2005-04-02 Daniel Berlin <dberlin@dberlin.org>
Fix PR tree-optimization/20612
* lambda-code.c (lambda_loopnest_to_gcc_loopnest): Fix increment
handling
(perfect_nestify): preheaderbb is *not* part of loop of the
old destination.
Index: lambda-code.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/lambda-code.c,v
retrieving revision 2.30
diff -u -p -r2.30 lambda-code.c
--- lambda-code.c 13 Mar 2005 15:54:15 -0000 2.30
+++ lambda-code.c 25 Mar 2005 14:48:45 -0000
@@ -1874,6 +1874,7 @@ lambda_loopnest_to_gcc_loopnest (struct
lambda_linear_expression offset;
tree type;
bool insert_after;
+ tree inc_stmt;
oldiv = VEC_index (tree, old_ivs, i);
type = TREE_TYPE (oldiv);
@@ -1922,7 +1923,20 @@ lambda_loopnest_to_gcc_loopnest (struct
create_iv (newlowerbound,
build_int_cst (type, LL_STEP (newloop)),
ivvar, temp, &bsi, insert_after, &ivvar,
- &ivvarinced);
+ NULL);
+
+ /* Unfortunately, the incremented ivvar that create_iv inserted may not
+ dominate the block containing the exit condition.
+ So we simply create our own incremented iv to use in the new exit
+ test, and let redundancy elimination sort it out. */
+ inc_stmt = build (PLUS_EXPR, type,
+ ivvar, build_int_cst (type, LL_STEP (newloop)));
+ inc_stmt = build (MODIFY_EXPR, void_type_node, SSA_NAME_VAR (ivvar),
+ inc_stmt);
+ ivvarinced = make_ssa_name (SSA_NAME_VAR (ivvar), inc_stmt);
+ TREE_OPERAND (inc_stmt, 0) = ivvarinced;
+ bsi = bsi_for_stmt (exitcond);
+ bsi_insert_before (&bsi, inc_stmt, BSI_SAME_STMT);
/* Replace the exit condition with the new upper bound
comparison. */
@@ -2366,7 +2380,6 @@ perfect_nestify (struct loops *loops,
add_bb_to_loop (latchbb, newloop);
add_bb_to_loop (bodybb, newloop);
add_bb_to_loop (headerbb, newloop);
- add_bb_to_loop (preheaderbb, olddest->loop_father);
set_immediate_dominator (CDI_DOMINATORS, bodybb, headerbb);
set_immediate_dominator (CDI_DOMINATORS, headerbb, preheaderbb);
set_immediate_dominator (CDI_DOMINATORS, preheaderbb,