poly_span_traits fixes (PR 84811)
authorRichard Sandiford <richard.sandiford@linaro.org>
Wed, 21 Mar 2018 20:52:15 +0000 (20:52 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Wed, 21 Mar 2018 20:52:15 +0000 (20:52 +0000)
commit535808fd722db576f0f14424bc083fbef183fd4b
tree46261783cb3e754715a50c28c60d025fc28af544
parente215422f1d6c69ae23b09de85a97bb3925cc5bfe
poly_span_traits fixes (PR 84811)

This patch fixes incorrect results for HOST_WIDE_INT positions
at opposite extremes when used with HOST_WIDE_INT sizes.  It also
fixes UB when comparing such positions with unsigned HOST_WIDE_INT
sizes (although the results in that case were wrapv-correct).

2018-03-20  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
PR tree-optimization/84811
* poly-int.h (poly_span_traits): Remove the T3 parameter and
promote HOST_WIDE_INT T2 - T1 results to unsigned HOST_WIDE_INT.
(maybe_in_range_p, known_in_range_p, ranges_known_overlap_p):
(known_subrange_p): Update accordingly.  Cast each value involved
in the size comparison, rather than casting the result of the
subtraction.

gcc/testsuite/
PR tree-optimization/84811
* gcc.dg/torture/pr84811.c: New test.

From-SVN: r258743
gcc/ChangeLog
gcc/poly-int.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr84811.c [new file with mode: 0644]