www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/27/15:13:33

From: beppu AT rigel DOT oac DOT uci DOT edu (John Beppu)
Newsgroups: comp.os.msdos.djgpp
Subject: [??] coaxing gcc into generating better code
Date: 27 Jan 1997 13:59:46 GMT
Organization: University of California, Irvine
Lines: 92
Message-ID: <5cicci$ljs@news.service.uci.edu>
NNTP-Posting-Host: rigel.oac.uci.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

    static bUINT32 L0=0;	// NOTE THAT L0 IS *STATIC* 

    /* whiteSpaceBMP ...................
    default {
        0x09 tab
        0x0a line feed
        0x0d carriage return
        0x20 space
    }
    */
 
    whiteSpaceBMP[0] = 0x00002600;  // 09,0a,0d
    whiteSpaceBMP[1] = 0x00000001;  // 20
    whiteSpaceBMP[2] = L0;
    whiteSpaceBMP[3] = L0;
    whiteSpaceBMP[4] = L0;
    whiteSpaceBMP[5] = L0;
    whiteSpaceBMP[6] = L0;
    whiteSpaceBMP[7] = L0;

____asm generated by above sequence____

        movl $9728,1184(%edx)
        movl $1,1188(%edx)
        movl _L0.2,%eax
        movl %eax,1192(%edx)
        movl %eax,1196(%edx)
        movl %eax,1200(%edx)
        movl %eax,1204(%edx)
        movl %eax,1208(%edx)
        movl %eax,1212(%edx)

____asm generated when L0 is *NOT* static____

        movl $9728,1184(%eax)
        movl $1,1188(%eax)
        movl $0,1192(%eax)
        movl $0,1196(%eax)
        movl $0,1200(%eax)
        movl $0,1204(%eax)
        movl $0,1208(%eax)
        movl $0,1212(%eax)

  /* How horrible the second assembly output is.  It's no good for
     486 and terrible for P5.  (I don't know how P6 will feel about
     it.)  The command line parameters I invoked gcc with were:

     -S			// assembly output
     -O2		// optimizations
     -fforce-addr	// put ptrs into registers?
     -fomit-frame-pointer
			// uses esp for stackframe and frees ebp

  */ 


  
  [Can this be done?]

  I would like to have L0 not be static, but for the constant 0's to
  be placed in a register.  Without resorting to assembly, is there
  something I can do about this.  

  In other words, I want L0 to not be static and produce output that
  looks like the first assembly output.

  I don't want instructions which have both a constant and a constant
  displacement like the second example.  (Such instructions have no
  chance of pairing on a Pentium).

  
  hmmm.....   If I were to take the address of L0 like
  {
    &L0;

    // and then do

    L0 = 0;

    // and then write to the array
  }

  ...would that coax gcc into placing 0 into a register before doing
  the mov's?  Any help is appreciated.  Thanks in advance to those
  (if any) who reply.




-- 
  beppu AT uci DOT edu .............................................................

- Raw text -


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