Skip to content
Snippets Groups Projects
Commit eea52e38 authored by Andrew Carlotti's avatar Andrew Carlotti
Browse files

Refactor number_of_iterations_popcount

This includes various changes to improve clarity, and to enable the code
to be more similar to the clz and ctz idiom recognition added in
subsequent patches.

We create new number_of_iterations_bitcount function, which will be used
to call the other bit-counting recognition functions added in subsequent
patches, as well as a generic comment describing the loop structures
that are common to each idiom. Some of the variables in
number_of_iterations_popcount are given more descriptive names, and the
popcount expression builder is extracted into a separate function.

As part of the refactoring, we also fix a bug where the max loop count
for modes shorter than an integer would be incorrectly computed as if
the input mode were actually an integer.

We also ensure that niter->max takes into account the final value for
niter->niter (after any folding and simplifying), since if the latter is a
constant, then record_estimate mandates that the two values are equivalent.

gcc/ChangeLog:

	* tree-ssa-loop-niter.cc
	(number_of_iterations_exit_assumptions): Modify to call...
	(number_of_iterations_bitcount): ...this new function.
	(number_of_iterations_popcount): Now called by the above.
	Refactor, and extract popcount expression builder to...
	(build_popcount_expr): this new function.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/popcount-max.c: New test.
parent fe985a23
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment