https://github.com/pkubaj created
https://github.com/llvm/llvm-project/pull/224328
The big-endian vbpermq permute constant in the ppc_wrappers
_mm_movemask_ps lists the four sign-bit indices as 0x00 0x20 0x40 0x60,
which lands element 0 in the most significant of the four result bits.
x86 semantics (and the little-endian branch) put element 0 in bit 0.
Reverse the index order so big-endian returns the same mask as x86.
Verified on FreeBSD/powerpc64 (POWER9, -mcpu=power8): for the inputs
{-1,2,-3,4} and {1,2,3,-4} the header returned 10 and 1 instead of 5
and 8; embree's BVH traversal, which selects child nodes from this
mask, crashed with a wild pointer. _mm_movemask_pd and
_mm_movemask_epi8 already produce x86-compatible results on both
endians.
Assisted-by: Claude Fable 5.1
>From 15fc4b2613388c08e779cbe8cb61d018e21213e8 Mon Sep 17 00:00:00 2001
From: Piotr Kubaj <[email protected]>
Date: Wed, 16 Sep 2026 15:41:03 +0200
Subject: [PATCH] Fix _mm_movemask_ps bit order on big-endian
The big-endian vbpermq permute constant in the ppc_wrappers
_mm_movemask_ps lists the four sign-bit indices as 0x00 0x20 0x40 0x60,
which lands element 0 in the most significant of the four result bits.
x86 semantics (and the little-endian branch) put element 0 in bit 0.
Reverse the index order so big-endian returns the same mask as x86.
Verified on FreeBSD/powerpc64 (POWER9, -mcpu=power8): for the inputs
{-1,2,-3,4} and {1,2,3,-4} the header returned 10 and 1 instead of 5
and 8; embree's BVH traversal, which selects child nodes from this
mask, crashed with a wild pointer. _mm_movemask_pd and
_mm_movemask_epi8 already produce x86-compatible results on both
endians.
Assisted-by: Claude Fable 5.1
---
clang/lib/Headers/ppc_wrappers/xmmintrin.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Headers/ppc_wrappers/xmmintrin.h
b/clang/lib/Headers/ppc_wrappers/xmmintrin.h
index 9dd21b65c2f70..96a309be25b29 100644
--- a/clang/lib/Headers/ppc_wrappers/xmmintrin.h
+++ b/clang/lib/Headers/ppc_wrappers/xmmintrin.h
@@ -1318,7 +1318,7 @@ extern __inline int
#ifdef __LITTLE_ENDIAN__
0x00204060, 0x80808080, 0x80808080, 0x80808080
#else
- 0x80808080, 0x80808080, 0x80808080, 0x00204060
+ 0x80808080, 0x80808080, 0x80808080, 0x60402000
#endif
};
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits