aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2019-10-04 08:27:45 -0600
committerJeff Law <law@gcc.gnu.org>2019-10-04 08:27:45 -0600
commit82de69ffc84e4598f0380e52b9239af7421ba6c9 (patch)
tree2e69292c5163b2470bd4b01780d2b9c235455e12
parentb1fc776335a5d905f6ca37cb0e158613b04d0dc3 (diff)
downloadgcc-82de69ffc84e4598f0380e52b9239af7421ba6c9.zip
gcc-82de69ffc84e4598f0380e52b9239af7421ba6c9.tar.gz
gcc-82de69ffc84e4598f0380e52b9239af7421ba6c9.tar.bz2
range-op.cc (range_tests): Avoid two tests when ints and shorts are the same size.
* range-op.cc (range_tests): Avoid two tests when ints and shorts are the same size. From-SVN: r276581
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/range-op.cc26
2 files changed, 22 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 97e48c0..02cf697 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2019-10-04 Jeff Law <law@redhat.com>
+
+ * range-op.cc (range_tests): Avoid two tests when ints and
+ shorts are the same size.
+
2019-10-04 Richard Biener <rguenther@suse.de>
PR lto/91968
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index fff4a55..fc314853 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -2910,10 +2910,14 @@ range_tests ()
// If a range is in any way outside of the range for the converted
// to range, default to the range for the new type.
- r1 = value_range_base (integer_zero_node, maxint);
- range_cast (r1, short_integer_type_node);
- ASSERT_TRUE (r1.lower_bound () == wi::to_wide (minshort)
- && r1.upper_bound() == wi::to_wide (maxshort));
+ if (TYPE_PRECISION (TREE_TYPE (maxint))
+ > TYPE_PRECISION (short_integer_type_node))
+ {
+ r1 = value_range_base (integer_zero_node, maxint);
+ range_cast (r1, short_integer_type_node);
+ ASSERT_TRUE (r1.lower_bound () == wi::to_wide (minshort)
+ && r1.upper_bound() == wi::to_wide (maxshort));
+ }
// (unsigned char)[-5,-1] => [251,255].
r0 = rold = value_range_base (SCHAR (-5), SCHAR (-1));
@@ -3020,11 +3024,15 @@ range_tests ()
// "NOT 0 at signed 32-bits" ==> [-MIN_32,-1][1, +MAX_32]. This is
// is outside of the range of a smaller range, return the full
// smaller range.
- r0 = range_nonzero (integer_type_node);
- range_cast (r0, short_integer_type_node);
- r1 = value_range_base (TYPE_MIN_VALUE (short_integer_type_node),
- TYPE_MAX_VALUE (short_integer_type_node));
- ASSERT_TRUE (r0 == r1);
+ if (TYPE_PRECISION (integer_type_node)
+ > TYPE_PRECISION (short_integer_type_node))
+ {
+ r0 = range_nonzero (integer_type_node);
+ range_cast (r0, short_integer_type_node);
+ r1 = value_range_base (TYPE_MIN_VALUE (short_integer_type_node),
+ TYPE_MAX_VALUE (short_integer_type_node));
+ ASSERT_TRUE (r0 == r1);
+ }
// Casting NONZERO from a narrower signed to a wider signed.
//