From patchwork Fri Jul 29 14:32:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 73040 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1421761qga; Fri, 29 Jul 2016 07:33:14 -0700 (PDT) X-Received: by 10.66.172.237 with SMTP id bf13mr70322120pac.42.1469802794150; Fri, 29 Jul 2016 07:33:14 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id v187si18705145pfb.258.2016.07.29.07.33.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jul 2016 07:33:14 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-432772-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-432772-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-432772-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=Vb2C5C8u6//igaw oMrIjoRGgOJhefYStDdj9ziOBPgV2jwgh5ig9NdKaYC56xeJYd4yhu1ZrZ7qB/vk YjZXEszBtpQZZeSZSARmCqMnzzWfxlfKewt8/ZdH1LVVKI/mdXDxnyu8LoJsdAS2 lc0M69waT3GhA/BydAgoGv612M3s= 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=50sUlvcxc/HT5/p4ReQ1n GfH8rM=; b=Igmzw6M9XTWLw3MNk9+t/XYbWuRMXAEBBvbjWEa3olm9HH9mhn0cJ gurbSKyOdad2VjqG1tjcghp9dnt7ioRX+xGHgQXpnLOZBIvgi/Pt/FGMcfQ3YdwH mWciWtvPbaZTUozKfGOXnD9ntAvxlqs/AeATQa7gRAVhet+NAYerpo= Received: (qmail 76943 invoked by alias); 29 Jul 2016 14:32:59 -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 76906 invoked by uid 89); 29 Jul 2016 14:32:59 -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=anonymous X-HELO: mail-io0-f180.google.com Received: from mail-io0-f180.google.com (HELO mail-io0-f180.google.com) (209.85.223.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 29 Jul 2016 14:32:43 +0000 Received: by mail-io0-f180.google.com with SMTP id m101so130141488ioi.2 for ; Fri, 29 Jul 2016 07:32:43 -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=6BSbPKdBsk2PEPxcM0r4/mo/ntHF5Qfo6B8ecnUIQF8=; b=ajetJWbqQpfPr2e343zxFzW0DI2pD5IDWDG+mMdJxSquWtmxfXocJyy2d4H/03IYx/ cU3JRq1f8dg4Lm+uP7O+F/LoFxz8kpq+GdV9LKX7ufhnCoEkq//k2aQ0c4eFTbTsvzHD XP0xH+86/7LNoMUGxdJeqbf0MnzHKgsZEDbWa92LU3fjgshxXT+Oqo2joyyH943IAw16 8M+jm18y70HTyR/I6WStY86QkDItCURuTPdPY0Jhnl2AF8RMqE+L+gVhmIDe0ABScqVs /GOkXaCZmEcnKj/+V6t34Wk8onF09gIEGm11zjO0K5dsrsLjiIpBSFvDAMLM7UbDJLM4 8Jiw== X-Gm-Message-State: AEkoouu/GZ3d1o9VIFsmc51PpulvK4OiyKV87uJFXtCIcQwEpiygNr27txXiFQVEJeOwDxccT2P3gA5Pzzpbg4ki X-Received: by 10.107.175.27 with SMTP id y27mr49977947ioe.137.1469802761097; Fri, 29 Jul 2016 07:32:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.48.197 with HTTP; Fri, 29 Jul 2016 07:32:40 -0700 (PDT) In-Reply-To: References: From: Prathamesh Kulkarni Date: Fri, 29 Jul 2016 20:02:40 +0530 Message-ID: Subject: Re: [PR70920] transform (intptr_t) x eq/ne CST to x eq/ne (typeof x) cst To: Richard Biener Cc: Andreas Schwab , gcc Patches X-IsSubscribed: yes On 29 July 2016 at 12:42, Richard Biener wrote: > On Fri, 29 Jul 2016, Prathamesh Kulkarni wrote: > >> On 28 July 2016 at 19:18, Richard Biener wrote: >> > On Thu, 28 Jul 2016, Prathamesh Kulkarni wrote: >> > >> >> On 28 July 2016 at 15:58, Andreas Schwab wrote: >> >> > On Mo, Jul 25 2016, Prathamesh Kulkarni wrote: >> >> > >> >> >> diff --git a/gcc/testsuite/gcc.dg/pr70920-4.c b/gcc/testsuite/gcc.dg/pr70920-4.c >> >> >> new file mode 100644 >> >> >> index 0000000..dedb895 >> >> >> --- /dev/null >> >> >> +++ b/gcc/testsuite/gcc.dg/pr70920-4.c >> >> >> @@ -0,0 +1,21 @@ >> >> >> +/* { dg-do compile } */ >> >> >> +/* { dg-options "-O2 -fdump-tree-ccp-details -Wno-int-to-pointer-cast" } */ >> >> >> + >> >> >> +#include >> >> >> + >> >> >> +void f1(); >> >> >> +void f2(); >> >> >> + >> >> >> +void >> >> >> +foo (int a) >> >> >> +{ >> >> >> + void *cst = 0; >> >> >> + if ((int *) a == cst) >> >> >> + { >> >> >> + f1 (); >> >> >> + if (a) >> >> >> + f2 (); >> >> >> + } >> >> >> +} >> >> >> + >> >> >> +/* { dg-final { scan-tree-dump "gimple_simplified to if \\(_\[0-9\]* == 0\\)" "ccp1" } } */ >> >> > >> >> > This fails on all ilp32 platforms. >> >> Oops, sorry for the breakage. >> >> With -m32, the pattern is applied during forwprop1 rather than ccp1. >> >> I wonder though why ccp1 fails to fold the pattern with -m32 ? >> >> Looking at the dumps: >> >> >> >> without -m32: >> >> input to ccp1 pass: >> >> : >> >> cst_4 = 0B; >> >> _1 = (long int) a_5(D); >> >> _2 = (void *) _1; >> >> if (cst_4 == _2) >> >> goto ; >> >> else >> >> goto ; >> >> >> >> cc1 pass dump shows: >> >> Substituting values and folding statements >> >> >> >> Folding statement: _1 = (long int) a_5(D); >> >> Not folded >> >> Folding statement: _2 = (void *) _1; >> >> Not folded >> >> Folding statement: if (cst_4 == _2) >> >> which is likely CONSTANT >> >> Applying pattern match.pd:2537, gimple-match.c:6530 >> >> gimple_simplified to if (_1 == 0) >> >> Folded into: if (_1 == 0) >> >> >> >> with -m32: >> >> input to ccp1 pass: >> >> : >> >> cst_3 = 0B; >> >> a.0_1 = (void *) a_4(D); >> >> if (cst_3 == a.0_1) >> >> goto ; >> >> else >> >> goto ; >> >> >> >> ccp1 pass dump shows: >> >> Substituting values and folding statements >> >> >> >> Folding statement: a.0_1 = (void *) a_4(D); >> >> Not folded >> >> Folding statement: if (cst_3 == a.0_1) >> >> which is likely CONSTANT >> >> Folded into: if (a.0_1 == 0B) >> >> >> >> I am not able to understand why it doesn't fold it to >> >> if (a_4(D) == 0) ? >> >> forwprop1 folds a.0_1 == 0B to a_4(D) == 0. >> > >> > It's because CCP folds with follow-single-use edges but the >> > match-and-simplify code uses a single callback to valueize and >> > decide whether its valid to follow the SSA edge. I did have some >> > old patches trying to fix that but never followed up on those. >> Thanks for the explanation. >> > >> >> I suppose the test-case would need to scan ccp1 for non-ilp targets >> >> and forwprop1 for >> >> ilp targets. How do update the test-case to reflect this ? >> > >> > It's simpler to verify that at some point (forwprop) we have the >> > expected IL rather than testing for the match debug prints. >> In forwprop dump, >> For m32, we have if (a_4(D) == 0) >> and without m32: if (_1 == 0) >> So need to match either a default def or anonymous name >> in the test-case, which I am having a bit of trouble writing regex for. >> In the patch i simply chose to match "== 0\\)", not sure if that's a good idea. >> Also how do I update the test-case so that it gets tested twice, once with -m32 >> and once without ? > > I don't think just matching == 0 is a good idea. I suggest to > restrict the testcase to lp64 targets and maybe add a ilp32 variant. Hi, I restricted the test-case to lp64 targets. Is this OK to commit ? Thanks, Prathamesh > > Richard. > >> Thanks, >> Prathamesh >> > >> > Richard. >> > >> >> Thanks, >> >> Prathamesh >> >> > >> >> > Andreas. >> >> > >> >> > -- >> >> > Andreas Schwab, SUSE Labs, schwab@suse.de >> >> > GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 >> >> > "And now for something completely different." >> >> >> >> >> > >> > -- >> > Richard Biener >> > SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg) >> > > -- > Richard Biener > SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg) 2016-07-29 Prathamesh Kulkarni testsuite/ gcc.dg/pr70920-4.c: Restrict to lp64 targets and make scan-tree-dump to scan forwprop1 dump pass. diff --git a/gcc/testsuite/gcc.dg/pr70920-4.c b/gcc/testsuite/gcc.dg/pr70920-4.c index dedb895..ab2748b 100644 --- a/gcc/testsuite/gcc.dg/pr70920-4.c +++ b/gcc/testsuite/gcc.dg/pr70920-4.c @@ -1,5 +1,6 @@ +/* { dg-require-effective-target lp64 } */ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-ccp-details -Wno-int-to-pointer-cast" } */ +/* { dg-options "-O2 -fdump-tree-forwprop-details -Wno-int-to-pointer-cast" } */ #include @@ -18,4 +19,4 @@ foo (int a) } } -/* { dg-final { scan-tree-dump "gimple_simplified to if \\(_\[0-9\]* == 0\\)" "ccp1" } } */ +/* { dg-final { scan-tree-dump "if \\(_\[0-9\]* == 0\\)" "forwprop1" } } */