https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84811
--- Comment #26 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> --- Author: rsandifo Date: Wed Mar 21 20:52:15 2018 New Revision: 258743 URL: https://gcc.gnu.org/viewcvs?rev=258743&root=gcc&view=rev Log: 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.sandif...@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. Added: trunk/gcc/testsuite/gcc.dg/torture/pr84811.c Modified: trunk/gcc/ChangeLog trunk/gcc/poly-int.h trunk/gcc/testsuite/ChangeLog