From patchwork Wed Sep 17 09:18:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenqiang Chen X-Patchwork-Id: 390335 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id ECF721400AF for ; Wed, 17 Sep 2014 19:18:52 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=EZPnCwZ94A0aKexL SrR03Szcr4lN5fDlAgMDs3e4GY3yts+3X8PmIeu8i7rVNvHme8ZD7Ng30qdv67TS KrIGmrMze02Xyx2lmSD7fohfactPggWM/LYomVeuRKCRDCiN3cO/2foVCOdj9pMJ ycI2gRhmqGtrtonJg9skUM/vGhQ= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=VeFyVGg3iYr/SyS7aiNOpu 2oq4g=; b=Joj3Vn/R01dgkzfD/DXq0mb6XfvT3r3G8PxgdxzPgFFtrkM78osjXN kTkVQoS9ac87Tu3ElRSTzzthDJ3D11HPOwJj9WpjaUfgYC5qAsXcVinB/iHd5qr9 wnS8ukdpCYQoHPqc44jf77IQB6eqQa0pm/5kT1jlg86JwAtHkPCFo= Received: (qmail 21981 invoked by alias); 17 Sep 2014 09:18:44 -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 21972 invoked by uid 89); 17 Sep 2014 09:18:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 Sep 2014 09:18:38 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 17 Sep 2014 10:18:36 +0100 Received: from shawin003 ([10.164.2.82]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 17 Sep 2014 10:18:33 +0100 From: "Zhenqiang Chen" To: Subject: [PATCH, ira] Ignore some conflict cost Date: Wed, 17 Sep 2014 17:18:27 +0800 Message-ID: <000001cfd258$57b8fd50$072af7f0$@arm.com> MIME-Version: 1.0 X-MC-Unique: 114091710183600301 X-IsSubscribed: yes Hi, When assign_hard_reg, we always check_hard_reg_p, which has code if (! TEST_HARD_REG_BIT (profitable_regs, hard_regno)) return false; i.e. If a hard_regno is not in profitable_regs, we can not allocate it to the ira_allocno_t A. So the conflict on a hard_regno, which does not belong to the profitable_regs, can be ignored. Please refer https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63210 for the detail of the test case. Bootstrap and no make check regression on X86-64 and ARM Chromebook. NO spec2k performance regression on X86-64 and ARM Chromebook. CSiBE code size is 0.01% better for ARM Cortex-M0. OK for trunk? Thanks! -Zhenqiang ChangeLog: 2014-09-17 Zhenqiang Chen PR rtl-optimization/63210 * ira-color.c (assign_hard_reg): Ignore conflict cost if the HARD_REGNO is not availabe for CONFLICT_A. testsuite/ChangeLog: 2014-09-17 Zhenqiang Chen * gcc.target/arm/pr63210.c: New test. diff --git a/gcc/ira-color.c b/gcc/ira-color.c index e2ea359..e3fea54 100644 --- a/gcc/ira-color.c +++ b/gcc/ira-color.c @@ -1709,6 +1709,7 @@ assign_hard_reg (ira_allocno_t a, bool retry_p) { ira_allocno_t conflict_a = OBJECT_ALLOCNO (conflict_obj); enum reg_class conflict_aclass; + allocno_color_data_t data = ALLOCNO_COLOR_DATA (conflict_a); /* Reload can give another class so we need to check all allocnos. */ @@ -1780,7 +1781,12 @@ assign_hard_reg (ira_allocno_t a, bool retry_p) hard_regno = ira_class_hard_regs[aclass][j]; ira_assert (hard_regno >= 0); k = ira_class_hard_reg_index[conflict_aclass][hard_regno]; - if (k < 0) + if (k < 0 + /* If HARD_REGNO is not available for CONFLICT_A, + the conflict would be ignored, since HARD_REGNO + will never be assigned to CONFLICT_A. */ + || !TEST_HARD_REG_BIT (data->profitable_hard_regs, + hard_regno)) continue; full_costs[j] -= conflict_costs[k]; } diff --git a/gcc/testsuite/gcc.target/arm/pr63210.c b/gcc/testsuite/gcc.target/arm/pr63210.c new file mode 100644 index 0000000..c3ae928 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr63210.c @@ -0,0 +1,12 @@ +/* { dg-do assemble } */ +/* { dg-options "-mthumb -Os " } */ +/* { dg-require-effective-target arm_thumb1_ok } */ + +int foo1 (int c); +int foo2 (int c); + +int test (int c) +{ + return (foo1 (c) || foo2 (c)); +} +/* { dg-final { object-size text <= 28 } } */