From patchwork Mon Dec 6 20:04:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fang, Changpeng" X-Patchwork-Id: 74461 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 EE392B6EDF for ; Tue, 7 Dec 2010 07:04:34 +1100 (EST) Received: (qmail 20828 invoked by alias); 6 Dec 2010 20:04:31 -0000 Received: (qmail 20820 invoked by uid 22791); 6 Dec 2010 20:04:30 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from va3ehsobe001.messaging.microsoft.com (HELO VA3EHSOBE008.bigfish.com) (216.32.180.11) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Dec 2010 20:04:24 +0000 Received: from mail136-va3-R.bigfish.com (10.7.14.251) by VA3EHSOBE008.bigfish.com (10.7.40.28) with Microsoft SMTP Server id 14.1.225.8; Mon, 6 Dec 2010 20:04:21 +0000 Received: from mail136-va3 (localhost.localdomain [127.0.0.1]) by mail136-va3-R.bigfish.com (Postfix) with ESMTP id 624221490829; Mon, 6 Dec 2010 19:58:25 +0000 (UTC) X-SpamScore: -3 X-BigFish: VPS-3(zz4015Lzz1202hzzz32i668h34h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:ausb3twp02.amd.com; RD:none; EFVD:NLI Received: from mail136-va3 (localhost.localdomain [127.0.0.1]) by mail136-va3 (MessageSwitch) id 1291665504836647_12260; Mon, 6 Dec 2010 19:58:24 +0000 (UTC) Received: from VA3EHSMHS023.bigfish.com (unknown [10.7.14.254]) by mail136-va3.bigfish.com (Postfix) with ESMTP id A82A213004F; Mon, 6 Dec 2010 19:58:24 +0000 (UTC) Received: from ausb3twp02.amd.com (163.181.249.109) by VA3EHSMHS023.bigfish.com (10.7.99.33) with Microsoft SMTP Server id 14.1.225.8; Mon, 6 Dec 2010 20:04:17 +0000 X-M-MSG: Received: from sausexedgep01.amd.com (sausexedgep01-ext.amd.com [163.181.249.72]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ausb3twp02.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 26B2FC891E; Mon, 6 Dec 2010 14:04:14 -0600 (CST) Received: from sausexhtp02.amd.com (163.181.3.152) by sausexedgep01.amd.com (163.181.36.54) with Microsoft SMTP Server (TLS) id 8.3.106.1; Mon, 6 Dec 2010 14:05:45 -0600 Received: from SAUSEXMBP01.amd.com ([163.181.3.198]) by sausexhtp02.amd.com ([163.181.3.152]) with mapi; Mon, 6 Dec 2010 14:04:14 -0600 From: "Fang, Changpeng" To: "gcc-patches@gcc.gnu.org" CC: "sebpop@gmail.com" , "hjl.tools@gmail.com" , "Yazdani, Reza" Date: Mon, 6 Dec 2010 14:04:14 -0600 Subject: [Patch, i386] Turn on -fschedule-insns and -fsched-pressure by default for x86-64 Message-ID: MIME-Version: 1.0 X-OriginatorOrg: amd.com 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 Hi, Attached is the patch that proposes to turn on -fschedule-insns and -fsched-pressure by default at -O2 or higher (for speed-runs only) for x86-64 systems. Enablement of these two flags could improve the performance of floating point programs (For CFP2006, 2.29% under -O2, and 1.34% under -O3). There is no apparent performance impact on integer programs (as expected). We have investigated this optimization since 4.5, and it is the time to turn on these two flags to enjoy the performance gains. The patch passed bootstrappings under -O2 and -O3 on x86_64-unknown-linux-gnu, and passed the gcc regression tests. Is it OK to commit the patch? Thanks, Changpeng Percentage improvement by turning on -fschedule-insns and -fsched-pressure on an x86-64 system -O2 -O3 ============================ 410.bwaves 1.63 2.45 416.gamess 1.79 2.38 433.milc 1.39 2.52 434.zeusmp 1.79 0.8 435.gromacs 3.48 4.02 436.cactusADM 0.49 11.26 437.leslie3d 0 1.02 444.namd 3.73 3.6 447.dealII 1.09 -0.5 450.soplex 0 1.26 453.povray 0 0 454.calculix 23.81 0.24 459.GemsFDTD 2.16 -1.97 465.tonto 0 -0.75 470.lbm 1.49 -3.28 481.wrf 0.94 0.69 482.sphinx3 0.5 0 400.perlbench 1.07 0 401.bzip2 -1.48 -2.27 403.gcc 0.68 0.67 429.mcf 2.01 1.86 445.gobmk 1.19 -0.6 456.hmmer 3.45 0 458.sjeng 1.37 0.64 462.libquantum 0 -0.32 464.h264ref 0.92 -2.15 471.omnetpp 0.86 0.84 473.astar -0.97 -0.91 483.xalancbmk 1.82 3.55 ============================= CFP GEOMEAN 2.29 1.34 CINT GEOMEAN 0.65 0 From 60859804422c1e0093769eaa47b4cc2d95657f86 Mon Sep 17 00:00:00 2001 From: Changpeng Fang Date: Mon, 6 Dec 2010 11:03:07 -0800 Subject: [PATCH] Turn on -fschedule-insns and -fsched-pressure by default at -O2 or higher for x86-64. * common.opt (fschedule-insns): Add Init(0). * opts.c (default_options_table): Set default of -fschedule-insns to 2 to differentiate it with the user setting of 1 (if any). * config/i386/i386.c (ix86_option_optimization_table): Turn on -fsched-pressure by default at -O2 or higher (for speed run only). (ix86_option_override_internal): Turn off -fschedule-insns by default for 32-bit compilation. Also, turn off -fsched-pressure by default if -fschedule-insns was not turned on. --- gcc/common.opt | 2 +- gcc/config/i386/i386.c | 20 +++++++++++++++++--- gcc/opts.c | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index 57f5b0a..72be118 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1570,7 +1570,7 @@ Common Ignore Does nothing. Preserved for backward compatibility. fschedule-insns -Common Report Var(flag_schedule_insns) Optimization +Common Report Var(flag_schedule_insns) Init(0) Optimization Reschedule instructions before register allocation fschedule-insns2 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index a66a0c4..226e4fc 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -4079,6 +4079,19 @@ ix86_option_override_internal (bool main_args_p) if (!TARGET_SCHEDULE) flag_schedule_insns_after_reload = flag_schedule_insns = 0; +#ifdef INSN_SCHEDULING + /* For 32-bit compilation, turn off -fschedule-insns by default to hide + the problem with not enough registers. */ + if (!TARGET_64BIT) + flag_schedule_insns = (flag_schedule_insns == 1); + + /* If -fschedule-insns was not turned on, the default of -fsched-pressure + should be off. On the other hand, if user turned on -fschedule-insns + for 32-bit compilation, the default of -fsched-presssure is kept on. */ + if (!flag_schedule_insns) + flag_sched_pressure = (flag_sched_pressure == 1); +#endif + maybe_set_param_value (PARAM_SIMULTANEOUS_PREFETCHES, ix86_cost->simultaneous_prefetches, global_options.x_param_values, @@ -5031,10 +5044,11 @@ x86_output_aligned_bss (FILE *file, tree decl ATTRIBUTE_UNUSED, static const struct default_options ix86_option_optimization_table[] = { - /* Turn off -fschedule-insns by default. It tends to make the - problem with not enough registers even worse. */ + /* Turn on -fsched-pressure by default at -O2 or higher. This could + alleviate the problem with not enough registers caused by turning + on -fschedule-pressure (in opts.c). */ #ifdef INSN_SCHEDULING - { OPT_LEVELS_ALL, OPT_fschedule_insns, NULL, 0 }, + { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_fsched_pressure, NULL, 2 }, #endif #ifdef SUBTARGET_OPTIMIZATION_OPTIONS diff --git a/gcc/opts.c b/gcc/opts.c index cd41c2a..7700f0a 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -483,7 +483,7 @@ static const struct default_options default_options_table[] = { OPT_LEVELS_2_PLUS, OPT_fpeephole2, NULL, 1 }, #ifdef INSN_SCHEDULING /* Only run the pre-regalloc scheduling pass if optimizing for speed. */ - { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_fschedule_insns, NULL, 1 }, + { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_fschedule_insns, NULL, 2 }, { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 }, #endif { OPT_LEVELS_2_PLUS, OPT_fregmove, NULL, 1 }, -- 1.6.3.3