From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10230 invoked by alias); 11 Aug 2014 02:35:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 10203 invoked by uid 89); 11 Aug 2014 02:35:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-lb0-f174.google.com Received: from mail-lb0-f174.google.com (HELO mail-lb0-f174.google.com) (209.85.217.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 11 Aug 2014 02:35:19 +0000 Received: by mail-lb0-f174.google.com with SMTP id c11so5373590lbj.19 for ; Sun, 10 Aug 2014 19:35:16 -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:date :message-id:subject:from:to:cc:content-type; bh=DrxfwF2k+Pc0M1+lSr116DVRN7NO9WQx4IckaNl/0K0=; b=NV6fH/i3wbYGQ8WvLty+V0xy4lKTiMLXUyAmnn0i+A7TiTk7i4ozHya31myQ3fbVys ToFSn5AzlXPiliwxYCLwH0DAMlt/Yjslf14qcaTcniL5gktM32Y761NXu+9RzkF2g+gb iMBbJn3J6Vl1EaUxjUaSoFGGPPZqPlLY2elf9wmAeLvbdxoglu2yCZLrATaI+QAIegDP eSheUWuh0jbB93Vn4AuT2Myj/DyCcgW6xSKMkIAaZ3VBPWoxnek1JWLFk0hX3bjQ6Nzb uiQnTGuTppM/U413RiKeVxS9PkDqfj5qbSJFqABCQUnigokfrRVNt/gVpYDSlSAjKh1W W8WQ== X-Gm-Message-State: ALoCoQld5ovO5vSyG7I4dDCeJ9zcR+ZysrzpOi2PqEi78TDs5QeMul/kmAuAxeObi55MM6layV/Z MIME-Version: 1.0 X-Received: by 10.112.40.161 with SMTP id y1mr34549045lbk.61.1407724516089; Sun, 10 Aug 2014 19:35:16 -0700 (PDT) Received: by 10.112.140.169 with HTTP; Sun, 10 Aug 2014 19:35:15 -0700 (PDT) In-Reply-To: References: Date: Mon, 11 Aug 2014 02:35:00 -0000 Message-ID: Subject: Re: [PATCH, ARM] Keep constants in register when expanding From: Zhenqiang Chen To: Ramana Radhakrishnan Cc: "gcc-patches@gcc.gnu.org" Content-Type: multipart/mixed; boundary=001a11345cc2b94b7c050051672b X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00979.txt.bz2 --001a11345cc2b94b7c050051672b Content-Type: text/plain; charset=ISO-8859-1 Content-length: 2991 On 8 August 2014 23:22, Ramana Radhakrishnan wrote: > On Tue, Aug 5, 2014 at 10:31 AM, Zhenqiang Chen > wrote: >> Hi, >> >> For some large constants, ARM will split them during expanding, which >> makes impossible to hoist them out the loop or shared by different >> references (refer the test case in the patch). >> >> The patch keeps some constants in registers. If the constant can not >> be optimized, the cprop and combine passes can optimize them as what >> we do in current expand pass with >> >> define_insn_and_split "*arm_subsi3_insn" >> define_insn_and_split "*arm_andsi3_insn" >> define_insn_and_split "*iorsi3_insn" >> define_insn_and_split "*arm_xorsi3" >> >> The patch does not modify addsi3 since the define_insn_and_split >> "*arm_addsi3" is only valid when (reload_completed || >> !arm_eliminable_register (operands[1])). The cprop and combine passes >> can not optimize the large constant if we put it in register, which >> will lead to regression. >> >> For logic operators, the patch skips changes for constants: >> >> INTVAL (operands[2]) < 0 && const_ok_for_arm (-INTVAL (operands[2]) >> >> since expand pass always uses "sign-extend" to get the value >> (trunc_int_for_mode called from immed_wide_int_const) for rtl, and >> logs show most negative values are UNSIGNED when they are TREE node. >> And combine pass is smart enough to recover the negative value to >> positive value. > > I am unable to verify any change in code generation for this testcase > with and without the patch when I had a play with the patch. > > what gives ? Thanks for trying the patch. Do you add option -fno-gcse which is mentioned in dg-options " -O2 -fno-gcse "? Without it, there is no change for the testcase since cprop pass will propagate the constant to AND expr (A patch to enhance cprop pass was discussed at https://gcc.gnu.org/ml/gcc-patches/2014-06/msg01321.html). In addition, if the constant can not be hoisted out the loop, later combine pass can also optimize it. These (cprop and combine) are reasons why the patch itself has little impact on current tests. Test case in the patch is updated since it does not work for armv7-m. Thanks! -Zhenqiang > Ramana > > >> >> Bootstrap and no make check regression on Chrome book. >> For coremark, dhrystone and eembcv1, no any code size and performance >> change on Cortex-M4. >> No any file in CSiBE has code size change for Cortex-A15 and Cortex-M4. >> No Spec2000 performance regression on Chrome book and dumped assemble >> codes only show very few difference. >> >> OK for trunk? >> >> Thanks! >> -Zhenqiang >> >> ChangeLog: >> 2014-08-05 Zhenqiang Chen >> >> * config/arm/arm.md (subsi3, andsi3, iorsi3, xorsi3): Keep some >> large constants in register other than split them. >> >> testsuite/ChangeLog: >> 2014-08-05 Zhenqiang Chen >> >> * gcc.target/arm/maskdata.c: New test. --001a11345cc2b94b7c050051672b Content-Type: text/x-patch; charset=US-ASCII; name="skip-split-v2.patch" Content-Disposition: attachment; filename="skip-split-v2.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hyp6mvbq0 Content-length: 4970 ZGlmZiAtLWdpdCBhL2djYy9jb25maWcvYXJtL2FybS5tZCBiL2djYy9jb25m aWcvYXJtL2FybS5tZAppbmRleCBiZDhlYThmLi5jOGIzMDAxIDEwMDY0NAot LS0gYS9nY2MvY29uZmlnL2FybS9hcm0ubWQKKysrIGIvZ2NjL2NvbmZpZy9h cm0vYXJtLm1kCkBAIC0xMTYyLDkgKzExNjIsMTYgQEAKICAgICB7CiAgICAg ICBpZiAoVEFSR0VUXzMyQklUKQogICAgICAgICB7Ci0gICAgICAgICAgYXJt X3NwbGl0X2NvbnN0YW50IChNSU5VUywgU0ltb2RlLCBOVUxMX1JUWCwKLQkg ICAgICAgICAgICAgICAgICAgICAgSU5UVkFM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