[PTR-PLUS] Fix up SCEV, Data ref, the vectorizer, and loop niter

Andrew_Pinski@PlayStation.Sony.Com Andrew_Pinski@PlayStation.Sony.Com
Thu May 10 03:34:00 GMT 2007


Hi,
  This patch fixes most of the vectorizer testsuite failures (there are 
two left dealing with the data reference and how we return even more 
conserative results but no wrong code or ICE) and all of the loop/ltrans 
testcases.  After this patch, we now are able to vectorize vect-106.c 
because the aliasing pass no longer gets confused as there are no casts 
(this is the first testcase which shows an improvement in the testsuite).

So for polynomial_chrec, we consider the increment of a POINTER type to be 
sizetype instead of pointer type, this allows for parrallelism with 
POINTER_PLUS_EXPR.  I needed a new function called chrec_convert_rhs to 
simplify this case.  This patch also removes the code which had dealt with 
the cast to pointer type in tree-scalar-evolution.c as they are no longer 
needed with POINTER_PLUS_EXPR.

Zdenek wrote most of the tree-scalar-evolution.c and tree-chrec parts and 
I tweaked it to make it work and added chrec_convert_rhs to simplify the 
code.  I also added support to tree-ssa-loop-niter.c and tree-data-ref.c 
for POINTER_PLUS_EXPR so the testcases would pass.  I needed to an extra 
folding of MINUS_EXPR when we have ((PTR0 p+ A) - (PTR1 p+ B)) and (PTR0 
p+ A) - PTR1 [where PTR0 - PTR1 simplifies] to get one of the two loop 
testcases to pass and optimize correctly.

The vectorizer needed a quick fix for it was building a multiply 
expression in a pointer type which was declared as invalid in my previous 
VRP patch.  In fold_to_nonsharp_ineq_using_bound in fold-const, when I 
added support for pointers, I accidently used the wrong type for the 
MINUS_EXPR, I was using the pointer type which caused a crash in some 
cases.


Here is the diff stats, it shows some nice stats:
 fold-const.c                     |   27 ++++
 testsuite/gcc.dg/vect/vect-106.c |    9 -
 tree-chrec.c                     |   49 ++++++--
 tree-chrec.h                     |    6 -
 tree-data-ref.c                  |   15 +-
 tree-scalar-evolution.c          |  215 
++++-----------------------------------
 tree-ssa-loop-niter.c            |   45 ++++----
 tree-vect-transform.c            |   21 ++-
 8 files changed, 147 insertions(+), 240 deletions(-)


Committed to the branch after a bootstrap and test on i686-linux-gnu (C, 
C++, and Fortran).

Thanks,
Andrew Pinski

PS Richard, could you run a SPEC/C++ benchmark on the branch.
PPS. There are still a couple of regressions in the C++ testsuite, one 
dealing with expand causing an internal error and some libmudflap C++ 
ICEs.


ChangeLog:

        * fold-const.c  (fold_to_nonsharp_ineq_using_bound): Don't
        use a pointer type for MINUS_EXPR.
        (fold_binary <case MINUS_EXPR>): Fold (PTR0 p+ A) - (PTR1 p+ B)
        into (PTR0 - PTR1) + (A - B). Fold (PTR0 p+ A) - PTR1 into
        (PTR0 - PTR1) + A iff (PTR0 - PTR1) simplifies.
        * tree-chrec.c (chrec_fold_plus_poly_poly): For
        POINTER_PLUS_EXPR, use a different right hand side type.
        Handle POINTER_PLUS_EXPR like PLUS_EXPR.
        (chrec_fold_plus_1): Likewise.
        (convert_affine_scev): Likewise.
        (chrec_convert_aggressive): Likewise.
        (chrec_fold_plus): For pointer types, use POINTER_PLUS_EXPR
        instead of PLUS_EXPR.
        (reset_evolution_in_loop): For pointer types, the new_evol
        should be sizetype.
        (chrec_convert_rhs): New function.
        * tree-chrec.h (chrec_convert_rhs): New prototype.
        (build_polynomial_chrec): For pointer types, the right hand
        side should be sizetype and not the same as the left hand side.
        * tree-scalar-evolution.c (add_to_evolution_1): Convert the
        increment using chrec_convert_rhs instead of chrec_convert.
        (follow_ssa_edge_in_rhs): Handle POINTER_PLUS_EXPR like
        PLUS_EXPR except for the right hand side's type will be
        sizetype.
        (interpret_rhs_modify_stmt): Handle POINTER_PLUS_EXPR.
        (fold_used_pointer_cast): Kill.
        (pointer_offset_p): Kill.
        (fold_used_pointer): Kill.
        (pointer_used_p): Kill.
        (analyze_scalar_evolution_1 <case GIMPLE_MODIFY_STMT>): Don't
        call fold_used_pointer.
        (instantiate_parameters_1): Convert the increment
        using chrec_convert_rhs instead of chrec_convert.
        Handle POINTER_PLUS_EXPR as PLUS_EXPR.
        * tree-ssa-loop-niter.c (split_to_var_and_offset): Handle
        POINTER_PLUS_EXPR as PLUS_EXPR.
        (assert_loop_rolls_lt): For pointer types, use sizetype when
        creating MINUS_EXPR/PLUS_EXPRs.
        (number_of_iterations_le): Likewise.
        (expand_simple_operations): POINTER_PLUS_EXPR are simple also.
        (derive_constant_upper_bound): Handle POINTER_PLUS_EXPR just
        like PLUS_EXPR and MINUS_EXPR.
        * tree-data-ref.c (analyze_offset_expr): Likewise.
        (address_analysis): Handle POINTER_PLUS_EXPR as PLUS_EXPR.
        (analyze_offset): Handle POINTER_PLUS_EXPR also.
        (create_data_ref): Convert the increment
        using chrec_convert_rhs instead of chrec_convert.
        * tree-vect-transform.c (vect_update_ivs_after_vectorizer):
        For pointer types, create POINTER_PLUS_EXPR instead of
        PLUS_EXPR and also create MULT_EXPR in sizetype.


        * gcc.dg/vect/vect-106.c: We are now able to vectorize two
        loops instead of one. Remove the "can't determine dependence"
        check.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fixscevdatarefvect.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070510/81f60cac/attachment.txt>


More information about the Gcc-patches mailing list