diff mbox series

[COMMITTED] Automatically set type is certain Value_Range routines.

Message ID af917818-2d7b-f75f-8088-d58e357ba281@redhat.com
State New
Headers show
Series [COMMITTED] Automatically set type is certain Value_Range routines. | expand

Commit Message

Andrew MacLeod Aug. 3, 2023, 6:25 p.m. UTC
When you use a Value_Range, you need to set it's type first so it knows 
whether it will be an irange or an frange or whatever.

There are a few set routines which take a type, and you shouldn't need 
to set the type first in those cases..  For instance set_varying() takes 
a type, so it seems pointless to specify the type twice.  ie

Value_Range r1 (TREE_TYPE (name));
r1.set_varying (TREE_TYPE (name));

this patch automatically sets the kind based on the type in the routines 
set_varying(), set_zero(), and set_nonzero().. All of which take a type 
parameter.  Now it is simply:

Value_Range r1;
r1.set_varying (TREE_TYPE (name));

Bootstraps on  x86_64-pc-linux-gnu with no regressions.   Pushed.

Andrew
diff mbox series

Patch

From 1fbde4cc5fb7ad4b08f0f7ae1f247f9b35124f99 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Wed, 2 Aug 2023 17:46:58 -0400
Subject: [PATCH 1/3] Automatically set type is certain Value_Range routines.

Set routines which take a type shouldn't have to pre-set the type of the
underlying range as it is specified as a parameter already.

	* value-range.h (Value_Range::set_varying): Set the type.
	(Value_Range::set_zero): Ditto.
	(Value_Range::set_nonzero): Ditto.
---
 gcc/value-range.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/value-range.h b/gcc/value-range.h
index d8af6fca7d7..622b68863d2 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -679,15 +679,16 @@  public:
   tree type () { return m_vrange->type (); }
   bool varying_p () const { return m_vrange->varying_p (); }
   bool undefined_p () const { return m_vrange->undefined_p (); }
-  void set_varying (tree type) { m_vrange->set_varying (type); }
+  void set_varying (tree type) { init (type); m_vrange->set_varying (type); }
   void set_undefined () { m_vrange->set_undefined (); }
   bool union_ (const vrange &r) { return m_vrange->union_ (r); }
   bool intersect (const vrange &r) { return m_vrange->intersect (r); }
   bool contains_p (tree cst) const { return m_vrange->contains_p (cst); }
   bool singleton_p (tree *result = NULL) const
     { return m_vrange->singleton_p (result); }
-  void set_zero (tree type) { return m_vrange->set_zero (type); }
-  void set_nonzero (tree type) { return m_vrange->set_nonzero (type); }
+  void set_zero (tree type) { init (type); return m_vrange->set_zero (type); }
+  void set_nonzero (tree type)
+    { init (type); return m_vrange->set_nonzero (type); }
   bool nonzero_p () const { return m_vrange->nonzero_p (); }
   bool zero_p () const { return m_vrange->zero_p (); }
   wide_int lower_bound () const; // For irange/prange comparability.
-- 
2.40.1