Patchwork [07/10] target-i386: SSE4.2: fix pcmpXstrX instructions in "Equal ordered" mode

login
register
mail settings
Submitter Aurelien Jarno
Date March 26, 2013, 7:01 p.m.
Message ID <1364324502-9124-8-git-send-email-aurelien@aurel32.net>
Download mbox | patch
Permalink /patch/231517/
State New
Headers show

Comments

Aurelien Jarno - March 26, 2013, 7:01 p.m.
The inner loop should only change the current bit of the result, instead
of the whole result.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 target-i386/ops_sse.h |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Richard Henderson - March 27, 2013, 8:19 p.m.
On 03/26/2013 12:01 PM, Aurelien Jarno wrote:
> The inner loop should only change the current bit of the result, instead
> of the whole result.
> 
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
>  target-i386/ops_sse.h |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

Patch

diff --git a/target-i386/ops_sse.h b/target-i386/ops_sse.h
index 2fc5fdd..77ab410 100644
--- a/target-i386/ops_sse.h
+++ b/target-i386/ops_sse.h
@@ -2036,10 +2036,11 @@  static inline unsigned pcmpxstrx(CPUX86State *env, Reg *d, Reg *s,
     case 3:
         for (j = valids - validd; j >= 0; j--) {
             res <<= 1;
-            res |= 1;
+            v = 1;
             for (i = MIN(upper - j, validd); i >= 0; i--) {
-                res &= (pcmp_val(s, ctrl, i + j) == pcmp_val(d, ctrl, i));
+                v &= (pcmp_val(s, ctrl, i + j) == pcmp_val(d, ctrl, i));
             }
+            res |= v;
         }
         break;
     }