]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR middle-end/82123
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Feb 2018 18:53:29 +0000 (18:53 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Feb 2018 18:53:29 +0000 (18:53 +0000)
PR tree-optimization/81592
PR middle-end/79257
* gimple-ssa-sprintf.c (sprintf_dom_walker::handle_gimple_call): Query
the EVRP range analyzer for range data rather than using global data.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257853 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/gimple-ssa-sprintf.c

index bef9eb1d3ffb35862dd3b7fd8c3c39bddec76b49..3dad6fe44b10cc1c08b14bc6619c280ee9a3e97e 100644 (file)
@@ -3,6 +3,8 @@
        PR middle-end/82123
        PR tree-optimization/81592
        PR middle-end/79257
+       * gimple-ssa-sprintf.c (sprintf_dom_walker::handle_gimple_call): Query
+       the EVRP range analyzer for range data rather than using global data.
        * gimple-ssa-sprintf.c: Include alloc-pool.h, vr-values.h and 
        gimple-ssa-evrp-analyze.h
        (class sprintf_dom_walker): Add after_dom_children member function.
index 545f8337c13c184717de94e98a008347ea55681e..4b2de6d2aa45e439b4f1ce76bffdad4eadea8306 100644 (file)
@@ -3903,16 +3903,13 @@ sprintf_dom_walker::handle_gimple_call (gimple_stmt_iterator *gsi)
          /* Try to determine the range of values of the argument
             and use the greater of the two at level 1 and the smaller
             of them at level 2.  */
-         wide_int min, max;
-         enum value_range_type range_type
-           = get_range_info (size, &min, &max);
-         if (range_type == VR_RANGE)
-           {
-             dstsize
-               = (warn_level < 2
-                  ? wi::fits_uhwi_p (max) ? max.to_uhwi () : max.to_shwi ()
-                  : wi::fits_uhwi_p (min) ? min.to_uhwi () : min.to_shwi ());
-           }
+         value_range *vr = evrp_range_analyzer.get_value_range (size);
+         if (vr->type == VR_RANGE
+             && TREE_CODE (vr->min) == INTEGER_CST
+             && TREE_CODE (vr->max) == INTEGER_CST)
+           dstsize = (warn_level < 2
+                      ? TREE_INT_CST_LOW (vr->max)
+                      : TREE_INT_CST_LOW (vr->min));
 
          /* The destination size is not constant.  If the function is
             bounded (e.g., snprintf) a lower bound of zero doesn't