[Python-Dev] String hash function multiplier

Jeff Epler jepler at unpythonic.net
Wed Apr 14 15:33:59 EDT 2004

On Wed, Apr 14, 2004 at 11:34:13PM +1000, Andrew MacIntyre wrote:
> Ummm...  are you showing what you think you're showing here?  As I recall,
> i386 gcc uses -mcpu and -march differently to most other architectures:
> - -mcpu just sets scheduling parameters, but not instruction set;
> - -march sets the instruction set.

I'm pretty sure I am. (I'm not sure why I used -march on the
long-at-a-time version, though)

imul is on all x86 architectures, but whether to use it or not depends
on the characteristics of the target CPU.  With -mcpu=i386, imul is
considered quite slow and a shift sequence is (almost?) always preferred
when one operand is constant.  With -mcpu=i686 and newer, imul seems to
be preferred.

I did actually inspect the generated assembly with -mcpu=i386 and
-mcpu=i686, though I didn't look at it for all the combinations I


More information about the Python-Dev mailing list