diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2022-08-25 17:46:36 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-09-01 08:37:04 +0200 |
commit | 75046ad72eaaae954849e2b793b6f629befb4ebc (patch) | |
tree | d0029901e144a2b1f42ad25ca30fd226968e51aa /target | |
parent | 7b764d41733075624bf7d93b3e1ff9aa8f66f563 (diff) | |
download | qemu-75046ad72eaaae954849e2b793b6f629befb4ebc.zip qemu-75046ad72eaaae954849e2b793b6f629befb4ebc.tar.gz qemu-75046ad72eaaae954849e2b793b6f629befb4ebc.tar.bz2 |
target/i386: fix PHSUB* instructions with dest=src
The computation must not overwrite neither the destination
nor the source before the last element has been computed.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target')
-rw-r--r-- | target/i386/ops_sse.h | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index 535440f..2524db4 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -1528,34 +1528,43 @@ void glue(helper_pmaddubsw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) void glue(helper_phsubw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) { - d->W(0) = (int16_t)d->W(0) - (int16_t)d->W(1); - d->W(1) = (int16_t)d->W(2) - (int16_t)d->W(3); - XMM_ONLY(d->W(2) = (int16_t)d->W(4) - (int16_t)d->W(5)); - XMM_ONLY(d->W(3) = (int16_t)d->W(6) - (int16_t)d->W(7)); - d->W((2 << SHIFT) + 0) = (int16_t)s->W(0) - (int16_t)s->W(1); - d->W((2 << SHIFT) + 1) = (int16_t)s->W(2) - (int16_t)s->W(3); - XMM_ONLY(d->W(6) = (int16_t)s->W(4) - (int16_t)s->W(5)); - XMM_ONLY(d->W(7) = (int16_t)s->W(6) - (int16_t)s->W(7)); + Reg r; + + r.W(0) = (int16_t)d->W(0) - (int16_t)d->W(1); + r.W(1) = (int16_t)d->W(2) - (int16_t)d->W(3); + XMM_ONLY(r.W(2) = (int16_t)d->W(4) - (int16_t)d->W(5)); + XMM_ONLY(r.W(3) = (int16_t)d->W(6) - (int16_t)d->W(7)); + r.W((2 << SHIFT) + 0) = (int16_t)s->W(0) - (int16_t)s->W(1); + r.W((2 << SHIFT) + 1) = (int16_t)s->W(2) - (int16_t)s->W(3); + XMM_ONLY(r.W(6) = (int16_t)s->W(4) - (int16_t)s->W(5)); + XMM_ONLY(r.W(7) = (int16_t)s->W(6) - (int16_t)s->W(7)); + MOVE(*d, r); } void glue(helper_phsubd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) { - d->L(0) = (int32_t)d->L(0) - (int32_t)d->L(1); - XMM_ONLY(d->L(1) = (int32_t)d->L(2) - (int32_t)d->L(3)); - d->L((1 << SHIFT) + 0) = (int32_t)s->L(0) - (int32_t)s->L(1); - XMM_ONLY(d->L(3) = (int32_t)s->L(2) - (int32_t)s->L(3)); + Reg r; + + r.L(0) = (int32_t)d->L(0) - (int32_t)d->L(1); + XMM_ONLY(r.L(1) = (int32_t)d->L(2) - (int32_t)d->L(3)); + r.L((1 << SHIFT) + 0) = (int32_t)s->L(0) - (int32_t)s->L(1); + XMM_ONLY(r.L(3) = (int32_t)s->L(2) - (int32_t)s->L(3)); + MOVE(*d, r); } void glue(helper_phsubsw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) { - d->W(0) = satsw((int16_t)d->W(0) - (int16_t)d->W(1)); - d->W(1) = satsw((int16_t)d->W(2) - (int16_t)d->W(3)); - XMM_ONLY(d->W(2) = satsw((int16_t)d->W(4) - (int16_t)d->W(5))); - XMM_ONLY(d->W(3) = satsw((int16_t)d->W(6) - (int16_t)d->W(7))); - d->W((2 << SHIFT) + 0) = satsw((int16_t)s->W(0) - (int16_t)s->W(1)); - d->W((2 << SHIFT) + 1) = satsw((int16_t)s->W(2) - (int16_t)s->W(3)); - XMM_ONLY(d->W(6) = satsw((int16_t)s->W(4) - (int16_t)s->W(5))); - XMM_ONLY(d->W(7) = satsw((int16_t)s->W(6) - (int16_t)s->W(7))); + Reg r; + + r.W(0) = satsw((int16_t)d->W(0) - (int16_t)d->W(1)); + r.W(1) = satsw((int16_t)d->W(2) - (int16_t)d->W(3)); + XMM_ONLY(r.W(2) = satsw((int16_t)d->W(4) - (int16_t)d->W(5))); + XMM_ONLY(r.W(3) = satsw((int16_t)d->W(6) - (int16_t)d->W(7))); + r.W((2 << SHIFT) + 0) = satsw((int16_t)s->W(0) - (int16_t)s->W(1)); + r.W((2 << SHIFT) + 1) = satsw((int16_t)s->W(2) - (int16_t)s->W(3)); + XMM_ONLY(r.W(6) = satsw((int16_t)s->W(4) - (int16_t)s->W(5))); + XMM_ONLY(r.W(7) = satsw((int16_t)s->W(6) - (int16_t)s->W(7))); + MOVE(*d, r); } #define FABSB(_, x) (x > INT8_MAX ? -(int8_t)x : x) |