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 <richard.hender...@linaro.org> > > > r~ > -- Thanks, David / dhildenb