]> git.ipfire.org Git - thirdparty/gcc.git/commit
rs6000: Fix __builtin_altivec_vcmpne{b,h,w} implementation
authorCarl Love <cel@us.ibm.com>
Wed, 9 Aug 2023 15:30:48 +0000 (11:30 -0400)
committerCarl Love <cel@us.ibm.com>
Wed, 9 Aug 2023 15:30:48 +0000 (11:30 -0400)
commit29e2bc5f9ab70c653c7190c3a5b9e94f10909b44
tree2b12b57b7fc8ac5e8daf993175d327a1b0c0fd83
parentb3a2b307b9deea719fb725a86df43b82176fe459
rs6000: Fix __builtin_altivec_vcmpne{b,h,w} implementation

The current built-in definitions for vcmpneb, vcmpneh, vcmpnew are defined
under the Power 9 section of r66000-builtins.  This implies they are only
supported on Power 9 and above when in fact they are defined and work with
Altivec as well with the appropriate Altivec instruction generation.

The vec_cmpne builtin should generate the vcmpequ{b,h,w} instruction with
Altivec enabled and generate the vcmpne{b,h,w} on Power 9 and newer
processors.

This patch moves the definitions to the Altivec stanza to make it clear
the built-ins are supported for all Altivec processors.  The patch
removes the confusion as to which processors support the vcmpequ{b,h,w}
instructions.

There is existing test coverage for the vec_cmpne built-in for
vector bool char, vector bool short, vector bool int,
vector bool long long in builtins-3-p9.c and p8vector-builtin-2.c.
Coverage for vector signed int, vector unsigned int is in
p8vector-builtin-2.c.

Test vec-cmpne.c is updated to check the generation of the vcmpequ{b,h,w}
instructions for Altivec.  A new test vec-cmpne-runnable.c is added to
verify the built-ins work as expected.

Patch has been tested on Power 8 LE/BE, Power 9 LE/BE and Power 10 LE
with no regressions.

gcc/ChangeLog:

* config/rs6000/rs6000-builtins.def (vcmpneb, vcmpneh, vcmpnew):
Move definitions to Altivec stanza.
* config/rs6000/altivec.md (vcmpneb, vcmpneh, vcmpnew): New
define_expand.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/vec-cmpne-runnable.c: New execution test.
* gcc.target/powerpc/vec-cmpne.c (define_test_functions,
execute_test_functions): Move to vec-cmpne.h.  Add
scan-assembler-times for vcmpequb, vcmpequh, vcmpequw.
* gcc.target/powerpc/vec-cmpne.h: New include file for vec-cmpne.c
and vec-cmpne-runnable.c. Split define_test_functions definition
into define_test_functions and define_init_verify_functions.
gcc/config/rs6000/altivec.md
gcc/config/rs6000/rs6000-builtins.def
gcc/testsuite/gcc.target/powerpc/vec-cmpne-runnable.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/vec-cmpne.c
gcc/testsuite/gcc.target/powerpc/vec-cmpne.h [new file with mode: 0644]