This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH PR80153]Part1, Get base pointer from the first element of pointer type aff_tree, Simplify add_elt_to_tree


Hi,
This is another try fixing PR80153.  It's based on richi's idea which is easier to understand than my
previous patch.  The patch gets base pointer from the first element of pointer aff_tree, builds result
expression in aff_tree's type unconditionally.  With this patch, A) we can do unconditional type
conversion on element in add_elt_to_tree, which simplify the function a lot; B) Except for below
mentioned fallout, customer of aff_tree doesn't need to do explicit conversion for result expression
of aff_combination_to_tree now.

Though this patch can handle normal constant base pointer_plus_expr, e.g, ((char *)1024 + (size_t)x),
we still can't handle extreme case in which x is of pointer type and its coef is 1.  I believe this is
a latent problem in tree-affine.c all the time.  It's not exposed because the biggest customer (ivopt)
always generates code in unsigned, rather than pointer type.  Let's see if this patch will uncover the issue.

I also need to do more invariant check in rewrite_use_nonlinear_expr for test gcc.dg/tree-ssa/reassoc-19.c.
 It relies on wrong behavior of tree-affine.c addressed in this patch.

Bootstrap and test on X86_64 and AArch64.  Is it OK if no failures?  The next patch addresses a
breakage of tree-affine.c usage.

Thanks,
bin

2017-04-07  Richard Biener  <rguenther@suse.de>
	    Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/80153
	* tree-affine.c (aff_combination_to_tree): Get base pointer from
	the first element of pointer type aff_tree.  Build result expr in
	aff_tree's type.
	(add_elt_to_tree): Convert to type unconditionally.  Remove other
	fold_convert calls.
	* tree-ssa-loop-ivopts.c (alloc_iv): Pass in consistent types.
	(rewrite_use_nonlinear_expr): Check invariant using iv information.

gcc/testsuite/ChangeLog
2017-04-07  Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/80153
	* gcc.c-torture/execute/pr80153.c: New.

Attachment: pr80153-part1-20170407.txt
Description: pr80153-part1-20170407.txt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]