[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 08/10 v11] target-tilegx: Add several helpers fo
From: |
Richard Henderson |
Subject: |
Re: [Qemu-devel] [PATCH 08/10 v11] target-tilegx: Add several helpers for instructions translation |
Date: |
Mon, 01 Jun 2015 09:02:11 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
On 05/30/2015 02:17 PM, Chen Gang wrote:
> + for (count = 0; count < 8; count++) {
> + sel = (rsrcb >> (count * 8)) & 0xf;
> + if (sel < 8) {
> + vdst |= ((rdst >> (8 * sel)) & 0xff) << (count * 8);
> + } else {
> + vdst |= ((rsrc >> (8 * (8 - sel))) & 0xff) << (count * 8);
8 - sel is wrong; you wanted sel - 8.
That said, you can do better with masking operations. And for brevity, let
count increment by 8. E.g.
uint64_t vdst = 0;
int count;
for (count = 0; count < 64; count += 8) {
uint64_t sel = rsrcb >> count;
uint64_t src = (sel & 8 ? rsrc : rdst);
vdst |= ((src >> ((sel & 7) * 8)) & 0xff) << count;
}
r~
- Re: [Qemu-devel] [PATCH 08/10 v11] target-tilegx: Add several helpers for instructions translation,
Richard Henderson <=