re PR middle-end/78501 (SEGV in vrp_val_max)
authorJakub Jelinek <jakub@redhat.com>
Fri, 25 Nov 2016 08:03:51 +0000 (09:03 +0100)
committerPrathamesh Kulkarni <prathamesh3492@gcc.gnu.org>
Fri, 25 Nov 2016 08:03:51 +0000 (08:03 +0000)
2016-11-25  Jakub Jelinek  <jakub@redhat.com>
    Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

PR middle-end/78501
* tree-vrp.c (extract_range_basic): Check for ptrdiff_type_node to be
non null and it's precision matches precision of lhs's type.

Co-Authored-By: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
From-SVN: r242858

gcc/ChangeLog
gcc/tree-vrp.c

index ab4ab36ea4cbb38021cffc32d8d0678f56414b0f..f2b48289d6b9ee97aba875f96eeafd4d801746de 100644 (file)
@@ -1,3 +1,10 @@
+2016-11-25  Jakub Jelinek  <jakub@redhat.com>
+           Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       PR middle-end/78501
+       * tree-vrp.c (extract_range_basic): Check for ptrdiff_type_node to be
+       non null and it's precision matches precision of lhs's type.
+
 2016-11-24  Martin Sebor  <msebor@redhat.com>
 
        PR tree-optimization/78476
index 33e0a755cfee6fa929a7ae89dadba4ded4e44d33..8bea4dbc3fb49549f1621258d5745244ef0cce6c 100644 (file)
@@ -4028,15 +4028,20 @@ extract_range_basic (value_range *vr, gimple *stmt)
          }
          return;
        case CFN_BUILT_IN_STRLEN:
-         {
-           tree type = TREE_TYPE (gimple_call_lhs (stmt));
-           tree max = vrp_val_max (ptrdiff_type_node);
-           wide_int wmax = wi::to_wide (max, TYPE_PRECISION (TREE_TYPE (max)));
-           tree range_min = build_zero_cst (type); 
-           tree range_max = wide_int_to_tree (type, wmax - 1);
-           set_value_range (vr, VR_RANGE, range_min, range_max, NULL);
-         }
-         return;
+         if (tree lhs = gimple_call_lhs (stmt))
+           if (ptrdiff_type_node
+               && (TYPE_PRECISION (ptrdiff_type_node)
+                   == TYPE_PRECISION (TREE_TYPE (lhs))))
+             {
+               tree type = TREE_TYPE (lhs);
+               tree max = vrp_val_max (ptrdiff_type_node);
+               wide_int wmax = wi::to_wide (max, TYPE_PRECISION (TREE_TYPE (max)));
+               tree range_min = build_zero_cst (type);
+               tree range_max = wide_int_to_tree (type, wmax - 1);
+               set_value_range (vr, VR_RANGE, range_min, range_max, NULL);
+               return;
+             }
+         break;
        default:
          break;
        }