poly_span_traits fixes (PR 84811)
commit009bee8c4612b3a14cdabe7949bf33e6fdfe8baa
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Mar 2018 20:52:15 +0000 (21 20:52 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Mar 2018 20:52:15 +0000 (21 20:52 +0000)
tree46261783cb3e754715a50c28c60d025fc28af544
parent6187b750b6720597f91a1a25626f7e2b66f20a10
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258743 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/poly-int.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr84811.c [new file with mode: 0644]