public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][committed][PR tree-optimization/82123] 03/06 Query EVRP range data in sprintf warning pass
@ 2018-02-20 18:53 Jeff Law
  0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2018-02-20 18:53 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 301 bytes --]


This is the 3rd patch in the series.  It updates one of the 3 range
queries to start using the EVRP computed range data.  This one is
trivial as it's occurring in a member function where we have direct
access to the range analyzer data.

Bootstrapped and regression tested on x86_64-linux-gnu.

Jeff

[-- Attachment #2: P3 --]
[-- Type: text/plain, Size: 1296 bytes --]

	* gimple-ssa-sprintf.c (sprintf_dom_walker::handle_gimple_call): Query
	the EVRP range analyzer for range data rather than using global data.


diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 545f833..4b2de6d 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-20 18:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-20 18:53 [PATCH][committed][PR tree-optimization/82123] 03/06 Query EVRP range data in sprintf warning pass Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).