From gcc-patches-return-65451-listarch-gcc-patches=gcc dot gnu dot org at gcc dot gnu dot org Fri Aug 02 01:39:13 2002 Return-Path: Delivered-To: listarch-gcc-patches at gcc dot gnu dot org Received: (qmail 21556 invoked by alias); 2 Aug 2002 01:39:12 -0000 Mailing-List: contact gcc-patches-help at gcc dot gnu dot org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner at gcc dot gnu dot org Delivered-To: mailing list gcc-patches at gcc dot gnu dot org Received: (qmail 21548 invoked from network); 2 Aug 2002 01:39:11 -0000 Received: from unknown (HELO mta02ps.bigpond.com) (144.135.25.134) by sources dot redhat dot com with SMTP; 2 Aug 2002 01:39:11 -0000 Received: from bubble.local ([144.135.25.78]) by mta02ps dot bigpond dot com (Netscape Messaging Server 4 dot 15 mta02ps May 23 2002 23:53:28) with SMTP id H070L800 dot 8P3 for ; Fri, 2 Aug 2002 11:39:08 +1000 Received: from CPE-144-136-176-14.sa.bigpond.net.au ([144.136.176.14]) by PSMAM04.mailsvc.email.bigpond.com(MailRouter V3.0n 98/27831336); 02 Aug 2002 11:39:08 Received: (qmail 17290 invoked by uid 179); 2 Aug 2002 01:39:08 -0000 Date: Fri, 2 Aug 2002 11:09:08 +0930 From: Alan Modra To: gcc-patches at gcc dot gnu dot org Cc: David Edelsohn Subject: power4 branch hints Message-ID: <20020802110907.L2148@bubble.sa.bigpond.net.au> Mail-Followup-To: gcc-patches at gcc dot gnu dot org, David Edelsohn Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i See the comment below. * config/rs6000/rs6000.c (output_cbranch): Hint differently for power4. * config/rs6000/rs6000.h (enum processor_type): Comment on ordering. Index: gcc/config/rs6000/rs6000.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v retrieving revision 1.355 diff -u -p -r1.355 rs6000.c --- gcc/config/rs6000/rs6000.c 2 Aug 2002 01:08:01 -0000 1.355 +++ gcc/config/rs6000/rs6000.c 2 Aug 2002 01:21:55 -0000 @@ -8438,21 +8438,30 @@ output_cbranch (op, label, reversed, ins /* Maybe we have a guess as to how likely the branch is. The old mnemonics don't have a way to specify this information. */ + pred = ""; note = find_reg_note (insn, REG_BR_PROB, NULL_RTX); if (note != NULL_RTX) { /* PROB is the difference from 50%. */ int prob = INTVAL (XEXP (note, 0)) - REG_BR_PROB_BASE / 2; - - /* For branches that are very close to 50%, assume not-taken. */ - if (abs (prob) > REG_BR_PROB_BASE / 20 - && ((prob > 0) ^ need_longbranch)) - pred = "+"; - else - pred = "-"; + int cpu_version1_arch = rs6000_cpu < PROCESSOR_POWER4; + + /* Only hint for highly probable/improbable branches on newer + cpus as static prediction overrides processor dynamic + prediction. For older cpus we may as well always hint, but + assume not taken for branches that are very close to 50% as a + mispredicted taken branch is more expensive than a + mispredicted not-taken branch. */ + if (cpu_version1_arch + || abs (prob) > REG_BR_PROB_BASE / 100 * 48) + { + if (abs (prob) > REG_BR_PROB_BASE / 20 + && ((prob > 0) ^ need_longbranch)) + pred = "+"; + else + pred = "-"; + } } - else - pred = ""; if (label == NULL) s += sprintf (s, "{b%sr|b%slr%s} ", ccode, ccode, pred); Index: gcc/config/rs6000/rs6000.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.h,v retrieving revision 1.217 diff -u -p -r1.217 rs6000.h --- gcc/config/rs6000/rs6000.h 1 Aug 2002 21:18:34 -0000 1.217 +++ gcc/config/rs6000/rs6000.h 2 Aug 2002 01:22:00 -0000 @@ -341,7 +341,10 @@ extern int target_flags; /* This is meant to be redefined in the host dependent files */ #define SUBTARGET_SWITCHES -/* Processor type. Order must match cpu attribute in MD file. */ +/* Processor type. Order must match cpu attribute in MD file. + Please keep all Power4 type processors using "at" branch hints + after PROCESSOR_POWER4, and those using the "y" branch hints, + before. */ enum processor_type { PROCESSOR_RIOS1, -- Alan Modra IBM OzLabs - Linux Technology Centre