[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] target/ppc: add vmsumudm vmsumcud instructions
From: |
Richard Henderson |
Subject: |
Re: [PATCH v2] target/ppc: add vmsumudm vmsumcud instructions |
Date: |
Fri, 19 Jun 2020 13:45:08 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 |
On 6/18/20 10:10 PM, Lijun Pan wrote:
>> Unfortunately, I can't find the v3.1 spec online yet, so I can't look at this
>> myself. What is the instruction supposed to produce?
>
> https://ibm.ent.box.com/s/hhjfw0x0lrbtyzmiaffnbxh2fuo0fog0
Thank you. So it really is the sum of an input and two separate 64x64->128 bit
multiplies.
I suggest
void helper_vmsumudm(CPUPPCState *env, ppc_avr_t *r,
ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
{
Int128 sum;
uint64_t lo, hi;
sum = int128_make128(c->VsrD(1), c->VsrD(0));
mulu64(&lo, &hi, a->VsrD(0), b->VsrD(0));
sum = int128_add(sum, int128_make128(lo, hi));
mulu64(&lo, &hi, a->VsrD(1), b->VsrD(1));
sum = int128_add(sum, int128_make128(lo, hi));
r->VsrD(0) = int128_gethi(sum);
r->VsrD(1) = int128_getlo(sum);
}
void helper_vmsumcud(CPUPPCState *env, ppc_avr_t *r,
ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
{
Int128 sum;
uint64_t p1lo, p1hi, p2lo, p2hi;
mulu64(&p1lo, &p1hi, a->VsrD(0), b->VsrD(0));
mulu64(&p2lo, &p2hi, a->VsrD(1), b->VsrD(1));
/* Sum lowest 64-bit elements. */
sum = int128_make128(c->VsrD(1), 0);
sum = int128_add(sum, int128_make128(p1lo, 0));
sum = int128_add(sum, int128_make128(p2lo, 0));
/*
* Discard low 64-bits, leaving the carry into bit 64.
* Then sum the higher 64-bit elements.
*/
sum = int128_rshift(sum, 64);
sum = int128_add(sum, int128_make128(c->VsrD(0), 0));
sum = int128_add(sum, int128_make128(p1hi, 0));
sum = int128_add(sum, int128_make128(p2hi, 0));
/* The result is only the carry into bits 64 & 65. */
r->VsrD(1) = int128_gethi(sum);
r->VsrD(0) = 0;
}
r~