https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88775

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I get pretty much the same thing with:
--- gcc/match.pd.jj     2019-01-07 17:59:24.100931144 +0100
+++ gcc/match.pd        2019-01-10 14:45:31.870509916 +0100
@@ -1660,6 +1660,19 @@ (define_operator_list COND_TERNARY
   (if (TREE_INT_CST_LOW (@1) & 1)
    { constant_boolean_node (cmp == NE_EXPR, type); })))

+/* Turn (uintptr_t) ptr1 != (uintptr_t) ptr2 comparison into just
+   ptr1 != ptr2.  Don't do that for non-equality comparisons.  */
+(for cmp (eq ne)
+ (simplify
+  (cmp (convert@2 @0) (convert @1))
+  (if (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@2))
+       && POINTER_TYPE_P (TREE_TYPE (@0))
+       && POINTER_TYPE_P (TREE_TYPE (@1))
+       && TYPE_PRECISION (TREE_TYPE (@2)) >= TYPE_PRECISION (TREE_TYPE (@0))
+       && ((GIMPLE && types_compatible_p (TREE_TYPE (@0), TREE_TYPE (@1)))
+          || (GENERIC && TREE_TYPE (@0) == TREE_TYPE (@1))))
+   (cmp @0 @1))))
+
 /* Arguments on which one can call get_nonzero_bits to get the bits
    possibly set.  */
 (match with_possible_nonzero_bits

(well, even without the (unsigned long) casts).  Isn't this better or do we
want both patches?

Reply via email to