Comments

Hi, forward to Zdenek for the review.
Thanks,
bin
---------- Forwarded message ----------
From: Bin Cheng <bin.cheng@arm.com>
Date: Thu, Jul 17, 2014 at 10:09 AM
Subject: [PATCH 3/3]Improve induction variable elimination
To: gcc-patches@gcc.gnu.org
Hi,
Function iv_elimination_compare_lt is used to eliminate induction variable
when the loop's latch could run for zero time (i.e., may_be_zero in loop
niter information evaluates to true). As stated in the first message, it
only handles very specific case that rarely happens for either GCC bootstrap
or spec2k/spec2k6 compilation. The function has two restrictions which
could be improved:
a) When checking that candidate iv doesn't overflow, it only handles
candidates that are computed in a type that guarantees no overflows. More
complex analysis can be used to prove the non-overflow ness, as in this
patch.
b) The function only handles the original form of may_be_zero like "a + 1
> b", but that expression could have been folded into other forms. This
patch handles three folded forms and does iv elimination as well. I think
this isn't a very corner case, because for many loops iterating from "0"
(i.e., we have "a == 0"), the expression will be folded.
I also refactored period check from may_eliminate_iv into a single function
so that it can be reused.
Thanks,
bin
2014-07-17 Bin Cheng <bin.cheng@arm.com>
* tree-ssa-loop-ivopts.c (iv_nowrap_period)
(nowrap_cand_for_loop_niter_p): New functions.
(period_greater_niter_exit): New function refactored from
may_eliminate_iv.
(iv_elimination_compare_lt): New parameter. Check wrapping
behavior for candidate of wrapping type. Handle folded forms
of may_be_zero expression.
(may_eliminate_iv): Call period_greater_niter_exit. Pass new
argument for iv_elimination_compare_lt.
gcc/testsuite/ChangeLog
2014-07-17 Bin Cheng <bin.cheng@arm.com>
* gcc.dg/tree-ssa/ivopts-lt-3.c: New test.
* gcc.dg/tree-ssa/ivopts-lt-4.c: New test.