Message ID | 4D7D005B.6000002@codesourcery.com |
---|---|
State | New |
Headers | show |
Hi, > diff -u gcc/tree-ssa-loop-ivopts.c gcc/tree-ssa-loop-ivopts.c > --- gcc/tree-ssa-loop-ivopts.c (working copy) > +++ gcc/tree-ssa-loop-ivopts.c (working copy) > @@ -1194,6 +1300,7 @@ record_use (struct ivopts_data *data, tr > gimple stmt, enum use_type use_type) > { > struct iv_use *use = XCNEW (struct iv_use); > + tree tmp; > > use->id = n_iv_uses (data); > use->type = use_type; > @@ -1204,11 +1311,14 @@ record_use (struct ivopts_data *data, tr > > /* To avoid showing ssa name in the dumps, if it was not reset by the > caller. */ > + tmp = iv->ssa_name; > iv->ssa_name = NULL_TREE; > > if (dump_file && (dump_flags & TDF_DETAILS)) > dump_use (dump_file, use); > > + iv->ssa_name = tmp; > + > VEC_safe_push (iv_use_p, heap, data->iv_uses, use); > > return use; this is not ok. You can get the ssa name from extract_cond_operands. > + /* Determine if the exit test is formulated in terms of the phi or the > + increment of the use iv. */ > + use_uses_inced_iv > + = gimple_code (SSA_NAME_DEF_STMT (use->iv->ssa_name)) != GIMPLE_PHI; > + > + /* Determine if the exit test is before or after the increment of the > + cand. */ > + use_after_cand_inc > + = stmt_after_increment (data->current_loop, cand, use->stmt); > + > + /* For now, we only handle these cases. */ > + if (use_after_cand_inc != use_uses_inced_iv) > + return false; what is this trying to achieve? USE_USES_INCED_IV is pretty much meaningless -- the value of USE does not depend in any way on whether it comes directly from a PHI node or from some other calculation. > + /* Calculate bound. */ > + bound = fold_build_plus (PLUS_EXPR, base_ptr, > + fold_convert (sizetype, use_lt_bound)); > + if (bound == NULL_TREE) > + return false; How could the result be NULL_TREE? Zdenek
Index: gcc/testsuite/gcc.dg/tree-ssa/ivopts-lt.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/ivopts-lt.c (revision 0) +++ gcc/testsuite/gcc.dg/tree-ssa/ivopts-lt.c (revision 0) @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ivopts -fno-tree-vectorize -fno-tree-loop-ivcanon" } */ + +void +f1 (char *p, unsigned long int i, unsigned long int n) +{ + p += i; + do + { + *p = '\0'; + p += 1; + i++; + } + while (i < n); +} + +void +f2 (char *p, unsigned int i, unsigned int n) +{ + p += i; + do + { + *p = '\0'; + p += 1; + i++; + } + while (i < n); +} + +/* { dg-final { scan-tree-dump-times "PHI" 2 "ivopts"} } */ +/* { dg-final { scan-tree-dump-times "PHI <p_" 2 "ivopts"} } */ +/* { dg-final { scan-tree-dump-times "p_\[0-9\]* <" 2 "ivopts"} } */ +/* { dg-final { cleanup-tree-dump "ivopts" } } */