]> gcc.gnu.org Git - gcc.git/commitdiff
[range-ops] Remove special case for handling bitmasks in casts.
authorAldy Hernandez <aldyh@redhat.com>
Wed, 26 Jul 2023 09:00:08 +0000 (11:00 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Wed, 26 Jul 2023 11:36:57 +0000 (13:36 +0200)
Now that we can generically handle bitmasks for unary operators,
there's no need to special case them.

gcc/ChangeLog:

* range-op-mixed.h (class operator_cast): Add update_bitmask.
* range-op.cc (operator_cast::update_bitmask): New.
(operator_cast::fold_range): Call update_bitmask.

gcc/range-op-mixed.h
gcc/range-op.cc

index 70550c52232ab4e1766fe085f4b770238fee2828..3cb904f9d80455e7aed73debaad192b0742efa45 100644 (file)
@@ -346,6 +346,8 @@ public:
   relation_kind lhs_op1_relation (const irange &lhs,
                                  const irange &op1, const irange &op2,
                                  relation_kind) const final override;
+  void update_bitmask (irange &r, const irange &lh,
+                      const irange &rh) const final override;
 private:
   bool truncating_cast_p (const irange &inner, const irange &outer) const;
   bool inside_domain_p (const wide_int &min, const wide_int &max,
index 5653ca0d18663aa4f0ab4f568156fa659bb77be9..615e5fe00369dbc1b795b93aec01025713304189 100644 (file)
@@ -2881,24 +2881,17 @@ operator_cast::fold_range (irange &r, tree type ATTRIBUTE_UNUSED,
        return true;
     }
 
-  // Update the bitmask.  Truncating casts are problematic unless
-  // the conversion fits in the resulting outer type.
-  irange_bitmask bm = inner.get_bitmask ();
-  if (truncating_cast_p (inner, outer)
-      && wi::rshift (bm.mask (),
-                    wi::uhwi (TYPE_PRECISION (outer.type ()),
-                              TYPE_PRECISION (inner.type ())),
-                    TYPE_SIGN (inner.type ())) != 0)
-    return true;
-  unsigned prec = TYPE_PRECISION (type);
-  signop sign = TYPE_SIGN (inner.type ());
-  bm = irange_bitmask (wide_int::from (bm.value (), prec, sign),
-                      wide_int::from (bm.mask (), prec, sign));
-  r.update_bitmask (bm);
-
+  update_bitmask (r, inner, outer);
   return true;
 }
 
+void
+operator_cast::update_bitmask (irange &r, const irange &lh,
+                              const irange &rh) const
+{
+  update_known_bitmask (r, CONVERT_EXPR, lh, rh);
+}
+
 bool
 operator_cast::op1_range (irange &r, tree type,
                          const irange &lhs,
This page took 0.087492 seconds and 5 git commands to generate.