[v1] arm: fix neon 16-bit lane duplication for big-endian [PR128324]
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_simplebootstrap_build--master-aarch64-bootstrap |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap |
fail
|
Patch failed to apply
|
Commit Message
From: Richard Earnshaw <rearnsha@arm.com>
There was an issue with the ordering of statements in my patch r17-2930
when compiling for big-endian. The call to subreg_regno_offset to pick
the core register for the extraction needs to be made before we adjust
the element number to map the big-endian model on the the Arm lane
ordering.
PR target/128324
gcc/ChangeLog:
* config/arm/neon.md
(neon_vdup_lan<VDQW:mode>_internal): Calculate the register
before adjusting the element.
(neon_vdup_lane<VHFBF:mode>_internal): Likewise.
gcc/testsuite/ChangeLog:
* gcc.target/arm/pr128324.c: New test.
---
This is a forge pull request published on the gcc-patches mailing list mailing list
as requested by Richard Earnshaw via Sourceware Forge <forge-bot+rearnsha@forge-stage.sourceware.org>.
Forge discussion: https://forge.sourceware.org/gcc/gcc/pulls/267
Get it locally using:
```
git fetch forge-upstream "+refs/versioned_pull/267/*:refs/versioned_pull/267/*"
git switch -c "pr-267-v1" "refs/versioned_pull/267/1/head"
```
Or, download the patch at: https://forge.sourceware.org/gcc/gcc/pulls/267.diff
Created on: 2026-11-04 16:35:47+00:00
Latest update: 2026-11-04 16:38:45+00:00
Changes: 2 changed files, 26 additions, 4 deletions
Head revision: rearnsha/gcc ref bf16-dup-be commit 109aa7b2bd4fd9b5812b104e5975fdbe144f381a
Base revision: gcc/gcc ref trunk commit 610d625725b1b1cefd5e15b26d01e03926111bd0 r17-5821-g610d625725b1b1
Merge base: 610d625725b1b1cefd5e15b26d01e03926111bd0
Requested Reviewers:
Changed files:
- A: gcc/testsuite/gcc.target/arm/pr128324.c
- M: gcc/config/arm/neon.md
gcc/config/arm/neon.md | 8 ++++----
gcc/testsuite/gcc.target/arm/pr128324.c | 22 ++++++++++++++++++++++
2 files changed, 26 insertions(+), 4 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/arm/pr128324.c
Comments
Pushed
--
https://forge.sourceware.org/gcc/gcc/pulls/267#issuecomment-8119
@@ -3553,13 +3553,13 @@ if (BYTES_BIG_ENDIAN)
(vec_duplicate:VDQW (match_dup 3)))]
{
unsigned HOST_WIDE_INT elt = UINTVAL (operands[2]);
- if (BYTES_BIG_ENDIAN)
- elt = GET_MODE_NUNITS (<V_double_vector_mode>mode) - 1 - elt;
unsigned HOST_WIDE_INT size = GET_MODE_SIZE (<V_elem>mode);
int base_regno = REGNO (operands[1]);
int regno = (base_regno
+ subreg_regno_offset (base_regno, <V_double_vector_mode>mode,
elt * size, SImode));
+ if (BYTES_BIG_ENDIAN)
+ elt = GET_MODE_NUNITS (<V_double_vector_mode>mode) - 1 - elt;
unsigned HOST_WIDE_INT offset = (elt * size) % GET_MODE_SIZE (SImode);
if (offset != 0)
{
@@ -3636,13 +3636,13 @@ if (BYTES_BIG_ENDIAN)
(vec_duplicate:VHFBF (match_dup 3)))]
{
unsigned HOST_WIDE_INT elt = UINTVAL (operands[2]);
- if (BYTES_BIG_ENDIAN)
- elt = GET_MODE_NUNITS (<V_double_vector_mode>mode) - 1 - elt;
unsigned HOST_WIDE_INT size = GET_MODE_SIZE (<V_elem>mode);
int base_regno = REGNO (operands[1]);
int regno = (base_regno
+ subreg_regno_offset (base_regno, <V_double_vector_mode>mode,
elt * size, SImode));
+ if (BYTES_BIG_ENDIAN)
+ elt = GET_MODE_NUNITS (<V_double_vector_mode>mode) - 1 - elt;
unsigned HOST_WIDE_INT offset = (elt * size) % GET_MODE_SIZE (SImode);
if (offset != 0)
{
new file mode 100644
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target stdint_types_mbig_endian } */
+/* { dg-require-effective-target arm_arch_v7ve_neon_ok } */
+/* { dg-options "-O2 -mbig-endian" } */
+/* { dg-add-options arm_arch_v7ve_neon } */
+/* { dg-final { check-function-bodies "**" "" "" } } */
+
+#include <arm_neon.h>
+#include <stdint.h>
+
+int16x4_t be_lane (int16x4_t v)
+{
+ return vdup_lane_s16 (v, 3);
+}
+
+/*
+** be_lane:
+** lsrs? (r[0-9]*), r0, #16
+** vdup.16 d16, \1
+** vmov r1, r0, d16 @ v4hi
+** bx lr
+*/