www.delorie.com/archives/browse.cgi   search  
Mail Archives: pgcc/1999/09/26/18:38:39.1

Message-Id: <3.0.32.19990926230735.00c74930@pop.xs4all.nl>
X-Sender: diep AT pop DOT xs4all DOT nl (Unverified)
X-Mailer: Windows Eudora Pro Version 3.0 (32)
Date: Sun, 26 Sep 1999 23:07:37 +0100
To: pgcc AT delorie DOT com
From: Vincent Diepeveen <diep AT xs4all DOT nl>
Subject: using cmov* not that great
Cc: pcg AT goof DOT com, "Robert M. Hyatt" <hyatt AT cis DOT uab DOT edu>
Mime-Version: 1.0
Reply-To: pgcc AT delorie DOT com

Hello,

In my megabytes of C source code gcc 2.95 uses only 259
movnn. In the crucial code (evaluation of my chessprogram)
where it can be used bigtime it only uses it out of all
many thousands of times it can easily use it only about 200 times.
other 59 times are in interface, time division, search etc.

For my search inside loops very important is next pattern:

int *p,u,*array;

if( !PATTERN )
  p += array[u];

Now pattern checks for zero. So if non-zero then
p += array[u] is applied.

Pattern is also an array reference. something like !s[t[u]]

For my eval combination of patterns is more important:
where l = something logical as && or || and also ( and )
#define VALUE 1
int s;
if( PATTERN l PATTERN l PATTERN | PATTERN )
  s += VALUE;

For all branches it's such that they're not in the BTB.
BTB is just a laughable 512 entries at the PRO/PII processor,
and assuming FIFO is used for it, then it'll never see the same
branch much, as i'm talking about many tens of thousands of branches,
from which in 1 eval most are not taken as they are grouped by
general patterns. 

So the 90% prediction rate that intel claims is a major joke,
as fall through is hard to realize without cmovxx instructions.

The general patterns sure are hard to rewrite:

  if( GENERAL PATTERN ) {
    if( PATTERN l PATTERN l PATTERN ) 
      s += SCORE_XXXX;

    if( PATTERN l PATTERN l PATTERN ) 
      s += SCORE_YXXX;

    if( PATTERN l PATTERN l PATTERN ) 
      s += SCORE_XXXX;
   }

So to fall through i would have to do next:
   if( !GENERALPATTERN ) {
     // nothing
   } 
   else {
    if( PATTERN l PATTERN l PATTERN ) 
      s += SCORE_XXXX;

    if( PATTERN l PATTERN l PATTERN ) 
      s += SCORE_YXXX;

    if( PATTERN l PATTERN l PATTERN ) 
      s += SCORE_XXXX;  
   }

Question: is above rewrite smart?
Is there an easier way to get fall through?

For me as a human writing the opposite of the pattern is now what i like
to do. In the end it's me maintaining all the patterns!

Greetings,
Vincent






Vincent Diepeveen
diep AT xs4all DOT nl

---
...en verder ben ik van mening dat Dap het heelal in 
dient te worden gestraald...

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019