On Fri, Jul 25, 2014 at 8:35 PM, Richard Biener <richard.guent...@gmail.com> wrote: > On Thu, Jul 17, 2014 at 11:08 AM, Bin Cheng <bin.ch...@arm.com> wrote: >> Hi, >> As quoted from the function difference_cannot_overflow_p, >> >> /* TODO: deeper inspection may be necessary to prove the equality. */ >> switch (code) >> { >> case PLUS_EXPR: >> return expr_equal_p (e1, offset) || expr_equal_p (e2, offset); >> case POINTER_PLUS_EXPR: >> return expr_equal_p (e2, offset); >> >> default: >> return false; >> } >> >> The overflow check can be improved by using deeper inspection to prove the >> equality. This patch deals with that by making below two improvements: >> a) Handles constant cases. >> b) Uses affine expansion as deeper inspection to check the equality. >> >> As a result, functions strip_wrap_conserving_type_conversions and >> expr_equal_p can be removed now. A test case is also added to illustrate iv >> elimination opportunity captured by this patch. >> >> Thanks, >> bin > > You add special casing for constants but I don't see any testcases for that. > Specifically > > + /* No overflow if offset is zero. */ > + if (offset == integer_zero_node) > return true; > > is a bogus check (use integer_zerop). Apart from the special-casing of > constants the patch looks good to me.
Hi Richard, I modified the patch according to your comments by removing the constant case. Re-bootstrap and test on x86_64 and x86. Is this version OK? Thanks, bin 2014-08-06 Bin Cheng <bin.ch...@arm.com> * tree-ssa-loop-ivopts.c (ivopts_data): New field name_expansion. (tree_ssa_iv_optimize_init): Initialize name_expansion. (tree_ssa_iv_optimize_finalize): Free name_expansion. (strip_wrap_conserving_type_conversions, expr_equal_p): Delete. (difference_cannot_overflow_p): New parameter. Use affine expansion for equality check. (iv_elimination_compare_lt): Pass new argument. gcc/testsuite/ChangeLog 2014-08-06 Bin Cheng <bin.ch...@arm.com> * gcc.dg/tree-ssa/ivopts-lt-2.c: New test.