From patchwork Fri Sep 14 23:44:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 970141 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-485699-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bell.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="EGeLzqY2"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42BsYl0LV4z9s8F for ; Sat, 15 Sep 2018 09:44:23 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:cc:message-id:date:mime-version:content-type; q= dns; s=default; b=cTwvSFlKuaYcIYSFnkT1ZkXYYe14hat1cXg9xIC/FGWolr RtjovpfgR+dHXC8nm7yVfl7e/I967YszGwZXxaPLlv9jFX8GX/b25R2qUQn31Q3g Wi56us0x0Yn/wxSe5zbEtcJJfxWROjsyAH+efHXYXjgP1QV40wIGuSWyrDqrk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:cc:message-id:date:mime-version:content-type; s= default; bh=MkHSoKJwwRtagj2PPn/UkXF5J4E=; b=EGeLzqY2CEanSijELEWB 18iWFBgOu7pTKiz194F4S3BOU4lI/Bmy4REA1JnuG/V7Vo8pOxps8Nybn0ZToxda twpnnUb3LDYm47qeTq07FYI93jxsnj1wGL2p13/UjTL22mTxo7O+g2x5gNYYFy4R jO8MROt0K8oGl/B5jSQ8XHY= Received: (qmail 110181 invoked by alias); 14 Sep 2018 23:44:15 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 110165 invoked by uid 89); 14 Sep 2018 23:44:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy=UD:have_canonicalize_funcptr_for_compare, sk:noncano, UD:targetm.have_canonicalize_funcptr_for_compare, 17564 X-HELO: mtlfep02.bell.net Received: from belmont80srvr.owm.bell.net (HELO mtlfep02.bell.net) (184.150.200.80) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Sep 2018 23:44:12 +0000 Received: from bell.net mtlfep02 184.150.200.30 by mtlfep02.bell.net with ESMTP id <20180914234410.DVRO22569.mtlfep02.bell.net@mtlspm01.bell.net> for ; Fri, 14 Sep 2018 19:44:10 -0400 Received: from [192.168.2.49] (really [70.53.62.196]) by mtlspm01.bell.net with ESMTP id <20180914234410.JKLP28394.mtlspm01.bell.net@[192.168.2.49]>; Fri, 14 Sep 2018 19:44:10 -0400 To: GCC Patches From: John David Anglin Subject: [committed] hppa: Fix canonicalize of method and void pointers in comparison operations Cc: Helge Deller , Matthias Klose , Mattias Ellert Message-ID: Date: Fri, 14 Sep 2018 19:44:08 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 The attached change fixes the canonicalization of method and void pointers in comparisons against another method or function pointer on 32-bit hppa targets.  As far as I know, 32-bit hppa is the only architecture that requires function pointer canonicalization due to lazy binding. Tested on hppa2.0w-hp-hpux11.11 and hppa-unknown-linux-gnu, GCC trunk and 8.  Committed to trunk and gcc-8 branch. Dave Index: dojump.c =================================================================== --- dojump.c (revision 264245) +++ dojump.c (working copy) @@ -1214,15 +1214,15 @@ code = unsignedp ? unsigned_code : signed_code; /* If function pointers need to be "canonicalized" before they can - be reliably compared, then canonicalize them. - Only do this if *both* sides of the comparison are function pointers. - If one side isn't, we want a noncanonicalized comparison. See PR - middle-end/17564. */ + be reliably compared, then canonicalize them. Canonicalize the + expression when one of the operands is a function pointer. This + handles the case where the other operand is a void pointer. See + PR middle-end/17564. */ if (targetm.have_canonicalize_funcptr_for_compare () - && POINTER_TYPE_P (TREE_TYPE (treeop0)) - && POINTER_TYPE_P (TREE_TYPE (treeop1)) - && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (treeop0))) - && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (treeop1)))) + && ((POINTER_TYPE_P (TREE_TYPE (treeop0)) + && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (treeop0)))) + || (POINTER_TYPE_P (TREE_TYPE (treeop1)) + && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (treeop1)))))) { rtx new_op0 = gen_reg_rtx (mode); rtx new_op1 = gen_reg_rtx (mode); Index: expr.c =================================================================== --- expr.c (revision 264245) +++ expr.c (working copy) @@ -11532,12 +11532,10 @@ /* We won't bother with store-flag operations involving function pointers when function pointers must be canonicalized before comparisons. */ if (targetm.have_canonicalize_funcptr_for_compare () - && ((TREE_CODE (TREE_TYPE (arg0)) == POINTER_TYPE - && (TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) - == FUNCTION_TYPE)) - || (TREE_CODE (TREE_TYPE (arg1)) == POINTER_TYPE - && (TREE_CODE (TREE_TYPE (TREE_TYPE (arg1))) - == FUNCTION_TYPE)))) + && ((POINTER_TYPE_P (TREE_TYPE (arg0)) + && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (arg0)))) + || (POINTER_TYPE_P (TREE_TYPE (arg1)) + && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (arg1)))))) return 0; STRIP_NOPS (arg0); Index: fold-const.c =================================================================== --- fold-const.c (revision 264245) +++ fold-const.c (working copy) @@ -4922,8 +4922,8 @@ /* Disable this optimization for function pointer expressions on targets that require function pointer canonicalization. */ if (targetm.have_canonicalize_funcptr_for_compare () - && TREE_CODE (etype) == POINTER_TYPE - && TREE_CODE (TREE_TYPE (etype)) == FUNCTION_TYPE) + && POINTER_TYPE_P (etype) + && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (etype))) return NULL_TREE; if (! in_p) Index: match.pd =================================================================== --- match.pd (revision 264245) +++ match.pd (working copy) @@ -3462,8 +3462,8 @@ /* Disable this optimization if we're casting a function pointer type on targets that require function pointer canonicalization. */ && !(targetm.have_canonicalize_funcptr_for_compare () - && TREE_CODE (TREE_TYPE (@00)) == POINTER_TYPE - && TREE_CODE (TREE_TYPE (TREE_TYPE (@00))) == FUNCTION_TYPE) + && POINTER_TYPE_P (TREE_TYPE (@00)) + && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@00)))) && single_use (@0)) (if (TYPE_PRECISION (TREE_TYPE (@00)) == TYPE_PRECISION (TREE_TYPE (@0)) && (TREE_CODE (@10) == INTEGER_CST