This is the mail archive of the 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 3/3]Improve induction variable elimination

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
  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.


2014-07-17  Bin Cheng  <>

	* tree-ssa-loop-ivopts.c (iv_nowrap_period)
	(nowrap_cand_for_loop_niter_p): New functions.
	(period_greater_niter_exit): New function refactored from
	(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.

2014-07-17  Bin Cheng  <>

	* gcc.dg/tree-ssa/ivopts-lt-3.c: New test.
	* gcc.dg/tree-ssa/ivopts-lt-4.c: New test.

Attachment: iv_elimination-improve-c-20140716.txt
Description: Text document

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