This is the mail archive of the
mailing list for the GCC project.
[PATCH]: Fix incorrect condition for swapping tree test inlambda-code
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: gcc-patches at gcc dot gnu dot org, dalej at apple dot com
- Date: Tue, 16 Nov 2004 17:24:21 -0500
- Subject: [PATCH]: Fix incorrect condition for swapping tree test inlambda-code
Dale noticed (by example) that we were using the wrong condition for
swapping the tree test type when building the new bounds.
The idea of what it wanted to do (swap the tree test type when the exit
edge meant the opposite of what we wanted) was right, but the
implementation was wrong.
I've updated the comment and the code to be correct..
I'm also working on some runtime verification tests for loop interchange
that are forthcoming to make sure we don't screw this up again in the
Bootstrapped and regtested on i686-pc-linux-gnu.
I'll be committing this as obvious in a few moments.
2004-11-15 Daniel Berlin <email@example.com>
* lambda-code.c (lambda_loopnest_to_gcc_loopnest): Swap
the test when the edge has the opposite meaning, not when
the first argument is invariant.
RCS file: /cvs/gcc/gcc/gcc/lambda-code.c,v
retrieving revision 2.19
diff -u -p -r2.19 lambda-code.c
--- lambda-code.c 13 Nov 2004 21:11:04 -0000 2.19
+++ lambda-code.c 16 Nov 2004 22:16:40 -0000
@@ -1867,6 +1867,7 @@ lambda_loopnest_to_gcc_loopnest (struct
+ edge exit;
tree ivvar, ivvarinced, exitcond, stmts;
enum tree_code testtype;
tree newupperbound, newlowerbound;
@@ -1908,6 +1909,7 @@ lambda_loopnest_to_gcc_loopnest (struct
invariants, MIN_EXPR, &stmts);
+ exit = temp->single_exit;
exitcond = get_loop_exit_condition (temp);
bb = bb_for_stmt (exitcond);
bsi = bsi_start (bb);
@@ -1928,17 +1930,16 @@ lambda_loopnest_to_gcc_loopnest (struct
testtype = LL_STEP (newloop) >= 0 ? LE_EXPR : GE_EXPR;
- /* Since we don't know which cond_expr part currently points to each
- edge, check which one is invariant and make sure we reverse the
- comparison if we are trying to replace a <= 50 with 50 >= newiv.
- This ensures that we still canonicalize to <invariant> <test>
- <induction variable>. */
- if (!expr_invariant_in_loop_p (temp, TREE_OPERAND (exitcond, 0)))
+ /* We want to build a conditional where true means exit the loop, and
+ false means continue the loop.
+ So swap the testtype if this isn't the way things are.*/
+ if (exit->flags & EDGE_FALSE_VALUE)
testtype = swap_tree_comparison (testtype);
COND_EXPR_COND (exitcond) = build (testtype,
VEC_replace (tree, new_ivs, i, ivvar);