[PATCH PR69564]Improve vectorizer's runtime alias check for wrapping type

Bin Cheng Bin.Cheng@arm.com
Fri Feb 24 11:01:00 GMT 2017


Hi,
As analyzed in PR69564, inefficient code for runtime alias check is generated in benchmark
scimark2.  It is suspected vectorized loop doesn't run enough iterations to cover the loss
of the inefficient code.  This patch improves runtime alias check for (unsigned) wrapping
types.

Originally, vectorizer checks if below two ranges overlap with each other
    range a: [min_a, max_a]  ; abs(length_a) = max_a - min_a
    range_b: [min_b, max_b]  ; abs(length_b) = max_b - min_b
with condition like:
    max_a <= min_b || max_b <= min_a

With knowledge of length of the two ranges, this patch checks overlap with condition like:
    (min_b - min_a) >= abs(len_a) && (min_b - min_a) <= (- abs(len_b))
It's better because common sub expressions in b/a can be folded.

Note there is an implicit condition for above statements that length of range needs to be
no larger than middle value of the unsigned type.  This is always true since object never
spans over half address space in GCC.

As mentioned, this is only done for case with wrap type and also constant segment length
for both a and b, which is the most common case.  It is possible to improve signed cases
or compilation time unknown segment length cases too, but may not worth the effort.

Unfortunately, test case is hard to create for such code optimization.
Bootstrap and test on x86)64 and AArch64.  Is it OK?

Thanks,
bin

2017-02-23  Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/69564
	* tree-vect-loop-manip.c (tree-affine.h): Include.
	(create_intersect_range_checks): For types with wrap behavior, check
	range overlap for [min_a, max_a]/[min_b, max_b] with condition like:
	"(min_b - min_a) >= abs(len_a) && (min_b - min_a) <= (-abs(len_b))".

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr69564-20170218.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20170224/f14af625/attachment.txt>


More information about the Gcc-patches mailing list