]> gcc.gnu.org Git - gcc.git/commitdiff
Add global setter for value/mask pair for SSA names.
authorAldy Hernandez <aldyh@redhat.com>
Sun, 16 Jul 2023 18:44:02 +0000 (20:44 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Mon, 17 Jul 2023 07:17:59 +0000 (09:17 +0200)
This patch provides a way to set the value/mask pair of known bits
globally, similarly to how we can use set_nonzero_bits for known 0
bits.  This can then be used by CCP and IPA to set value/mask info
instead of throwing away the known 1 bits.

In further clean-ups, I will see if it makes sense to remove
set_nonzero_bits altogether, since it is subsumed by value/mask.

gcc/ChangeLog:

* tree-ssanames.cc (set_bitmask): New.
* tree-ssanames.h (set_bitmask): New.

gcc/tree-ssanames.cc
gcc/tree-ssanames.h

index 5fdb6a37e9fa2b538d8d8a5fb26e365a8071677f..f54394363a03d177bd52dcbbd0785d3b5e78ddea 100644 (file)
@@ -465,6 +465,21 @@ set_nonzero_bits (tree name, const wide_int &mask)
   set_range_info (name, r);
 }
 
+/* Update the known bits of NAME.
+
+   Zero bits in MASK cover constant values.  Set bits in MASK cover
+   unknown values.  VALUE are the known bits.  */
+
+void
+set_bitmask (tree name, const wide_int &value, const wide_int &mask)
+{
+  gcc_assert (!POINTER_TYPE_P (TREE_TYPE (name)));
+
+  int_range<2> r (TREE_TYPE (name));
+  r.update_bitmask (irange_bitmask (value, mask));
+  set_range_info (name, r);
+}
+
 /* Return a widest_int with potentially non-zero bits in SSA_NAME
    NAME, the constant for INTEGER_CST, or -1 if unknown.  */
 
index f3fa609208a775ec0b9e0da40511325b0c6929e9..b5e3f228ee8e96fe4b1b4a2e2f3f0d267e551586 100644 (file)
@@ -59,6 +59,7 @@ struct GTY(()) ptr_info_def
 /* Sets the value range to SSA.  */
 extern bool set_range_info (tree, const vrange &);
 extern void set_nonzero_bits (tree, const wide_int &);
+extern void set_bitmask (tree, const wide_int &value, const wide_int &mask);
 extern wide_int get_nonzero_bits (const_tree);
 extern bool ssa_name_has_boolean_range (tree);
 extern void init_ssanames (struct function *, int);
This page took 0.065954 seconds and 5 git commands to generate.