From patchwork Thu Aug 4 19:21:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 73304 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1556122qga; Thu, 4 Aug 2016 12:21:55 -0700 (PDT) X-Received: by 10.66.131.48 with SMTP id oj16mr5469790pab.126.1470338515200; Thu, 04 Aug 2016 12:21:55 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id h5si15987880pfj.2.2016.08.04.12.21.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 12:21:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-433255-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-433255-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-433255-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; q=dns; s=default; b=OHGF5ab9l/hGgf9 e93eV6yiTJKSEjuySnbF38/CHC70L6xvqe+N5T7/QyWZpwc7CkWyAYC2JnmhA/cT jy5DcVn+8RL0vB3kbHr7nFKw15ykC7L9JR3o7RQoeC5lQ3rgSrhGoJWj8VmXWMQ+ YwDDLsH+1Gd6dCxWifb2/e4fdkOA= 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 :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; s=default; bh=YjQGJBuhiSCKYu0uTIeOt DeICp8=; b=rUUlNNn3/hqeiz+0cS7zO4dw63Fu9WE23OyFDlIMGF3OsUa/Ac3Mk w50H+dAU/lPz+OQhIi0SwHmvAH9WSrPYe4mYp9Nvut2McT4O5EJ+6RQWpQUPxxpi 2iwqijV/nPfg7sgVwPdVrBe+ynJiO+b/amoi1NnceIPc5y0nGFvpuA= Received: (qmail 74429 invoked by alias); 4 Aug 2016 19:21:40 -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 74412 invoked by uid 89); 4 Aug 2016 19:21:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=2016-08-05, 20160805 X-HELO: mail-it0-f43.google.com Received: from mail-it0-f43.google.com (HELO mail-it0-f43.google.com) (209.85.214.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 04 Aug 2016 19:21:29 +0000 Received: by mail-it0-f43.google.com with SMTP id j124so4663882ith.1 for ; Thu, 04 Aug 2016 12:21:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=LTMpFEUdjhdsB4Y6vnd0jeUf1Y7krNWtgwPliClABCw=; b=FjBeBq/qWOZCQAVTmx4fjx9n2uFTUtV+wq2j8KNMfti/6yZztVlhT6iSE8y45uBvtb LFBm3f/Yz3ikCWZog5H4A/rcmBgmuoDGGgPkXQx2O48GBPL+ZYjeN6yYSoc7As5DLa1l 52L8W5wxnMej+m5uFs+kWafBeTE5737QV/xdBsSH7WjAzV5bWL5jyqOiMslGDkIeTJzX CDkbGIjFoJNS3L4ptHiCP2hgbIGspkgm0o/G0aCrvTs49hyK2bHw0qKletyDp4win4U6 OlJwkh0MM6G/CLwUQCkj4QSavIhJG6rfqLUfX04T9r5Na0Q8Up15PWZM4m9zjZbcQNGV JHvA== X-Gm-Message-State: AEkooutqz/1dbjxm2hSvAe5NoNmbe3YjCHKjOajcZb563FPUchF5yUvhXhYawZRy8cPXIlADVwO/7rTDeR/V6ecY X-Received: by 10.36.225.134 with SMTP id n128mr4968046ith.16.1470338487108; Thu, 04 Aug 2016 12:21:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.208.18 with HTTP; Thu, 4 Aug 2016 12:21:26 -0700 (PDT) In-Reply-To: References: From: Prathamesh Kulkarni Date: Fri, 5 Aug 2016 00:51:26 +0530 Message-ID: Subject: Re: fix fallout of pr22051-2.c on arm To: Richard Biener Cc: Matthew Wahab , gcc Patches X-IsSubscribed: yes On 4 August 2016 at 12:39, Richard Biener wrote: > On Thu, 4 Aug 2016, Prathamesh Kulkarni wrote: > >> Hi, >> The attached patch fixes pr22051-2.c which regressed due to >> r238754. Matthew, could you please confirm if this patch fixes the >> test-case for you ? >> >> Bootstrapped and tested on x86_64-unknown-linux-gnu. >> Cross tested on arm*-*-*. >> OK for trunk ? > > Note that if function pointer types are really the issue then > you also need to handle METHOD_TYPE, thus sth like > > && ! FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@0)) > > please also add a comment for this non-obvious thing. I believe > we should simply apply function pointer canonicalization for > comparisons early during gimplification - exposing this target > detail only during RTL expansion makes generic optimization hard. > > Ok with those changes. Is the attached version OK ? Bootstrapped on x86_64-unknown-linux-gnu, cross-tested on arm*-*-*. Thanks, Prathamesh > > Thanks, > Richard. 2016-08-05 Prathamesh Kulkarni * match.pd ((intptr_t) x eq/ne CST to x eq/ne (typeof x) cst): Disable transform if operand's type is pointer to function or method. diff --git a/gcc/match.pd b/gcc/match.pd index 2380d90..ac7cfff 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2528,12 +2528,18 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) { neeq == EQ_EXPR ? boolean_false_node : boolean_true_node; }))) /* PR70920: Transform (intptr_t)x eq/ne CST to x eq/ne (typeof x) CST. - and (typeof ptr_cst) x eq/ne ptr_cst to x eq/ne (typeof x) CST */ + and (typeof ptr_cst) x eq/ne ptr_cst to x eq/ne (typeof x) CST. + Disable the transform if either operand is pointer to function. + This broke pr22051-2.c for arm where function pointer + canonicalizaion is not wanted. */ + (for cmp (ne eq) (simplify (cmp (convert @0) INTEGER_CST@1) - (if ((POINTER_TYPE_P (TREE_TYPE (@0)) && INTEGRAL_TYPE_P (TREE_TYPE (@1))) - || (INTEGRAL_TYPE_P (TREE_TYPE (@0)) && POINTER_TYPE_P (TREE_TYPE (@1)))) + (if ((POINTER_TYPE_P (TREE_TYPE (@0)) && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@0))) + && INTEGRAL_TYPE_P (TREE_TYPE (@1))) + || (INTEGRAL_TYPE_P (TREE_TYPE (@0)) && POINTER_TYPE_P (TREE_TYPE (@1)) + && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@1))))) (cmp @0 (convert @1))))) /* Non-equality compare simplifications from fold_binary */