[COMMITTED] Use pp_vrange for ranges in dump_ssaname_info.

Message ID 20220715094035.1011279-3-aldyh@redhat.com
State Committed
Commit 3aab916f4ff9b41222273e712e1d435013ac8150
Headers
Series [COMMITTED] Use pp_vrange for ranges in dump_ssaname_info. |

Commit Message

Aldy Hernandez July 15, 2022, 9:40 a.m. UTC
  This changes the ad-hoc dumping of ranges in the gimple pretty printer
to use the pp_vrange utility function, which has the benefit of
handling all range types going forward and unifying the dumping code.

Instead of:
	# RANGE [0, 51] NONZERO 0x3f
	# RANGE ~[5, 10]

we would now get:

	# RANGE [irange] long unsigned int [0, 51] NONZERO 0x3f
	# RANGE [irange] int [-MIN, 4][11, MAX]

Tested on x86-64 Linux.

gcc/ChangeLog:

	* gimple-pretty-print.cc (dump_ssaname_info): Use pp_vrange.
---
 gcc/gimple-pretty-print.cc | 32 ++++----------------------------
 1 file changed, 4 insertions(+), 28 deletions(-)
  

Comments

Aldy Hernandez July 15, 2022, 12:30 p.m. UTC | #1
On Fri, Jul 15, 2022 at 11:40 AM Aldy Hernandez <aldyh@redhat.com> wrote:
>
> This changes the ad-hoc dumping of ranges in the gimple pretty printer
> to use the pp_vrange utility function, which has the benefit of
> handling all range types going forward and unifying the dumping code.
>
> Instead of:
>         # RANGE [0, 51] NONZERO 0x3f
>         # RANGE ~[5, 10]
>
> we would now get:
>
>         # RANGE [irange] long unsigned int [0, 51] NONZERO 0x3f
>         # RANGE [irange] int [-MIN, 4][11, MAX]

BTW, these are the global ranges, that for some historical reason
unknown to me, are visible with -fdump-tree-all-alias.  Yes, alias
:-).  For example:

 <bb 3> :
  _1 = (long unsigned int) i_54;
  # RANGE [irange] long unsigned int [0, +INF] NONZERO 0xfffffffffffffffc
  _2 = _1 * 4;
  _3 = ia_60(D) + _2;
  _4 = *_3;
  _5 = (long unsigned int) i_54;
  # RANGE [irange] long unsigned int [0, +INF] NONZERO 0xfffffffffffffffc
  _6 = _5 * 4;
...
...

The VRP twins, as well as other ranger clients, continue displaying
things as they were before.

Aldy
  

Patch

diff --git a/gcc/gimple-pretty-print.cc b/gcc/gimple-pretty-print.cc
index ebd87b20a0a..f18baec438a 100644
--- a/gcc/gimple-pretty-print.cc
+++ b/gcc/gimple-pretty-print.cc
@@ -30,6 +30,7 @@  along with GCC; see the file COPYING3.  If not see
 #include "ssa.h"
 #include "cgraph.h"
 #include "gimple-pretty-print.h"
+#include "value-range-pretty-print.h"
 #include "internal-fn.h"
 #include "tree-eh.h"
 #include "gimple-iterator.h"
@@ -2335,35 +2336,10 @@  dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
   if (!POINTER_TYPE_P (TREE_TYPE (node))
       && SSA_NAME_RANGE_INFO (node))
     {
-      wide_int min, max, nonzero_bits;
-      value_range r;
-
+      Value_Range r (TREE_TYPE (node));
       get_global_range_query ()->range_of_expr (r, node);
-      value_range_kind range_type = r.kind ();
-      if (!r.undefined_p ())
-	{
-	  min = wi::to_wide (r.min ());
-	  max = wi::to_wide (r.max ());
-	}
-
-      // FIXME: Use irange::dump() instead.
-      if (range_type == VR_VARYING)
-	pp_printf (buffer, "# RANGE VR_VARYING");
-      else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
-	{
-	  pp_printf (buffer, "# RANGE ");
-	  pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
-	  pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
-	  pp_printf (buffer, ", ");
-	  pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
-	  pp_printf (buffer, "]");
-	}
-      nonzero_bits = get_nonzero_bits (node);
-      if (nonzero_bits != -1)
-	{
-	  pp_string (buffer, " NONZERO ");
-	  pp_wide_int (buffer, nonzero_bits, UNSIGNED);
-	}
+      pp_string (buffer, "# RANGE ");
+      pp_vrange (buffer, &r);
       newline_and_indent (buffer, spc);
     }
 }