* [PATCH] More frange::set cleanups.
@ 2022-08-02 12:24 Aldy Hernandez
2022-08-02 12:24 ` [PATCH] Limit ranger query in ipa-prop.cc to integrals Aldy Hernandez
2022-08-02 12:24 ` [PATCH] Implement streamer for frange Aldy Hernandez
0 siblings, 2 replies; 3+ messages in thread
From: Aldy Hernandez @ 2022-08-02 12:24 UTC (permalink / raw)
To: GCC patches
Will commit pending a final round of tests.
gcc/ChangeLog:
* value-range.cc (frange::set): Initialize m_props and cleanup.
---
gcc/value-range.cc | 47 +++++++++++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 19 deletions(-)
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index dc06f8b0078..dd5a4303908 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -292,38 +292,47 @@ frange::set (tree min, tree max, value_range_kind kind)
m_kind = kind;
m_type = TREE_TYPE (min);
-
- // Mark NANness.
- if (real_isnan (TREE_REAL_CST_PTR (min))
- || real_isnan (TREE_REAL_CST_PTR (max)))
- {
- gcc_checking_assert (operand_equal_p (min, max));
- m_props.nan_set_yes ();
- }
- else
- m_props.nan_set_no ();
+ m_props.set_varying ();
bool is_min = vrp_val_is_min (min);
bool is_max = vrp_val_is_max (max);
+ bool is_nan = (real_isnan (TREE_REAL_CST_PTR (min))
+ || real_isnan (TREE_REAL_CST_PTR (max)));
- // Mark when the endpoints can't be INF.
- if (!is_min)
- m_props.ninf_set_no ();
- if (!is_max)
- m_props.inf_set_no ();
+ // Ranges with a NAN and a non-NAN endpoint are nonsensical.
+ gcc_checking_assert (!is_nan || operand_equal_p (min, max));
- // Mark when the endpoints are definitely INF.
+ // The properties for singletons can be all set ahead of time.
if (operand_equal_p (min, max))
{
+ // Set INF properties.
if (is_min)
m_props.ninf_set_yes ();
- else if (is_max)
+ else
+ m_props.ninf_set_no ();
+ if (is_max)
m_props.inf_set_yes ();
+ else
+ m_props.inf_set_no ();
+ // Set NAN property.
+ if (is_nan)
+ m_props.nan_set_yes ();
+ else
+ m_props.nan_set_no ();
+ }
+ else
+ {
+ // Mark when the endpoints can't be +-INF.
+ if (!is_min)
+ m_props.ninf_set_no ();
+ if (!is_max)
+ m_props.inf_set_no ();
}
// Check for swapped ranges.
- gcc_checking_assert (m_props.nan_yes_p ()
- || tree_compare (LE_EXPR, min, max));
+ gcc_checking_assert (is_nan || tree_compare (LE_EXPR, min, max));
+
+ normalize_kind ();
if (flag_checking)
verify_range ();
--
2.37.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Limit ranger query in ipa-prop.cc to integrals.
2022-08-02 12:24 [PATCH] More frange::set cleanups Aldy Hernandez
@ 2022-08-02 12:24 ` Aldy Hernandez
2022-08-02 12:24 ` [PATCH] Implement streamer for frange Aldy Hernandez
1 sibling, 0 replies; 3+ messages in thread
From: Aldy Hernandez @ 2022-08-02 12:24 UTC (permalink / raw)
To: GCC patches
ipa-* still works on legacy value_range's which only support
integrals. This patch limits the query to integrals, as to not get a
floating point range that can't exist in an irange.
Will commit pending a final round of tests.
gcc/ChangeLog:
* ipa-prop.cc (ipa_compute_jump_functions_for_edge): Limit ranger
query to integrals.
---
gcc/ipa-prop.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
index fb8f97397dc..ca5b9f31570 100644
--- a/gcc/ipa-prop.cc
+++ b/gcc/ipa-prop.cc
@@ -2303,6 +2303,10 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
{
if (TREE_CODE (arg) == SSA_NAME
&& param_type
+ /* Limit the ranger query to integral types as the rest
+ of this file uses value_range's, which only hold
+ integers and pointers. */
+ && irange::supports_p (TREE_TYPE (arg))
&& get_range_query (cfun)->range_of_expr (vr, arg)
&& !vr.undefined_p ())
{
--
2.37.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Implement streamer for frange.
2022-08-02 12:24 [PATCH] More frange::set cleanups Aldy Hernandez
2022-08-02 12:24 ` [PATCH] Limit ranger query in ipa-prop.cc to integrals Aldy Hernandez
@ 2022-08-02 12:24 ` Aldy Hernandez
1 sibling, 0 replies; 3+ messages in thread
From: Aldy Hernandez @ 2022-08-02 12:24 UTC (permalink / raw)
To: GCC patches
This patch Allows us to export floating point ranges into the SSA name
(SSA_NAME_RANGE_INFO).
[Richi, in PR24021 you suggested that match.pd could use global float
ranges, because it would generally not invoke ranger. This patch
implements the boiler plate to save the frange globally.]
[Jeff, we've also been talking in parallel of using NAN knowledge
during expansion to RTL. This patch will provide the NAN bits in the
SSA name.]
Since frange's currently implementation is just a shell, with no
actual endpoints, frange_storage_slot only contains frange_props which
fits inside a byte. When we have endpoints, y'all can decide if it's
worth saving them, or if the NAN/etc bits are good enough.
I've tested this on my branch which has FP-ranger enabled. I will
commit once I do a final round of testing on vanilla trunk.
gcc/ChangeLog:
* tree-core.h (struct tree_ssa_name): Add frange_info and
reshuffle the rest.
* value-range-storage.cc (vrange_storage::alloc_slot): Add case
for frange.
(vrange_storage::set_vrange): Same.
(vrange_storage::get_vrange): Same.
(vrange_storage::fits_p): Same.
(frange_storage_slot::alloc_slot): New.
(frange_storage_slot::set_frange): New.
(frange_storage_slot::get_frange): New.
(frange_storage_slot::fits_p): New.
* value-range-storage.h (class frange_storage_slot): New.
---
gcc/tree-core.h | 12 ++++----
gcc/value-range-storage.cc | 61 +++++++++++++++++++++++++++++++++++++-
gcc/value-range-storage.h | 19 ++++++++++++
3 files changed, 85 insertions(+), 7 deletions(-)
diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index ea9f281f1cc..86a07c282af 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -1589,17 +1589,17 @@ struct GTY(()) tree_ssa_name {
/* Value range information. */
union ssa_name_info_type {
+ /* Ranges for integers. */
+ struct GTY ((tag ("0"))) irange_storage_slot *irange_info;
+ /* Ranges for floating point numbers. */
+ struct GTY ((tag ("1"))) frange_storage_slot *frange_info;
/* Pointer attributes used for alias analysis. */
- struct GTY ((tag ("0"))) ptr_info_def *ptr_info;
+ struct GTY ((tag ("2"))) ptr_info_def *ptr_info;
/* This holds any range info supported by ranger (except ptr_info
above) and is managed by vrange_storage. */
void * GTY ((skip)) range_info;
- /* GTY tag when the range in the range_info slot above satisfies
- irange::supports_type_p. */
- struct GTY ((tag ("1"))) irange_storage_slot *irange_info;
} GTY ((desc ("%1.typed.type ?" \
- "!POINTER_TYPE_P (TREE_TYPE ((tree)&%1)) : 2"))) info;
-
+ "(POINTER_TYPE_P (TREE_TYPE ((tree)&%1)) ? 2 : SCALAR_FLOAT_TYPE_P (TREE_TYPE ((tree)&%1))) : 3"))) info;
/* Immediate uses list for this SSA_NAME. */
struct ssa_use_operand_t imm_uses;
};
diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc
index 8b5ab544ce3..ea3b83ca641 100644
--- a/gcc/value-range-storage.cc
+++ b/gcc/value-range-storage.cc
@@ -40,7 +40,8 @@ vrange_storage::alloc_slot (const vrange &r)
if (is_a <irange> (r))
return irange_storage_slot::alloc_slot (*m_alloc, as_a <irange> (r));
-
+ if (is_a <frange> (r))
+ return frange_storage_slot::alloc_slot (*m_alloc, as_a <frange> (r));
return NULL;
}
@@ -55,6 +56,12 @@ vrange_storage::set_vrange (void *slot, const vrange &r)
gcc_checking_assert (s->fits_p (as_a <irange> (r)));
s->set_irange (as_a <irange> (r));
}
+ else if (is_a <frange> (r))
+ {
+ frange_storage_slot *s = static_cast <frange_storage_slot *> (slot);
+ gcc_checking_assert (s->fits_p (as_a <frange> (r)));
+ s->set_frange (as_a <frange> (r));
+ }
else
gcc_unreachable ();
}
@@ -70,6 +77,12 @@ vrange_storage::get_vrange (const void *slot, vrange &r, tree type)
= static_cast <const irange_storage_slot *> (slot);
s->get_irange (as_a <irange> (r), type);
}
+ else if (is_a <frange> (r))
+ {
+ const frange_storage_slot *s
+ = static_cast <const frange_storage_slot *> (slot);
+ s->get_frange (as_a <frange> (r), type);
+ }
else
gcc_unreachable ();
}
@@ -85,6 +98,12 @@ vrange_storage::fits_p (const void *slot, const vrange &r)
= static_cast <const irange_storage_slot *> (slot);
return s->fits_p (as_a <irange> (r));
}
+ if (is_a <frange> (r))
+ {
+ const frange_storage_slot *s
+ = static_cast <const frange_storage_slot *> (slot);
+ return s->fits_p (as_a <frange> (r));
+ }
gcc_unreachable ();
return false;
}
@@ -215,3 +234,43 @@ debug (const irange_storage_slot &storage)
storage.dump ();
fprintf (stderr, "\n");
}
+
+// Implementation of frange_storage_slot.
+
+frange_storage_slot *
+frange_storage_slot::alloc_slot (vrange_allocator &allocator, const frange &r)
+{
+ size_t size = sizeof (frange_storage_slot);
+ frange_storage_slot *p
+ = static_cast <frange_storage_slot *> (allocator.alloc (size));
+ new (p) frange_storage_slot (r);
+ return p;
+}
+
+void
+frange_storage_slot::set_frange (const frange &r)
+{
+ gcc_checking_assert (fits_p (r));
+ gcc_checking_assert (!r.undefined_p ());
+
+ m_props = r.m_props;
+}
+
+void
+frange_storage_slot::get_frange (frange &r, tree type) const
+{
+ gcc_checking_assert (r.supports_type_p (type));
+
+ r.set_varying (type);
+ r.m_props = m_props;
+ r.normalize_kind ();
+
+ if (flag_checking)
+ r.verify_range ();
+}
+
+bool
+frange_storage_slot::fits_p (const frange &) const
+{
+ return true;
+}
diff --git a/gcc/value-range-storage.h b/gcc/value-range-storage.h
index 5a3336b673b..3fac5ea2f86 100644
--- a/gcc/value-range-storage.h
+++ b/gcc/value-range-storage.h
@@ -100,6 +100,25 @@ private:
trailing_wide_ints<MAX_INTS> m_ints;
};
+// A chunk of memory to store an frange to long term memory.
+
+class GTY (()) frange_storage_slot
+{
+ public:
+ static frange_storage_slot *alloc_slot (vrange_allocator &, const frange &r);
+ void set_frange (const frange &r);
+ void get_frange (frange &r, tree type) const;
+ bool fits_p (const frange &) const;
+ private:
+ frange_storage_slot (const frange &r) { set_frange (r); }
+ DISABLE_COPY_AND_ASSIGN (frange_storage_slot);
+
+ // We can get away with just storing the properties because the type
+ // can be gotten from the SSA, and UNDEFINED is unsupported, so it
+ // can only be a range.
+ frange_props m_props;
+};
+
class obstack_vrange_allocator : public vrange_allocator
{
public:
--
2.37.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-02 12:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02 12:24 [PATCH] More frange::set cleanups Aldy Hernandez
2022-08-02 12:24 ` [PATCH] Limit ranger query in ipa-prop.cc to integrals Aldy Hernandez
2022-08-02 12:24 ` [PATCH] Implement streamer for frange Aldy Hernandez
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).