Use precision and sign to compare types for ranges
authorAndrew MacLeod <amacleod@redhat.com>
Mon, 19 Oct 2020 23:04:40 +0000 (19:04 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Mon, 19 Oct 2020 23:11:17 +0000 (19:11 -0400)
commit6e02de946125c36871bd4d8eff21f7f88f01a8aa
treed56c07a37e03501257e2682ecccc234d5a29cdff
parentf000b7c436e62c52798187d8150216569eef17b5
Use precision and sign to compare types for ranges

Sanity check ranges by comparing just SIGN and PRECISION.

gcc/
PR tree-optimization/97360
* gimple-range.h (range_compatible_p): New.
* gimple-range-gori.cc (is_gimple_logical_p): Use range_compatible_p.
(range_is_either_true_or_false): Ditto.
(gori_compute::outgoing_edge_range_p): Cast result to the correct
type if necessary.
(logical_stmt_cache::cacheable_p): Use range_compatible_p.
* gimple-range.cc (gimple_ranger::calc_stmt): Check range_compatible_p
before casting the range.
(gimple_ranger::range_on_exit): Use range_compatible_p.
(gimple_ranger::range_on_edge): Ditto.

gcc/testsuite/
* gcc.dg/pr97360-2.c: New test.
gcc/gimple-range-gori.cc
gcc/gimple-range.cc
gcc/gimple-range.h
gcc/testsuite/gcc.dg/pr97360-2.c [new file with mode: 0644]