From patchwork Fri Dec 6 10:19:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 297700 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0AE712C00A7 for ; Fri, 6 Dec 2013 21:19:34 +1100 (EST) 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:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=K1FqksMNAePzmm4DnF 0/xNsiJlKtbD/XpI1mlXAdwQikXDZMRWbbyTwgape5uWHNyl1rc4YBneDZF71O9+ bJ3kTUK18XOERpCZqwMkjIAsEeWVFTmvAQK7iUM5/SfWpOp/DTmmlkWWACdjWtq5 OAGaeZMYDJmuTk6vzyxebNZLg= 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:date:message-id:subject :from:to:cc:content-type; s=default; bh=h5YcQp1bM93P48vKMM8rRDHB QVk=; b=FKQS9aUhKmJsP+uPhYx+1lPwMSY2a9H/7VqVTThpj8h8rAoI5GEADHsE R9657I0+VLUhSaq6F3rn33EymsrBpCwGRn7LlQv3juoerI7e4OqhCCV57Zxj6rOz eNqUc2AVK6/F12myg/nk/pMyOo4yXkN7Qk7Xs+gwObnMgbPPsbo= Received: (qmail 14639 invoked by alias); 6 Dec 2013 10:19:28 -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 14628 invoked by uid 89); 6 Dec 2013 10:19:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-we0-f182.google.com Received: from Unknown (HELO mail-we0-f182.google.com) (74.125.82.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 06 Dec 2013 10:19:27 +0000 Received: by mail-we0-f182.google.com with SMTP id q59so435200wes.13 for ; Fri, 06 Dec 2013 02:19:17 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.194.206.5 with SMTP id lk5mr2336042wjc.46.1386325157227; Fri, 06 Dec 2013 02:19:17 -0800 (PST) Received: by 10.195.12.114 with HTTP; Fri, 6 Dec 2013 02:19:17 -0800 (PST) In-Reply-To: <529399EF.4070002@redhat.com> References: <003c01cee9bf$d58176e0$808464a0$@arm.com> <529399EF.4070002@redhat.com> Date: Fri, 6 Dec 2013 11:19:17 +0100 Message-ID: Subject: Re: [PATCH GCC]Pick up more address lowering cases for ivopt and tree-affine.c From: Richard Biener To: Jeff Law Cc: "bin.cheng" , GCC Patches X-IsSubscribed: yes On Mon, Nov 25, 2013 at 7:41 PM, Jeff Law wrote: > On 11/25/13 02:22, bin.cheng wrote: >> >> Hi, >> I previously committed two patches lowering complex address expression for >> IVOPT at http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00546.html and >> http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01103.html >> When I bootstrapping GCC I found there were some peculiar cases like >> &MEM[ptr+CST] + xxxx, which should be handled too. This patch consists >> below two changes: >> >> 1) change in alloc_iv: >> Original code lowers top level complex address expressions like >> &MEM[ptr+off]. The patch relaxes check condition in order to lower >> expressions like &MEM[ptr+off] + xxx, just as the BASE from below dump: >> use 2 >> generic >> in statement _595 = &MEM[(void *)&this_prg + 36B] + _594; >> >> at position >> type struct gcov_bucket_type * >> base (struct gcov_bucket_type *) &MEM[(void *)&this_prg + 36B] + >> (sizetype) ((unsigned int) (src_i_683 + -1) * 20) >> step 4294967276 >> base object (void *) &this_prg >> related candidates >> >> 2) change in tree_to_aff_combination: >> The function get_inner_reference returns "&MEM[ptr+off]" as the core for >> input like the memory ADDRESS in below dump: >> use 2 >> address >> in statement _59 = MEM[(const struct gcov_ctr_summary *)summary_22(D) + >> 4B].histogram[h_ix_111].min_value; >> >> at position MEM[(const struct gcov_ctr_summary *)summary_22(D) + >> 4B].histogram[h_ix_111].min_value >> type const gcov_type * >> base (const gcov_type *) &MEM[(const struct gcov_ctr_summary >> *)summary_22(D) + 4B] + 36 >> step 20 >> base object (void *) summary_22(D) >> related candidates >> >> Which can be further reduced into something like "summary_22(D) + 40B". >> This change is necessary for the first one, because I am using >> tree_to_aff_combination rather than get_inner_reference_aff now. >> >> Bootstrap and test on x86/x86_64/arm. Is it OK? >> >> Thanks. >> bin >> >> 2013-11-25 Bin Cheng >> >> * tree-ssa-loop-ivopts.c (contain_complex_addr_expr): New. >> (alloc_iv): Lower more cases by calling contain_complex_addr_expr >> and tree_to_aff_combination. >> * tree-affine.c (tree_to_aff_combination): Handle &MEM[ptr+CST] >> in core part of complex reference. >> >> gcc/testsuite/ChangeLog >> 2013-11-25 Bin Cheng >> >> * gcc.dg/tree-ssa/ivopts-lower_base.c: New test. > > Unless there's a PR for this problem, I think this needs to wait. I agree. Btw, please split the patch. please handle the offset before taking the address, thus if (TREE_CODE (core) == MEM_REF) { add constant offset; core = TREE_OPERAND (core, 0); } else core = build_fold_addr_expr (core); that simplifies things and avoids the address building. Richard. > jeff > > Index: gcc/tree-affine.c =================================================================== --- gcc/tree-affine.c (revision 205087) +++ gcc/tree-affine.c (working copy) @@ -328,7 +328,19 @@ tree_to_aff_combination (tree expr, tree type, aff double_int::from_uhwi (bitpos / BITS_PER_UNIT)); core = build_fold_addr_expr (core); if (TREE_CODE (core) == ADDR_EXPR) - aff_combination_add_elt (comb, core, double_int_one); + { + /* Handle &MEM[ptr + CST] in core part of complex reference. */ + if (TREE_CODE (TREE_OPERAND (core, 0)) == MEM_REF) + { + core = TREE_OPERAND (core, 0); + tree_to_aff_combination (TREE_OPERAND (core, 0), type, &tmp); + aff_combination_add (comb, &tmp); + tree_to_aff_combination (TREE_OPERAND (core, 1), sizetype, &tmp); + aff_combination_add (comb, &tmp); + } + else + aff_combination_add_elt (comb, core, double_int_one); + } else { tree_to_aff_combination (core, type, &tmp)