This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 2/3]Improve induction variable elimination
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Bin Cheng <bin dot cheng at arm dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 25 Jul 2014 14:35:19 +0200
- Subject: Re: [PATCH 2/3]Improve induction variable elimination
- Authentication-results: sourceware.org; auth=none
- References: <002e01cfa19e$ac13fed0$043bfc70$ at arm dot com>
On Thu, Jul 17, 2014 at 11:08 AM, Bin Cheng <bin.cheng@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.
Richard.
> 2014-07-17 Bin Cheng <bin.cheng@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. Handle constant
> cases. Use affine expansion for equality check.
> (iv_elimination_compare_lt): Pass new argument.
>
> gcc/testsuite/ChangeLog
> 2014-07-17 Bin Cheng <bin.cheng@arm.com>
>
> * gcc.dg/tree-ssa/ivopts-lt-2.c: New test.