This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/81635] [8 Regression] nvptx SLP test cases regressions
- From: "rsandifo at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 08 Feb 2018 15:17:01 +0000
- Subject: [Bug tree-optimization/81635] [8 Regression] nvptx SLP test cases regressions
- Auto-submitted: auto-generated
- References: <bug-81635-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81635
--- Comment #14 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Author: rsandifo
Date: Thu Feb 8 15:16:29 2018
New Revision: 257491
URL: https://gcc.gnu.org/viewcvs?rev=257491&root=gcc&view=rev
Log:
Use nonzero bits to refine range in split_constant_offset (PR 81635)
This patch is part 2 of the fix for PR 81635. It means that
split_constant_offset can handle loops like:
for (unsigned int i = 0; i < n; i += 4)
{
a[i] = ...;
a[i + 1] = ...;
}
CCP records that "i" must have its low 2 bits clear, but we don't
include this information in the range of "i", which remains [0, +INF].
I tried making set_nonzero_bits update the range info in the same
way that set_range_info updates the nonzero bits, but it regressed
cases like vrp117.c and made some other tests worse.
vrp117.c has a multiplication by 10, so CCP can infer that the low bit
of the result is clear. If we included that in the range, the range
would go from [-INF, +INF] to [-INF, not-quite-+INF]. However,
the multiplication is also known to overflow in all cases, so VRP
saturates the result to [INT_MAX, INT_MAX]. This obviously creates a
contradiction with the nonzero bits, and intersecting the new saturated
range with an existing not-quite-+INF range would make us drop to
VR_UNDEFINED. We're prepared to fold a comparison with an [INT_MAX,
INT_MAX] value but not with a VR_UNDEFINED value.
The other problems were created when intersecting [-INF, not-quite-+INF]
with a useful VR_ANTI_RANGE like ~[-1, 1]. The intersection would
keep the former range rather than the latter.
The patch therefore keeps the adjustment local to split_constant_offset
for now, but adds a helper routine so that it's easy to move this later.
2018-02-08 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
PR tree-optimization/81635
* wide-int.h (wi::round_down_for_mask, wi::round_up_for_mask): Declare.
* wide-int.cc (wi::round_down_for_mask, wi::round_up_for_mask)
(test_round_for_mask): New functions.
(wide_int_cc_tests): Call test_round_for_mask.
* tree-vrp.h (intersect_range_with_nonzero_bits): Declare.
* tree-vrp.c (intersect_range_with_nonzero_bits): New function.
* tree-data-ref.c (split_constant_offset_1): Use it to refine the
range returned by get_range_info.
gcc/testsuite/
PR tree-optimization/81635
* gcc.dg/vect/bb-slp-pr81635-3.c: New test.
* gcc.dg/vect/bb-slp-pr81635-4.c: Likewise.
Added:
trunk/gcc/testsuite/gcc.dg/vect/bb-slp-pr81635-3.c
trunk/gcc/testsuite/gcc.dg/vect/bb-slp-pr81635-4.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-data-ref.c
trunk/gcc/tree-vrp.c
trunk/gcc/tree-vrp.h
trunk/gcc/wide-int.cc
trunk/gcc/wide-int.h