Adjust integer <-> pointer conversion IL checking
authorRichard Biener <rguenther@suse.de>
Tue, 14 Jan 2020 09:42:47 +0000 (10:42 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 6 May 2020 06:41:17 +0000 (08:41 +0200)
The existing check doesn't reflect the actual reason why it exists,
the patch makes us to use POINTERS_EXTEND_UNSIGNED instead which
is specified for ptr_mode and word_mode/Pmode precision.

2020-05-06  Richard Biener  <rguenther@suse.de>

* tree-cfg.c (verify_gimple_assign_unary): Adjust integer
to/from pointer conversion checking.

gcc/ChangeLog
gcc/tree-cfg.c

index 15ac1c3c4df634ec1ef2f9d7ef7a06c04ec3fafc..628008833b9dbe89be02c37bc0e2829b69bf5164 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-06  Richard Biener  <rguenther@suse.de>
+
+       * tree-cfg.c (verify_gimple_assign_unary): Adjust integer
+       to/from pointer conversion checking.
+
 2020-05-05  Michael Meissner  <meissner@linux.ibm.com>
 
        * config/rs6000/rs6000-builtin.def: Delete changes meant for a
index b21ef0eee371f84e33f26be514c692ba78703503..8e6fed876f503ae7091e22f0d683a77a3f3a0514 100644 (file)
@@ -3591,13 +3591,21 @@ verify_gimple_assign_unary (gassign *stmt)
        /* Allow conversions from pointer type to integral type only if
           there is no sign or zero extension involved.
           For targets were the precision of ptrofftype doesn't match that
-          of pointers we need to allow arbitrary conversions to ptrofftype.  */
+          of pointers we allow conversions to types where
+          POINTERS_EXTEND_UNSIGNED specifies how that works.  */
        if ((POINTER_TYPE_P (lhs_type)
             && INTEGRAL_TYPE_P (rhs1_type))
            || (POINTER_TYPE_P (rhs1_type)
                && INTEGRAL_TYPE_P (lhs_type)
                && (TYPE_PRECISION (rhs1_type) >= TYPE_PRECISION (lhs_type)
-                   || ptrofftype_p (lhs_type))))
+#if defined(POINTERS_EXTEND_UNSIGNED)
+                   || (TYPE_MODE (rhs1_type) == ptr_mode
+                       && (TYPE_PRECISION (lhs_type)
+                             == BITS_PER_WORD /* word_mode */
+                           || (TYPE_PRECISION (lhs_type)
+                                 == GET_MODE_PRECISION (Pmode))))
+#endif
+                  )))
          return false;
 
        /* Allow conversion from integral to offset type and vice versa.  */