From patchwork Fri Jul 29 01:01:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 73015 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1122982qga; Thu, 28 Jul 2016 18:01:35 -0700 (PDT) X-Received: by 10.98.9.194 with SMTP id 63mr64244921pfj.56.1469754095731; Thu, 28 Jul 2016 18:01:35 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id wm7si15153876pac.130.2016.07.28.18.01.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 18:01:35 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-432735-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-432735-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-432735-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=ICf74kjU9bZPQI+ 9WXESYqS5Fx7Lp+tq9WbktXVzKH+eGB5l1LmHi1lr4fFM+9zZaGEduC73VR3NX6j CA/X3G8Fdch9NCiE/h8uu5lFrajWiOW84H3Hi+WePiFLq8HFuxCXQJMbAyxm24JX jg0hNN+5kyWr6MkoMOwIjWsCbIeY= 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=eGzdzW1joYwPF6Lb/mDv/ v4qiGI=; b=FAU8BrKQy0hXlAsEZSfmsvn3JfyMakv5hEaGqLyYXEbz2UyDw6Rv5 2RDSa3kg/Qyh55Q5qDv1yUXhe8FPLylj5DIxAK4Gfwuhf2ZFt8MJOHhrzEiijKBq zuj6iRvmbmZJP8BUx7UB+67YfB+lapRJ/IvHSL4N5NzWB8qVvxHimw= Received: (qmail 95848 invoked by alias); 29 Jul 2016 01:01:22 -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 95823 invoked by uid 89); 29 Jul 2016 01:01:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-io0-f174.google.com Received: from mail-io0-f174.google.com (HELO mail-io0-f174.google.com) (209.85.223.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 29 Jul 2016 01:01:11 +0000 Received: by mail-io0-f174.google.com with SMTP id b62so115421005iod.3 for ; Thu, 28 Jul 2016 18:01:10 -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=1ggqVW0lxnbs7s3CgoCWPtay6iCl+ceDai7enxco8vo=; b=HaOBk8ni0rS6tF9FyekPAbtrtGpR3lUROL99TJaqSaBoHNpXKSJN7F7L1Gq9REt2Fd vJyY3CL8AgJbH19DnmB5X5C4y2syBAeIZnsl7Qfg1CPpWhvUhroVmNJ/uxebtRna+Ncb gCjojBDtySTURJKSKYmtFOXqCD8XdvhDmaO1XDuVrYg54B1/UBzK6ZHkk/4QYKUQa1UN QSESdoYWMcEi1OqmdKPebvwNQ9S1C+LwA+mqh3fNtIBW/lx4MFENFPQcnyhmrDMvsEnW pe12mHjOWku8APdrO1CUXIwzt+CF62Q+r64glcht+f1wCnn4vlb9k7LZA0WD0CN97Q46 P3GQ== X-Gm-Message-State: AEkoouub3f8aoMjsUTNBxj++/Me6+4sfaS0qsi+k2h2MMcddRHwsDhOQIUG3btnbhSAc6Uf4LI5hPciFIPogSI0S X-Received: by 10.107.14.2 with SMTP id 2mr39300259ioo.181.1469754068770; Thu, 28 Jul 2016 18:01:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.48.197 with HTTP; Thu, 28 Jul 2016 18:01:07 -0700 (PDT) In-Reply-To: References: From: Prathamesh Kulkarni Date: Fri, 29 Jul 2016 06:31:07 +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 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 ? 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) diff --git a/gcc/testsuite/gcc.dg/pr70920-4.c b/gcc/testsuite/gcc.dg/pr70920-4.c index dedb895..035c3cb 100644 --- a/gcc/testsuite/gcc.dg/pr70920-4.c +++ b/gcc/testsuite/gcc.dg/pr70920-4.c @@ -1,5 +1,5 @@ /* { 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 +18,4 @@ foo (int a) } } -/* { dg-final { scan-tree-dump "gimple_simplified to if \\(_\[0-9\]* == 0\\)" "ccp1" } } */ +/* { dg-final { scan-tree-dump "== 0\\)" "forwprop1" } } */