This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

i386 performance problem due to regmove.c change


I've been noticing a performance hit on the i386 due to the
June 11 regmove.c change.  Attached is a sample program which
demostrates the problem.  The results of running this program
on a 233 MHz Pentium II running FreeBSD-current is:

19980703 egcs-current -O             9.7 seconds

19980703 egcs-current -O -fregmove  12.2 seconds

19980703 egcs-current -O -fregmove   9.7 seconds
         using 19980608 regmove

Is the June 11 change to regmove helpful in enough situations to
warrant leaving it in egcs even though it hurts the i386 in some
situations?

-- John
-----------------8<----------------------8<---------------------
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#  define ChangeSide(x) ((x)^1)

int last[2][2];

struct {
  int position;
  int status;
  } book_buffer[2];

void
MakeMove(int a, int b)
  {

  last[0][0] = a + b;
  }

int
Xor(int a, int b)
  {

  return a ^ b;
  }

int
RepetitionCheck(int a, int b)
  {

  return a < b;
  }

int
Random32()
  {

  return last[0][0];
  }

int
Max(int a, int b)
  {

  return (a > b) ? a : b;
  }

int Book(int wtm) {
  static int bs_won[2];
  int i, which;
  int *mv;
  int nmoves;
  int distribution;

  for (mv=last[0];mv<last[1];mv++) {
    MakeMove(*mv,wtm);
    if (RepetitionCheck(2,ChangeSide(wtm))) {
      return(0);
      }
    }

  nmoves=0;
  for (mv=last[0];mv<last[1];mv++) {
    MakeMove(*mv,wtm);
    if (RepetitionCheck(2,ChangeSide(wtm))) {
      return(0);
      }
    for (i=0;i<wtm;i++) {
      if (!Xor(wtm,book_buffer[i].position)) {
          bs_won[nmoves++]=book_buffer[i].status;
        break;
        }
      }
    }

  which=Random32();
  distribution=abs(which) % Max(nmoves,1);
  for (which=0;which<nmoves;which++) {
    distribution-=bs_won[which];
    }
  return(distribution);
}

main()
  {
  int a;
  int i;

  a = 0;
  for (i = 0; i < 10000000; i++)
    a += Book(0);
  return a;
  }
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]