From patchwork Wed Apr 17 12:54:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Zamyatin X-Patchwork-Id: 237212 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 2EA0F2C007E for ; Wed, 17 Apr 2013 22:54:40 +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 :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=LZ5sMU7whrPwJCmdTsC4AmiWqEJ2jcl2nWf+Dmkmod2FAk jSwZs/DZM2/vkI1Wm8UcbYVYByFZoNUdZtB0ebFS+bgrgXtaDfPe/+uU5ZDcb488 MNQaEnzs1TWmoNIa0yMgonz7cZ8XECOqykWD9ROmF+swMi3KZuvgpeSBGWWcE= 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:date:message-id:subject:from:to:content-type; s= default; bh=EguCkap5RljytHNwLG3OmV99fXE=; b=JjGm21q8DvYATLDO4Ecf JiJz+Fpz5pflaW4sQCCb0d7DsSo/MpqAiEoY26gcBSm2azBDnIkrviTLB8yagvS+ YkE8U9zIqTr3Flo18NgKUbY6JxtVY4/PI9mJHaz5nLOB8fqmAkUVr+ujWWB5WSKa kYf9rNzLJmmFIWKSyPJY/FU= Received: (qmail 6072 invoked by alias); 17 Apr 2013 12:54:34 -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 6062 invoked by uid 89); 17 Apr 2013 12:54:33 -0000 X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_AV autolearn=ham version=3.3.1 Received: from mail-lb0-f178.google.com (HELO mail-lb0-f178.google.com) (209.85.217.178) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 17 Apr 2013 12:54:33 +0000 Received: by mail-lb0-f178.google.com with SMTP id q13so1583319lbi.9 for ; Wed, 17 Apr 2013 05:54:30 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.173.70 with SMTP id bi6mr3559940lbc.116.1366203270382; Wed, 17 Apr 2013 05:54:30 -0700 (PDT) Received: by 10.114.180.133 with HTTP; Wed, 17 Apr 2013 05:54:30 -0700 (PDT) Date: Wed, 17 Apr 2013 16:54:30 +0400 Message-ID: Subject: Re: [patch] RFC: ix86 / x86_64 register pressure aware scheduling From: Igor Zamyatin To: "gcc-patches@gcc.gnu.org" , stevenb.gcc@gmail.com, Uros Bizjak , "H.J. Lu" , jh@suse.cz, Yuri Rumyantsev X-Virus-Found: No These changes are what we used to try here at Intel after bunch of changes which made pre-alloc scheduler more stable. We benchmarked both register pressure algorithms and overall result was not that promising. We saw number of regressions e.g. for optset "-mavx -O3 -funroll-loops -ffast-math -march=corei7" (for spec2000 not only lucas but also applu regressed). And overall gain is negative even for x86_64. For 32 bits picture was worse if I remember correctly. In common we have doubts that this feature is good for OOO machine.... Thanks, Igor -----Original Message----- From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-owner@gcc.gnu.org] On Behalf Of Steven Bosscher Sent: Monday, April 15, 2013 11:34 PM To: GCC Patches Cc: H.J. Lu; Uros Bizjak; Jan Hubicha Subject: [patch] RFC: ix86 / x86_64 register pressure aware scheduling Hello, The attached patch enables register pressure aware scheduling for the ix86 and x86_64 targets. It uses the optimistic algorithm to avoid being overly conservative. This is the same as what other CISCy targets, like s390, also do. The motivation for this patch is the excessive spilling I've observed in a few test cases with relatively large basic blocks, e.g. encryption algorithms and codecs. The patch passes bootstrap+testing on x86_64-unknown-linux-gnu and i686-unknown-linux-gnu, with a few new failures due to PR56950. Off-list, Uros, Honza and others have already looked at the patch and benchmarked it. For x86_64 there is an overall improvement for SPEC2k except that lucas regresses, but such a preliminary result is IMHO very promising. Comments/suggestions welcome :-) Ciao! Steven * common/config/i386/i386-common.c (ix86_option_optimization_table): Do not disable insns scheduling. Enable register pressure aware scheduling. * config/i386/i386.c (ix86_option_override): Use the alternative, optimistic scheduling-pressure algorithm by default. Index: common/config/i386/i386-common.c =================================================================== --- common/config/i386/i386-common.c (revision 197941) +++ common/config/i386/i386-common.c (working copy) @@ -707,9 +707,15 @@ static const struct default_options ix86 { /* Enable redundant extension instructions removal at -O2 and higher. */ { OPT_LEVELS_2_PLUS, OPT_free, NULL, 1 }, - /* Turn off -fschedule-insns by default. It tends to make the - problem with not enough registers even worse. */ - { OPT_LEVELS_ALL, OPT_fschedule_insns, NULL, 0 }, + /* Enable -fsched-pressure by default for all optimization levels. + Before SCHED_PRESSURE_MODEL register-pressure aware schedule was + available, -fschedule-insns was turned off completely by default for + this port, because scheduling before register allocation tends to + make the problem with not enough registers even worse. However, + for very long basic blocks the scheduler can help bring register + pressure down significantly, and SCHED_PRESSURE_MODEL is still + conservative enough to avoid creating excessive register pressure. */ + { OPT_LEVELS_ALL, OPT_fsched_pressure, NULL, 1 }, #ifdef SUBTARGET_OPTIMIZATION_OPTIONS SUBTARGET_OPTIMIZATION_OPTIONS, Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 197941) +++ config/i386/i386.c (working copy) @@ -3936,6 +3936,10 @@ ix86_option_override (void) ix86_option_override_internal (true); + /* Use the alternative scheduling-pressure algorithm by default. */ + maybe_set_param_value (PARAM_SCHED_PRESSURE_ALGORITHM, 2, + global_options.x_param_values, + global_options_set.x_param_values); /* This needs to be done at start up. It's convenient to do it here. */ register_pass (&insert_vzeroupper_info);