From patchwork Thu Sep 27 22:57:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 187520 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]) by ozlabs.org (Postfix) with SMTP id 04AF82C00B5 for ; Fri, 28 Sep 2012 08:57:55 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1349391476; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=sYhw7/4 hDD8rOFnvasc/OS0s340=; b=fNoxdTtZmjcBzvCmttnSqcgVbWXqh6RO1IOa6Kf QdzbcNus1NnyW9rgCL6IQMhSO310qn8lGlkCwPZbeHz1LouUgz2px5xgWmKl5prZ qOVmXfSN7oFb7UigOTph4kewBmZJLbvxdCmuX14vcYLBm2rce+amT7DbaqpIpse9 De9s= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=oe0PF+ykEzYSafogXwl60YjOzYkVXh2Uc9ouumI6aqnCBiZmFW5dLiYtsoi7m4 dHS5W0ogVoo3uaHf5wSFxGU5sxrLa0PV716/NRazFwfvYnrvBbnYxsYcAHJXn0rz 5h+m1DPSX85AL7wBcM4YPUe5z7RW2xG88jrPUKkVRB4Fg=; Received: (qmail 14856 invoked by alias); 27 Sep 2012 22:57:52 -0000 Received: (qmail 14844 invoked by uid 22791); 27 Sep 2012 22:57:51 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Sep 2012 22:57:43 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8RMvgIw004380 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 27 Sep 2012 18:57:42 -0400 Received: from ivy.local (ovpn-113-56.phx2.redhat.com [10.3.113.56]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q8RMvfpX002067 for ; Thu, 27 Sep 2012 18:57:42 -0400 Message-ID: <5064D9E5.2040901@redhat.com> Date: Thu, 27 Sep 2012 18:57:41 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1 MIME-Version: 1.0 To: GCC Patches Subject: RFC: LRA for x86/x86-64 [3/9] X-IsSubscribed: yes 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 LRA creates a lot of new pseudos. So the following patch implements ahead allocation reg info information which is important for LRA compilation speed. 2012-09-27 Vladimir Makarov * reginfo.c (max_regno_since_last_resize): New. (reg_preferred_class, reg_alternate_class): Add assert. (allocate_reg_info): Initialize allocated reg info. (resize_reg_info): Make bigger reg_info and initialize new memory. (reginfo_init): Initialize max_regno_since_last_resize. (setup_reg_classes): Change assert. Index: reginfo.c =================================================================== --- reginfo.c (revision 191771) +++ reginfo.c (working copy) @@ -839,6 +839,8 @@ static struct reg_pref *reg_pref; /* Current size of reg_info. */ static int reg_info_size; +/* Max_reg_num still last resize_reg_info call. */ +static int max_regno_since_last_resize; /* Return the reg_class in which pseudo reg number REGNO is best allocated. This function is sometimes called before the info has been computed. @@ -849,6 +851,7 @@ reg_preferred_class (int regno) if (reg_pref == 0) return GENERAL_REGS; + gcc_assert (regno < reg_info_size); return (enum reg_class) reg_pref[regno].prefclass; } @@ -858,6 +861,7 @@ reg_alternate_class (int regno) if (reg_pref == 0) return ALL_REGS; + gcc_assert (regno < reg_info_size); return (enum reg_class) reg_pref[regno].altclass; } @@ -868,45 +872,64 @@ reg_allocno_class (int regno) if (reg_pref == 0) return NO_REGS; + gcc_assert (regno < reg_info_size); return (enum reg_class) reg_pref[regno].allocnoclass; } -/* Allocate space for reg info. */ +/* Allocate space for reg info and initilize it. */ static void allocate_reg_info (void) { - reg_info_size = max_reg_num (); + int i; + + max_regno_since_last_resize = max_reg_num (); + reg_info_size = max_regno_since_last_resize * 3 / 2 + 1; gcc_assert (! reg_pref && ! reg_renumber); reg_renumber = XNEWVEC (short, reg_info_size); reg_pref = XCNEWVEC (struct reg_pref, reg_info_size); memset (reg_renumber, -1, reg_info_size * sizeof (short)); + for (i = 0; i < reg_info_size; i++) + { + reg_pref[i].prefclass = GENERAL_REGS; + reg_pref[i].altclass = ALL_REGS; + reg_pref[i].allocnoclass = GENERAL_REGS; + } } -/* Resize reg info. The new elements will be uninitialized. Return - TRUE if new elements (for new pseudos) were added. */ +/* Resize reg info. The new elements will be initialized. Return TRUE + if new pseudos were added since the last call. */ bool resize_reg_info (void) { - int old; + int old, i; + bool change_p; if (reg_pref == NULL) { allocate_reg_info (); return true; } - if (reg_info_size == max_reg_num ()) - return false; + change_p = max_regno_since_last_resize != max_reg_num (); + max_regno_since_last_resize = max_reg_num (); + if (reg_info_size >= max_reg_num ()) + return change_p; old = reg_info_size; - reg_info_size = max_reg_num (); + reg_info_size = max_reg_num () * 3 / 2 + 1; gcc_assert (reg_pref && reg_renumber); reg_renumber = XRESIZEVEC (short, reg_renumber, reg_info_size); reg_pref = XRESIZEVEC (struct reg_pref, reg_pref, reg_info_size); memset (reg_pref + old, -1, (reg_info_size - old) * sizeof (struct reg_pref)); memset (reg_renumber + old, -1, (reg_info_size - old) * sizeof (short)); + for (i = old; i < reg_info_size; i++) + { + reg_pref[i].prefclass = GENERAL_REGS; + reg_pref[i].altclass = ALL_REGS; + reg_pref[i].allocnoclass = GENERAL_REGS; + } return true; } @@ -938,6 +961,7 @@ reginfo_init (void) /* This prevents dump_reg_info from losing if called before reginfo is run. */ reg_pref = NULL; + reg_info_size = max_regno_since_last_resize = 0; /* No more global register variables may be declared. */ no_global_reg_vars = 1; return 1; @@ -964,7 +988,7 @@ struct rtl_opt_pass pass_reginfo_init = -/* Set up preferred, alternate, and cover classes for REGNO as +/* Set up preferred, alternate, and allocno classes for REGNO as PREFCLASS, ALTCLASS, and ALLOCNOCLASS. */ void setup_reg_classes (int regno, @@ -973,7 +997,7 @@ setup_reg_classes (int regno, { if (reg_pref == NULL) return; - gcc_assert (reg_info_size == max_reg_num ()); + gcc_assert (reg_info_size >= max_reg_num ()); reg_pref[regno].prefclass = prefclass; reg_pref[regno].altclass = altclass; reg_pref[regno].allocnoclass = allocnoclass;