]> xenbits.xensource.com Git - qemu-upstream-4.5-testing.git/commitdiff
target-mips: Fix helper and tests for dot/cross-dot product instructions
authorPetar Jovanovic <petarj@mips.com>
Wed, 2 Jan 2013 04:08:48 +0000 (05:08 +0100)
committerAurelien Jarno <aurelien@aurel32.net>
Tue, 8 Jan 2013 10:58:43 +0000 (11:58 +0100)
Helper function for dpa_w_ph, dpax_w_ph, dps_w_ph and dpsx_w_ph incorrectly
defines halfword vector elements as unsigned values. This results in wrong
output which is not triggered in the tests as they also follow this logic.

Signed-off-by: Petar Jovanovic <petarj@mips.com>
Reviewed-by: Eric Johnson <ericj@mips.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
target-mips/dsp_helper.c
tests/tcg/mips/mips32-dspr2/dpa_w_ph.c
tests/tcg/mips/mips32-dspr2/dpax_w_ph.c
tests/tcg/mips/mips32-dspr2/dps_w_ph.c
tests/tcg/mips/mips32-dspr2/dpsx_w_ph.c

index a33e2bf9fd22d3253744f335a648c4ee0254bff1..4870e3dbbc1d5dd6ed19965ff34deabb38e2380b 100644 (file)
@@ -2473,7 +2473,7 @@ DP_OB(dpsu_h_obr, 0, 24, 16, 8, 0, 24, 16, 8, 0);
 void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt,              \
                    CPUMIPSState *env)                                          \
 {                                                                              \
-    uint16_t rsB, rsA, rtB, rtA;                                               \
+    int16_t rsB, rsA, rtB, rtA;                                                \
     int32_t  tempA, tempB;                                                     \
     int64_t  acc;                                                              \
                                                                                \
index 1cfbdb080f1e7e719eeb4fec34a55d2842c4a465..fae49f10eb952451dde8a163dc4a6508d2e1bb77 100644 (file)
@@ -26,8 +26,8 @@ int main()
     ach = 6, acl = 7;
     rs     = 0xFFFF00FF;
     rt     = 0xFFFF0002;
-    resulth = 0x05;
-    resultl = 0xfffe0206;
+    resulth = 0x06;
+    resultl = 0x206;
     __asm
         ("mthi  %0, $ac1\n\t"
          "mtlo  %1, $ac1\n\t"
index f75699755c3b7cb606a754c18c98bd3cca67d6a0..514797cfd1b454ae54ebc8c74447743a51c1cc48 100644 (file)
@@ -23,5 +23,22 @@ int main()
     assert(ach == resulth);
     assert(acl == resultl);
 
+    ach = 6, acl = 7;
+    rs     = 0xFFFF00FF;
+    rt     = 0xFFFF0002;
+    resulth = 0x05;
+    resultl = 0xFFFFFF06;
+    __asm
+        ("mthi  %0, $ac1\n\t"
+         "mtlo  %1, $ac1\n\t"
+         "dpax.w.ph $ac1, %2, %3\n\t"
+         "mfhi  %0, $ac1\n\t"
+         "mflo  %1, $ac1\n\t"
+         : "+r"(ach), "+r"(acl)
+         : "r"(rs), "r"(rt)
+        );
+    assert(ach == resulth);
+    assert(acl == resultl);
+
     return 0;
 }
index 8303643d187f6ac1ec8df8c3905aeb3ec223692d..f51f9b9d13d711ce6f78e0f9d8043aad7c3bf640 100644 (file)
@@ -23,5 +23,22 @@ int main()
     assert(ach == resulth);
     assert(acl == resultl);
 
+    ach = 6, acl = 7;
+    rs     = 0xFFFF00FF;
+    rt     = 0xFFFF0002;
+    resulth = 0x05;
+    resultl = 0xFFFFFE08;
+    __asm
+        ("mthi  %0, $ac1\n\t"
+         "mtlo  %1, $ac1\n\t"
+         "dps.w.ph $ac1, %2, %3\n\t"
+         "mfhi  %0, $ac1\n\t"
+         "mflo  %1, $ac1\n\t"
+         : "+r"(ach), "+r"(acl)
+         : "r"(rs), "r"(rt)
+        );
+    assert(ach == resulth);
+    assert(acl == resultl);
+
     return 0;
 }
index 6db59a4ccdf484b197156efd33ef8335a599b1d8..bb49a4031d34731c2b8f25364e10f16b0e225abd 100644 (file)
@@ -9,8 +9,8 @@ int main()
 
     rs      = 0xBC0123AD;
     rt      = 0x01643721;
-    resulth = 0x04;
-    resultl = 0xD751F050;
+    resulth = 0x05;
+    resultl = 0xE72F050;
     __asm
         ("mthi  %0, $ac1\n\t"
          "mtlo  %1, $ac1\n\t"