vec_mergeh/l operates differently for BE and LE, because of the order of
the vector elements (l->r in BE and r->l in LE).
To fix that, we simply need to swap between the input parameters, in case
we are working in LE.

v2:

- replace _LITTLE_ENDIAN with WORDS_BIGENDIAN for consistency
- fixed whitespaces and indentation issues

Signed-off-by: Oded Gabbay <oded.gab...@gmail.com>
Reviewed-by: Adam Jackson <a...@redhat.com>
---
 pixman/pixman-vmx.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/pixman/pixman-vmx.c b/pixman/pixman-vmx.c
index c963c28..cef921f 100644
--- a/pixman/pixman-vmx.c
+++ b/pixman/pixman-vmx.c
@@ -57,12 +57,22 @@ pix_multiply (vector unsigned int p, vector unsigned int a)
 
     /* unpack to short */
     hi = (vector unsigned short)
+#ifdef WORDS_BIGENDIAN
        vec_mergeh ((vector unsigned char)AVV (0),
                    (vector unsigned char)p);
+#else
+       vec_mergeh ((vector unsigned char) p,
+                   (vector unsigned char) AVV (0));
+#endif
 
     mod = (vector unsigned short)
+#ifdef WORDS_BIGENDIAN
        vec_mergeh ((vector unsigned char)AVV (0),
                    (vector unsigned char)a);
+#else
+       vec_mergeh ((vector unsigned char) a,
+                   (vector unsigned char) AVV (0));
+#endif
 
     hi = vec_mladd (hi, mod, (vector unsigned short)
                     AVV (0x0080, 0x0080, 0x0080, 0x0080,
@@ -74,11 +84,22 @@ pix_multiply (vector unsigned int p, vector unsigned int a)
 
     /* unpack to short */
     lo = (vector unsigned short)
+#ifdef WORDS_BIGENDIAN
        vec_mergel ((vector unsigned char)AVV (0),
                    (vector unsigned char)p);
+#else
+       vec_mergel ((vector unsigned char) p,
+                   (vector unsigned char) AVV (0));
+#endif
+
     mod = (vector unsigned short)
+#ifdef WORDS_BIGENDIAN
        vec_mergel ((vector unsigned char)AVV (0),
                    (vector unsigned char)a);
+#else
+       vec_mergel ((vector unsigned char) a,
+                   (vector unsigned char) AVV (0));
+#endif
 
     lo = vec_mladd (lo, mod, (vector unsigned short)
                     AVV (0x0080, 0x0080, 0x0080, 0x0080,
-- 
2.4.3

_______________________________________________
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman

Reply via email to