qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v1 09/41] s390x/tcg: Implement VECTOR CHECKSUM


From: David Hildenbrand
Subject: Re: [Qemu-devel] [PATCH v1 09/41] s390x/tcg: Implement VECTOR CHECKSUM
Date: Tue, 16 Apr 2019 10:58:25 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

On 13.04.19 01:01, Richard Henderson wrote:
> On 4/11/19 12:08 AM, David Hildenbrand wrote:
>> +    read_vec_element_i32(sum, get_field(s->fields, v3), 1, ES_32);
>> +    for (i = 0; i < 4; i++) {
>> +        read_vec_element_i32(tmp, get_field(s->fields, v2), i, ES_32);
>> +        tcg_gen_add_i32(sum, sum, tmp);
>> +        tcg_gen_setcond_i32(TCG_COND_LTU, tmp, sum, tmp);
>> +        tcg_gen_add_i32(sum, sum, tmp);
>> +    }
>> +    zero_vec(get_field(s->fields, v1));
>> +    write_vec_element_i32(sum, get_field(s->fields, v1), 1, ES_32);
> 
> It seems like it should be possible to implement this with i64, and fold the
> carry around at the end -- 2 insns instead of 12 for managing carry.  But I
> can't quite tell if that produces the same results.

I had the same in mind but also wasn't sure if it would produce the
exact same result. Feels like it should.
> 
> You could use
> 
>   tcg_gen_add2_i32(sum, tmp, sum, zero, tmp, zero);
>   tcg_gen_add_i32(sum, sum, tmp);

That makes perfect sense, I will use that for now, thanks!

> 
> instead of computing carry manually with setcond.
> 
> That said, your code exactly matches the language in the manual, so
> 
> Reviewed-by: Richard Henderson <address@hidden>
> 
> 
> r~
> 


-- 

Thanks,

David / dhildenb



reply via email to

[Prev in Thread] Current Thread [Next in Thread]