Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating fastest Mul31



Hello, all.
I am interested what would be fastest implementation of the following multiplication:


#define Mul31(x,y) ((int32)(((int64)(x) * (y)) >> 31))

obviously, int32 and int64 are signed 32 and 64 integers.

Currently i am using:
inline int32 Mul31(int32 x, int32 y)
{
  register int hi_prod, lo_prod, result;
  asm
  {
    mullw lo_prod, x, y
    srwi lo_prod, lo_prod, 31

    mulhw hi_prod, x, y
    slwi hi_prod, hi_prod, 1

    or result, hi_prod, lo_prod;
  }
  return result;
}

Is it possible to make it faster? Target CPUs are PPC G4 and G5, and compiler are gcc 3.3 and 4.x Thank you in advance.

--
Sincerely,
	Rustam Muginov

_______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/perfoptimization-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.