Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r16-7428-gc4c747adc8959d.

gcc/analyzer/ChangeLog:
        PR analyzer/113496
        * constraint-manager.cc (cmp_types): New.
        (bounded_range::cmp): Compare the types of the constants, as well
        as their values.

gcc/testsuite/ChangeLog:
        PR analyzer/113496
        * gcc.dg/analyzer/ice-pr113496.c: New test.

Signed-off-by: David Malcolm <[email protected]>
---
 gcc/analyzer/constraint-manager.cc           | 21 +++++++++++++++++---
 gcc/testsuite/gcc.dg/analyzer/ice-pr113496.c | 21 ++++++++++++++++++++
 2 files changed, 39 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/analyzer/ice-pr113496.c

diff --git a/gcc/analyzer/constraint-manager.cc 
b/gcc/analyzer/constraint-manager.cc
index 738ac28003f21..22b8d402df01f 100644
--- a/gcc/analyzer/constraint-manager.cc
+++ b/gcc/analyzer/constraint-manager.cc
@@ -512,13 +512,28 @@ bounded_range::operator== (const bounded_range &other) 
const
          && tree_int_cst_equal (m_upper, other.m_upper));
 }
 
+static int
+cmp_types (const_tree type1, const_tree type2)
+{
+  int t1 = TYPE_UID (type1);
+  int t2 = TYPE_UID (type2);
+  return t1 - t2;
+}
+
 int
 bounded_range::cmp (const bounded_range &br1, const bounded_range &br2)
 {
-  if (int cmp_lower = tree_int_cst_compare (br1.m_lower,
-                                           br2.m_lower))
+  if (int cmp_lower = tree_int_cst_compare (br1.m_lower, br2.m_lower))
     return cmp_lower;
-  return tree_int_cst_compare (br1.m_upper, br2.m_upper);
+  if (int cmp_upper = tree_int_cst_compare (br1.m_upper, br2.m_upper))
+    return cmp_upper;
+  if (int cmp_lower_type = cmp_types (TREE_TYPE (br1.m_lower),
+                                     TREE_TYPE (br2.m_lower)))
+    return cmp_lower_type;
+  if (int cmp_upper_type = cmp_types (TREE_TYPE (br1.m_upper),
+                                     TREE_TYPE (br2.m_upper)))
+    return cmp_upper_type;
+  return 0;
 }
 
 /* struct bounded_ranges.  */
diff --git a/gcc/testsuite/gcc.dg/analyzer/ice-pr113496.c 
b/gcc/testsuite/gcc.dg/analyzer/ice-pr113496.c
new file mode 100644
index 0000000000000..147228bf0c727
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/ice-pr113496.c
@@ -0,0 +1,21 @@
+/* { dg-additional-options "-fdump-analyzer" } */
+
+enum { PIPE_SWIZZLE_X, PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W };
+enum { UTIL_FORMAT_COLORSPACE_YUV, UTIL_FORMAT_COLORSPACE_ZS } colorspace;
+int util_format_colormask_descutil_format_colormask_colormask,
+    util_format_get_component_bits_component,
+    util_format_get_component_bits_desc_0_3_0;
+void util_format_colormask_descutil_format_colormask() {
+  switch (colorspace) {
+  case UTIL_FORMAT_COLORSPACE_YUV:
+    util_format_colormask_descutil_format_colormask_colormask = 0;
+    for (;;)
+    case UTIL_FORMAT_COLORSPACE_ZS:; /* { dg-warning "infinite loop" } */
+  }
+}
+unsigned util_format_get_component_bits() {
+  switch (util_format_get_component_bits_component)
+  case PIPE_SWIZZLE_X:
+  case PIPE_SWIZZLE_W:
+    return util_format_get_component_bits_desc_0_3_0;
+}
-- 
2.26.3

Reply via email to