[COMMITTED] Avoid comparing ranges when sub-ranges is 0.

Message ID 20221003110815.1075975-3-aldyh@redhat.com
State New, archived
Headers
Series [COMMITTED] Avoid comparing ranges when sub-ranges is 0. |

Commit Message

Aldy Hernandez Oct. 3, 2022, 11:08 a.m. UTC
  There is nothing else to compare when the number of sub-ranges is 0.

gcc/ChangeLog:

	* value-range.cc (irange::operator==): Early bail on m_num_ranges
	equal to 0.
---
 gcc/value-range.cc | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index ddbcdd67633..e1066f4946e 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -1260,6 +1260,9 @@  irange::operator== (const irange &other) const
   if (m_num_ranges != other.m_num_ranges)
     return false;
 
+  if (m_num_ranges == 0)
+    return true;
+
   for (unsigned i = 0; i < m_num_ranges; ++i)
     {
       tree lb = tree_lower_bound (i);