re PR tree-optimization/88739 (Big-endian union bug)
authorRichard Biener <rguenther@suse.de>
Mon, 28 Jan 2019 08:15:42 +0000 (08:15 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 28 Jan 2019 08:15:42 +0000 (08:15 +0000)
2019-01-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/88739
* tree-cfg.c (verify_types_in_gimple_reference): Verify
BIT_FIELD_REFs only are applied to mode-precision operands
when they are integral.
(verify_gimple_assign_ternary): Likewise for BIT_INSERT_EXPR.
* tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid generating
BIT_FIELD_REFs of non-mode-precision integral operands.

From-SVN: r268332

gcc/ChangeLog
gcc/tree-cfg.c
gcc/tree-ssa-sccvn.c

index eddf1e505231ad377965199bfc8994894db56dab..724d120121112541097b47bb58d65ca1ae2ce5a4 100644 (file)
@@ -1,3 +1,13 @@
+2019-01-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/88739
+       * tree-cfg.c (verify_types_in_gimple_reference): Verify
+       BIT_FIELD_REFs only are applied to mode-precision operands
+       when they are integral.
+       (verify_gimple_assign_ternary): Likewise for BIT_INSERT_EXPR.
+       * tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid generating
+       BIT_FIELD_REFs of non-mode-precision integral operands.
+
 2019-01-27  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/87214
index 6041f4208b07e4a02df63d42001151bcd9f85da8..62254270524116f30776791cb04435b090469a62 100644 (file)
@@ -3118,6 +3118,12 @@ verify_types_in_gimple_reference (tree expr, bool require_lvalue)
                     "match field size of BIT_FIELD_REF");
              return true;
            }
+         if (INTEGRAL_TYPE_P (TREE_TYPE (op))
+             && !type_has_mode_precision_p (TREE_TYPE (op)))
+           {
+             error ("BIT_FIELD_REF of non-mode-precision operand");
+             return true;
+           }
          if (!AGGREGATE_TYPE_P (TREE_TYPE (op))
              && maybe_gt (size + bitpos,
                           tree_to_poly_uint64 (TYPE_SIZE (TREE_TYPE (op)))))
@@ -4319,6 +4325,12 @@ verify_gimple_assign_ternary (gassign *stmt)
          error ("invalid position or size in BIT_INSERT_EXPR");
          return true;
        }
+      if (INTEGRAL_TYPE_P (rhs1_type)
+         && !type_has_mode_precision_p (rhs1_type))
+       {
+         error ("BIT_INSERT_EXPR into non-mode-precision operand");
+         return true;
+       }
       if (INTEGRAL_TYPE_P (rhs1_type))
        {
          unsigned HOST_WIDE_INT bitpos = tree_to_uhwi (rhs3);
index 7e8e05e7af0c2eba47c2abd4d77199a7c7952199..81604d2912a7db05fede7a38a83aeb198e3fc7d5 100644 (file)
@@ -2298,6 +2298,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
       base2 = get_ref_base_and_extent (gimple_assign_lhs (def_stmt),
                                       &offset2, &size2, &maxsize2,
                                       &reverse);
+      tree def_rhs = gimple_assign_rhs1 (def_stmt);
       if (!reverse
          && known_size_p (maxsize2)
          && known_eq (maxsize2, size2)
@@ -2309,11 +2310,13 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
             according to endianness.  */
          && (! INTEGRAL_TYPE_P (vr->type)
              || known_eq (ref->size, TYPE_PRECISION (vr->type)))
-         && multiple_p (ref->size, BITS_PER_UNIT))
+         && multiple_p (ref->size, BITS_PER_UNIT)
+         && (! INTEGRAL_TYPE_P (TREE_TYPE (def_rhs))
+             || type_has_mode_precision_p (TREE_TYPE (def_rhs))))
        {
          gimple_match_op op (gimple_match_cond::UNCOND,
                              BIT_FIELD_REF, vr->type,
-                             vn_valueize (gimple_assign_rhs1 (def_stmt)),
+                             vn_valueize (def_rhs),
                              bitsize_int (ref->size),
                              bitsize_int (offset - offset2));
          tree val = vn_nary_build_or_lookup (&op);