forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aarch64: Improve vector constant generation using SVE INDEX instructi…
…on [PR113328] SVE's INDEX instruction can be used to populate vectors by values starting from "base" and incremented by "step" for each subsequent value. We can take advantage of it to generate vector constants if TARGET_SVE is available and the base and step values are within [-16, 15]. For example, with the following function: typedef int v4si __attribute__ ((vector_size (16))); v4si f_v4si (void) { return (v4si){ 0, 1, 2, 3 }; } GCC currently generates: f_v4si: adrp x0, .LC4 ldr q0, [x0, #:lo12:.LC4] ret .LC4: .word 0 .word 1 .word 2 .word 3 With this patch, we generate an INDEX instruction instead if TARGET_SVE is available. f_v4si: index z0.s, #0, #1 ret PR target/113328 gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_simd_valid_immediate): Improve handling of some ADVSIMD vectors by using SVE's INDEX if TARGET_SVE is available. (aarch64_output_simd_mov_immediate): Likewise. gcc/testsuite/ChangeLog: * gcc.target/aarch64/sve/acle/general/dupq_1.c: Update test to use SVE's INDEX instruction. * gcc.target/aarch64/sve/acle/general/dupq_2.c: Likewise. * gcc.target/aarch64/sve/acle/general/dupq_3.c: Likewise. * gcc.target/aarch64/sve/acle/general/dupq_4.c: Likewise. * gcc.target/aarch64/sve/vec_init_3.c: New test. Signed-off-by: Pengxuan Zheng <[email protected]>
- Loading branch information
Showing
6 changed files
with
115 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-O2" } */ | ||
/* { dg-final { check-function-bodies "**" "" "" } } */ | ||
|
||
typedef char v16qi __attribute__ ((vector_size (16))); | ||
typedef char v8qi __attribute__ ((vector_size (8))); | ||
typedef short v8hi __attribute__ ((vector_size (16))); | ||
typedef short v4hi __attribute__ ((vector_size (8))); | ||
typedef int v4si __attribute__ ((vector_size (16))); | ||
typedef int v2si __attribute__ ((vector_size (8))); | ||
typedef long v2di __attribute__ ((vector_size (16))); | ||
|
||
/* | ||
** f_v16qi: | ||
** index z0\.b, #0, #1 | ||
** ret | ||
*/ | ||
v16qi | ||
f_v16qi (void) | ||
{ | ||
return (v16qi){ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; | ||
} | ||
|
||
/* | ||
** f_v8qi: | ||
** index z0\.b, #0, #1 | ||
** ret | ||
*/ | ||
v8qi | ||
f_v8qi (void) | ||
{ | ||
return (v8qi){ 0, 1, 2, 3, 4, 5, 6, 7 }; | ||
} | ||
|
||
/* | ||
** f_v8hi: | ||
** index z0\.h, #0, #1 | ||
** ret | ||
*/ | ||
v8hi | ||
f_v8hi (void) | ||
{ | ||
return (v8hi){ 0, 1, 2, 3, 4, 5, 6, 7 }; | ||
} | ||
|
||
/* | ||
** f_v4hi: | ||
** index z0\.h, #0, #1 | ||
** ret | ||
*/ | ||
v4hi | ||
f_v4hi (void) | ||
{ | ||
return (v4hi){ 0, 1, 2, 3 }; | ||
} | ||
|
||
/* | ||
** f_v4si: | ||
** index z0\.s, #0, #1 | ||
** ret | ||
*/ | ||
v4si | ||
f_v4si (void) | ||
{ | ||
return (v4si){ 0, 1, 2, 3 }; | ||
} | ||
|
||
/* | ||
** f_v2si: | ||
** index z0\.s, #0, #1 | ||
** ret | ||
*/ | ||
v2si | ||
f_v2si (void) | ||
{ | ||
return (v2si){ 0, 1 }; | ||
} | ||
|
||
/* | ||
** f_v2di: | ||
** index z0\.d, #0, #1 | ||
** ret | ||
*/ | ||
v2di | ||
f_v2di (void) | ||
{ | ||
return (v2di){ 0, 1 }; | ||
} | ||
|
||
/* | ||
** g_v4si: | ||
** index z0\.s, #3, #-4 | ||
** ret | ||
*/ | ||
v4si | ||
g_v4si (void) | ||
{ | ||
return (v4si){ 3, -1, -5, -9 }; | ||
} |