[committed] Don't optimize comparison if either operand is a function pointer when target requires function pointer canonicalization

Message ID 56e67c85-065a-3b85-4715-7579896ba2ca@bell.net
State New
Headers show
Series
  • [committed] Don't optimize comparison if either operand is a function pointer when target requires function pointer canonicalization
Related show

Commit Message

John David Anglin Sept. 28, 2018, 11:21 p.m.
This fixes the lack of symmetry in checking for function pointer 
arguments in simple_comparison.
In other places, we check both operands as it is possible one is a void 
pointer.

This only affects 32-bit hppa.

Tested on hppa-unknown-linux-gnu.  Committed to trunk.

Dave

-- 
John David Anglin  dave.anglin@bell.net
2018-09-28  John David Anglin  <danglin@gcc.gnu.org>

	* match.pd (simple_comparison): Don't optimize if either operand is
	a function pointer when target needs function pointer canonicalization.

Patch

Index: match.pd
===================================================================
--- match.pd	(revision 264689)
+++ match.pd	(working copy)
@@ -3558,8 +3558,10 @@ 
        /* Disable this optimization if we're casting a function pointer
 	  type on targets that require function pointer canonicalization.  */
        && !(targetm.have_canonicalize_funcptr_for_compare ()
-	    && POINTER_TYPE_P (TREE_TYPE (@00))
-	    && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@00))))
+	    && ((POINTER_TYPE_P (TREE_TYPE (@00))
+		 && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@00))))
+		|| (POINTER_TYPE_P (TREE_TYPE (@10))
+		    && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@10))))))
        && single_use (@0))
    (if (TYPE_PRECISION (TREE_TYPE (@00)) == TYPE_PRECISION (TREE_TYPE (@0))
 	&& (TREE_CODE (@10) == INTEGER_CST