Fix some Neon insns on big-endian hosts
cover Fix some Neon insns on big-endian hosts
This patchseries fixes a couple of places where the vector helpers we use for Neon insns were missing uses of the address-swizzling macros H1(), H2() or H4(). This is harmless on little-endian hosts but causes the wrong results to be generated on big-endian hosts. The affected insns are VUDOT(scalar), VSDOT(scalar), VPADD, VPMAX and VPMIN.
This series is independent of Richard's recent "target/arm:
Fix neon reg offsets"; it fixes the handful of remaining risu test failures I see.
thanks
-- PMM
Peter Maydell (2):
target/arm: Fix float16 pairwise Neon ops on big-endian hosts target/arm: Fix VUDOT/VSDOT (scalar) on big-endian hosts
target/arm/vec_helper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/2 target/arm: Fix float16 pairwise Neon ops on big-endian hosts
In the neon_padd/pmax/pmin helpers for float16, a cut-and-paste error meant we were using the H4() address swizzler macro rather than the H2() which is required for 2-byte data. This had no effect on little-endian hosts but meant we put the result data into the destination Dreg in the wrong order on big-endian hosts.
--- target/arm/vec_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/arm/vec_helper.c +4 -4
@@ -1858,10 +1858,10 @@ DO_ABA(gvec_uaba_d, uint64_t) r2 = float16_##OP(m[H2(0)], m[H2(1)], fpst); \ r3 = float16_##OP(m[H2(2)], m[H2(3)], fpst); \ \ - d[H4(0)] = r0; \ - d[H4(1)] = r1; \ - d[H4(2)] = r2; \ - d[H4(3)] = r3; \ + d[H2(0)] = r0; \ + d[H2(1)] = r1; \ + d[H2(2)] = r2; \ + d[H2(3)] = r3; \ }DO_NEON_PAIRWISE (neon_padd, add)
Signature · 1 line
2.20.1
Re: [PATCH 1/2] target/arm: Fix float16 pairwise Neon ops on big-endian hosts
Quoted 10 lines · Peter Maydell
In the neon_padd/pmax/pmin helpers for float16, a cut-and-paste error meant we were using the
H4()address swizzler macro rather than theH2()which is required for 2-byte data. This had no effect on little-endian hosts but meant we put the result data into the destination Dreg in the wrong order on big-endian hosts.Signed-off-by Peter Maydell <[email protected]>--- target/arm/vec_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Philippe Mathieu-Daudé
Tested-byRe: [PATCH 1/2] target/arm: Fix float16 pairwise Neon ops on big-endian hosts
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Peter Maydell
In the neon_padd/pmax/pmin helpers for float16, a cut-and-paste error meant we were using the
H4()address swizzler macro rather than theH2()which is required for 2-byte data. This had no effect on little-endian hosts but meant we put the result data into the destination Dreg in the wrong order on big-endian hosts.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Peter Maydell <[email protected]>--- target/arm/vec_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)Reviewed-by Philippe Mathieu-Daudé <[email protected]>
PATCH 2/2 target/arm: Fix VUDOT/VSDOT (scalar) on big-endian hosts
In reply to Peter MaydellThe helper functions for performing the udot/sdot operations against a scalar were not using an address-swizzling macro when converting the index of the scalar element into a pointer into the vm array. This had no effect on little-endian hosts but meant we generated incorrect results on big-endian hosts.
For these insns, the index is indexing over group of 4 8-bit values, so 32 bits per indexed entity, and H4() is therefore what we want. (For Neon the only possible input indexes are 0 and 1.)
---
I believe that gvec_udot_idx_h and gvec_sdot_idx_h are OK because the index there is over groups of 4*16-bit values, which are 64 bits each.
--- target/arm/vec_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/arm/vec_helper.c +2 -2
@@ -293,7 +293,7 @@ void HELPER(gvec_sdot_idx_b)(void *vd, void *vn, void *vm, uint32_t desc)intptr_t index =simd_data (desc);uint32_t *d = vd;int8_t *n = vn; -int8_t *m_indexed = (int8_t *)vm + index *4 ; +int8_t *m_indexed = (int8_t *)vm +H4 (index) *4 ;/* Notice the special case of opr_sz == 8, from aa64/aa32 advsimd. * Otherwise opr_sz is a multiple of 16.
@@ -324,7 +324,7 @@ void HELPER(gvec_udot_idx_b)(void *vd, void *vn, void *vm, uint32_t desc)intptr_t index =simd_data (desc);uint32_t *d = vd;uint8_t *n = vn; -uint8_t *m_indexed = (uint8_t *)vm + index *4 ; +uint8_t *m_indexed = (uint8_t *)vm +H4 (index) *4 ;/* Notice the special case of opr_sz == 8, from aa64/aa32 advsimd. * Otherwise opr_sz is a multiple of 16.
Signature · 1 line
2.20.1
Re: [PATCH 2/2] target/arm: Fix VUDOT/VSDOT (scalar) on big-endian hosts
Quoted 10 lines · Peter Maydell
The helper functions for performing the udot/sdot operations against a scalar were not using an address-swizzling macro when converting the index of the scalar element into a pointer into the vm array. This had no effect on little-endian hosts but meant we generated incorrect results on big-endian hosts.
For these insns, the index is indexing over group of 4 8-bit values, so 32 bits per indexed entity, and
H4()is therefore what we want. (For Neon the only possible input indexes are 0 and 1.)
Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>---
I believe thatgvec_udot_idx_handgvec_sdot_idx_hare OK because the index there is over groups of 4*16-bit values, which are 64 bits each.--- target/arm/vec_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 3 lines · Peter Maydell
Peter Maydell (2):
target/arm: Fix float16 pairwise Neon ops on big-endian hosts target/arm: Fix VUDOT/VSDOT (scalar) on big-endian hosts
r~