home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / aix / 12954 < prev    next >
Encoding:
Text File  |  1993-01-03  |  1.9 KB  |  74 lines

  1. Newsgroups: comp.unix.aix
  2. Path: sparky!uunet!think.com!enterpoop.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jfc
  3. From: jfc@athena.mit.edu (John F Carr)
  4. Subject: Re: RS/6000 Integer Multiply Instruction
  5. Message-ID: <1993Jan3.172528.27328@athena.mit.edu>
  6. Sender: news@athena.mit.edu (News system)
  7. Nntp-Posting-Host: achates.mit.edu
  8. Organization: Massachusetts Institute of Technology
  9. References: <1i58g8INNk0j@msuinfo.cl.msu.edu>
  10. Date: Sun, 3 Jan 1993 17:25:28 GMT
  11. Lines: 61
  12.  
  13. In article <1i58g8INNk0j@msuinfo.cl.msu.edu> mrr@scss3.cl.msu.edu (Mark Riordan) writes:
  14. >On architectures with which I am familiar, I have been able to
  15. >speed up RIPEM by 50% or more simply by:
  16. >
  17. >  1. Feeding the C source through the compiler to get assembly output, 
  18. >  2. Replacing the lengthy and obtuse code needed to do the multiply 
  19. >     portably with the appropriate instruction for that platform,
  20. >  3. Feeding the resultant assembly source to the assembler.
  21.  
  22. >I can get xlc to put out an assembly *listing*, but not assembly
  23. >source code that can be fed to a compiler.  I obtained and installed
  24. >GNU C to solve that problem.  But I still can't figure out how to
  25. >access the MQ register.
  26.  
  27. If you have gcc, try using the built in "long long" type.
  28.  
  29.  
  30. This source file:
  31.  
  32.     long long mul32x32(int x, int y)
  33.     {
  34.       return (long long)x * (long long)y;
  35.     }
  36.     unsigned long long umul32x32(unsigned int x, unsigned int y)
  37.     {
  38.       return (unsigned long long)x * (unsigned long long)y;
  39.     }
  40.  
  41. compiles to this assembly:
  42.  
  43. .mul32x32:
  44.     mul 3,3,4
  45.     mfmq 4
  46.     br
  47.  
  48. .umul32x32:
  49.     ai 11,3,0
  50.     ai 7,4,0
  51.     ai 12,11,0
  52.     cal 11,0(0)
  53.     ai 8,7,0
  54.     cal 7,0(0)
  55.     mul 3,12,8
  56.     mfmq 4
  57.     sri 9,12,31
  58.     a 9,9,11
  59.     sri 0,8,31
  60.     a 0,0,7
  61.     muls 0,0,12
  62.     a 3,3,0
  63.     muls 9,9,8
  64.     a 3,3,9
  65.     br
  66.  
  67. gcc allocates 64 bit integers in consecutive registers, so the function
  68. return value is in r3:r4.
  69.  
  70. "ai <x>,<y>,0" is the instruction gcc uses for a register-register move.
  71.  
  72. --
  73.     John Carr (jfc@athena.mit.edu)
  74.