This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [patch] (4.1 stage 2 projects): vectorize reduction, part 3/n


Richard Henderson wrote:

On Tue, Jun 21, 2005 at 09:03:48AM +0200, Paolo Bonzini wrote:


I think min and max should be implemented in term of unsigned saturated subtraction for unsigned values.



Hmm, yes.


uminv8hi:
	movdqa	a, t1
	psubusw	b, t1	/* t1[n] == 0 iff b[n] >= a[n] */
	pxor	t2, t2
	pcmpeqw	t1, t2	/* t2[n] = b[n] < a[n] ? -1 : 0 */
	movdqa	t2, t3
	pand	a, t3
	pandn	b, t2
	por	t3, t2

I had in mind something like

uminv8hi:
       movdqa  a, t1
       movdqa  t1, t2
       psubusw b, t2   /* t2 = b[n] >= a[n] ? 0 : a[n] - b[n] */
       psubw   t1, t2     /* t1 = b[n] >= a[n] ? a[n] : b[n] */

For maximum, I could not come up with anything better than this

umaxv8hi:
       movdqa  a, t1
       movdqa  t1, t2
       psubusw b, t2   /* t2 = b[n] >= a[n] ? 0 : a[n] - b[n] */
       psubw   t1, t2     /* t1 = b[n] >= a[n] ? a[n] : b[n] */
       pxor      t1, t2     /* t2 = a[n] ^ min(a[n], b[n]) */
       pxor      b, t2      /* t2 = a[n] ^ b[n] ^ min(a[n], b[n]) */

which has a lot of dependencies, but very low register pressure.

Paolo


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