Hi, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79268 reports that the vec_xl and vec_xst intrinsics are being compiled to incorrectly use element-reversing loads and stores in some cases, and not accepting pointers to vector pixel as a legal parameter. This arose because vec_xl and vec_xst were incorrectly redefined in altivec.h to be equivalent to these instructions; the intent was to use them to implement vec_xl_be and vec_xst_be instead. I.e., I goofed...
This affects GCC 6 and GCC 7. This patch fixes the critical issue by restoring vec_xl and vec_xst to their former definitions, and adding a test case to ensure that vector pixel is covered by them. It also deletes the four test cases that were added as part of the errant patch. This is a simple patch that is intended for application to trunk and backport to GCC 6. A subsequent patch will address defining vec_xl_be and vec_xst_be in terms of the element-reversing memory accesses, which will require more extensive changes. This may or may not be deemed worth backporting, but I think that decision should be made independently. This first patch will be provided to the various distros to fix and/or prevent build problems using GCC 6 on packages that use vec_xl. At least one such package is known to exist. Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no regressions. Regstrap is in process for the GCC 6 version of the patch, which applies cleanly with offsets. Is this ok for trunk, and shortly thereafter for GCC 6? Thanks, Bill [gcc] 2017-01-29 Bill Schmidt <wschm...@linux.vnet.ibm.com> PR target/79268 * config/rs6000/altivec.h (vec_xl): Revise #define. (vec_xst): Likewise. [gcc/testsuite] 2017-01-29 Bill Schmidt <wschm...@linux.vnet.ibm.com> PR target/79268 * gcc.target/powerpc/pr79268.c: New file. * gcc.target/powerpc/vsx-elemrev-1.c: Delete file. * gcc.target/powerpc/vsx-elemrev-2.c: Likewise. * gcc.target/powerpc/vsx-elemrev-3.c: Likewise. * gcc.target/powerpc/vsx-elemrev-4.c: Likewise. Index: gcc/config/rs6000/altivec.h =================================================================== --- gcc/config/rs6000/altivec.h (revision 245016) +++ gcc/config/rs6000/altivec.h (working copy) @@ -333,8 +333,8 @@ #define vec_sqrt __builtin_vec_sqrt #define vec_vsx_ld __builtin_vec_vsx_ld #define vec_vsx_st __builtin_vec_vsx_st -#define vec_xl __builtin_vec_xl -#define vec_xst __builtin_vec_xst +#define vec_xl __builtin_vec_vsx_ld +#define vec_xst __builtin_vec_vsx_st /* Note, xxsldi and xxpermdi were added as __builtin_vsx_<xxx> functions instead of __builtin_vec_<xxx> */ Index: gcc/testsuite/gcc.target/powerpc/pr79268.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr79268.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/pr79268.c (working copy) @@ -0,0 +1,18 @@ +/* { dg-do compile { target { powerpc64le-*-* } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-options "-mcpu=power8 -O3 " } */ + +/* Verify that vec_xl and vec_xst accept vector pixel parameters. */ + +/* Test case to resolve PR79268. */ + +#include <altivec.h> + +vector pixel a; + +vector pixel +pr79268 (vector pixel *x) +{ + vec_xst (a, 0, x); + return vec_xl (0, x); +} Index: gcc/testsuite/gcc.target/powerpc/vsx-elemrev-1.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/vsx-elemrev-1.c (revision 245016) +++ gcc/testsuite/gcc.target/powerpc/vsx-elemrev-1.c (working copy) @@ -1,143 +0,0 @@ -/* { dg-do compile { target { powerpc64le*-*-* } } } */ -/* { dg-skip-if "do not override mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ -/* { dg-options "-mcpu=power8 -O0" } */ -/* { dg-final { scan-assembler-times "lxvd2x" 18 } } */ -/* { dg-final { scan-assembler-times "lxvw4x" 6 } } */ -/* { dg-final { scan-assembler-times "stxvd2x" 18 } } */ -/* { dg-final { scan-assembler-times "stxvw4x" 6 } } */ -/* { dg-final { scan-assembler-times "xxpermdi" 24 } } */ - -#include <altivec.h> - -extern vector double vd, *vdp; -extern vector signed long long vsll, *vsllp; -extern vector unsigned long long vull, *vullp; -extern vector float vf, *vfp; -extern vector signed int vsi, *vsip; -extern vector unsigned int vui, *vuip; -extern double *dp; -extern signed long long *sllp; -extern unsigned long long *ullp; -extern float *fp; -extern signed int *sip; -extern unsigned int *uip; - -void foo0 (void) -{ - vd = vec_xl (0, vdp); -} - -void foo1 (void) -{ - vsll = vec_xl (0, vsllp); -} - -void foo2 (void) -{ - vull = vec_xl (0, vullp); -} - -void foo3 (void) -{ - vf = vec_xl (0, vfp); -} - -void foo4 (void) -{ - vsi = vec_xl (0, vsip); -} - -void foo5 (void) -{ - vui = vec_xl (0, vuip); -} - -void foo6 (void) -{ - vec_xst (vd, 0, vdp); -} - -void foo7 (void) -{ - vec_xst (vsll, 0, vsllp); -} - -void foo8 (void) -{ - vec_xst (vull, 0, vullp); -} - -void foo9 (void) -{ - vec_xst (vf, 0, vfp); -} - -void foo10 (void) -{ - vec_xst (vsi, 0, vsip); -} - -void foo11 (void) -{ - vec_xst (vui, 0, vuip); -} - -void foo20 (void) -{ - vd = vec_xl (0, dp); -} - -void foo21 (void) -{ - vsll = vec_xl (0, sllp); -} - -void foo22 (void) -{ - vull = vec_xl (0, ullp); -} - -void foo23 (void) -{ - vf = vec_xl (0, fp); -} - -void foo24 (void) -{ - vsi = vec_xl (0, sip); -} - -void foo25 (void) -{ - vui = vec_xl (0, uip); -} - -void foo26 (void) -{ - vec_xst (vd, 0, dp); -} - -void foo27 (void) -{ - vec_xst (vsll, 0, sllp); -} - -void foo28 (void) -{ - vec_xst (vull, 0, ullp); -} - -void foo29 (void) -{ - vec_xst (vf, 0, fp); -} - -void foo30 (void) -{ - vec_xst (vsi, 0, sip); -} - -void foo31 (void) -{ - vec_xst (vui, 0, uip); -} Index: gcc/testsuite/gcc.target/powerpc/vsx-elemrev-2.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/vsx-elemrev-2.c (revision 245016) +++ gcc/testsuite/gcc.target/powerpc/vsx-elemrev-2.c (working copy) @@ -1,236 +0,0 @@ -/* { dg-do compile { target { powerpc64le*-*-* } } } */ -/* { dg-skip-if "do not override mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */ -/* { dg-options "-mcpu=power9 -O0" } */ -/* { dg-require-effective-target powerpc_p9vector_ok } */ -/* { dg-skip-if "" { powerpc*-*-aix* } { "*" } { "" } } */ -/* { dg-final { scan-assembler-times "lxvd2x" 6 } } */ -/* { dg-final { scan-assembler-times "lxvw4x" 6 } } */ -/* { dg-final { scan-assembler-times "lxvh8x" 4 } } */ -/* { dg-final { scan-assembler-times "lxvb16x" 4 } } */ -/* { dg-final { scan-assembler-times "stxvd2x" 6 } } */ -/* { dg-final { scan-assembler-times "stxvw4x" 6 } } */ -/* { dg-final { scan-assembler-times "stxvh8x" 4 } } */ -/* { dg-final { scan-assembler-times "stxvb16x" 4 } } */ - -#include <altivec.h> - -extern vector double vd, *vdp; -extern vector signed long long vsll, *vsllp; -extern vector unsigned long long vull, *vullp; -extern vector float vf, *vfp; -extern vector signed int vsi, *vsip; -extern vector unsigned int vui, *vuip; -extern vector signed short vss, *vssp; -extern vector unsigned short vus, *vusp; -extern vector signed char vsc, *vscp; -extern vector unsigned char vuc, *vucp; -extern double *dp; -extern signed long long *sllp; -extern unsigned long long *ullp; -extern float *fp; -extern signed int *sip; -extern unsigned int *uip; -extern signed short *ssp; -extern unsigned short *usp; -extern signed char *scp; -extern unsigned char *ucp; - -void foo0 (void) -{ - vd = vec_xl (0, vdp); -} - -void foo1 (void) -{ - vsll = vec_xl (0, vsllp); -} - -void foo2 (void) -{ - vull = vec_xl (0, vullp); -} - -void foo3 (void) -{ - vf = vec_xl (0, vfp); -} - -void foo4 (void) -{ - vsi = vec_xl (0, vsip); -} - -void foo5 (void) -{ - vui = vec_xl (0, vuip); -} - -void foo6 (void) -{ - vss = vec_xl (0, vssp); -} - -void foo7 (void) -{ - vus = vec_xl (0, vusp); -} - -void foo8 (void) -{ - vsc = vec_xl (0, vscp); -} - -void foo9 (void) -{ - vuc = vec_xl (0, vucp); -} - -void foo10 (void) -{ - vec_xst (vd, 0, vdp); -} - -void foo11 (void) -{ - vec_xst (vsll, 0, vsllp); -} - -void foo12 (void) -{ - vec_xst (vull, 0, vullp); -} - -void foo13 (void) -{ - vec_xst (vf, 0, vfp); -} - -void foo14 (void) -{ - vec_xst (vsi, 0, vsip); -} - -void foo15 (void) -{ - vec_xst (vui, 0, vuip); -} - -void foo16 (void) -{ - vec_xst (vss, 0, vssp); -} - -void foo17 (void) -{ - vec_xst (vus, 0, vusp); -} - -void foo18 (void) -{ - vec_xst (vsc, 0, vscp); -} - -void foo19 (void) -{ - vec_xst (vuc, 0, vucp); -} - -void foo20 (void) -{ - vd = vec_xl (0, dp); -} - -void foo21 (void) -{ - vsll = vec_xl (0, sllp); -} - -void foo22 (void) -{ - vull = vec_xl (0, ullp); -} - -void foo23 (void) -{ - vf = vec_xl (0, fp); -} - -void foo24 (void) -{ - vsi = vec_xl (0, sip); -} - -void foo25 (void) -{ - vui = vec_xl (0, uip); -} - -void foo26 (void) -{ - vss = vec_xl (0, ssp); -} - -void foo27 (void) -{ - vus = vec_xl (0, usp); -} - -void foo28 (void) -{ - vsc = vec_xl (0, scp); -} - -void foo29 (void) -{ - vuc = vec_xl (0, ucp); -} - -void foo30 (void) -{ - vec_xst (vd, 0, dp); -} - -void foo31 (void) -{ - vec_xst (vsll, 0, sllp); -} - -void foo32 (void) -{ - vec_xst (vull, 0, ullp); -} - -void foo33 (void) -{ - vec_xst (vf, 0, fp); -} - -void foo34 (void) -{ - vec_xst (vsi, 0, sip); -} - -void foo35 (void) -{ - vec_xst (vui, 0, uip); -} - -void foo36 (void) -{ - vec_xst (vss, 0, ssp); -} - -void foo37 (void) -{ - vec_xst (vus, 0, usp); -} - -void foo38 (void) -{ - vec_xst (vsc, 0, scp); -} - -void foo39 (void) -{ - vec_xst (vuc, 0, ucp); -} Index: gcc/testsuite/gcc.target/powerpc/vsx-elemrev-3.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/vsx-elemrev-3.c (revision 245016) +++ gcc/testsuite/gcc.target/powerpc/vsx-elemrev-3.c (working copy) @@ -1,142 +0,0 @@ -/* { dg-do compile { target { powerpc64-*-* } } } */ -/* { dg-skip-if "do not override mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ -/* { dg-options "-mcpu=power8 -O0" } */ -/* { dg-final { scan-assembler-times "lxvd2x" 16 } } */ -/* { dg-final { scan-assembler-times "lxvw4x" 8 } } */ -/* { dg-final { scan-assembler-times "stxvd2x" 16 } } */ -/* { dg-final { scan-assembler-times "stxvw4x" 8 } } */ - -#include <altivec.h> - -extern vector double vd, *vdp; -extern vector signed long long vsll, *vsllp; -extern vector unsigned long long vull, *vullp; -extern vector float vf, *vfp; -extern vector signed int vsi, *vsip; -extern vector unsigned int vui, *vuip; -extern double *dp; -extern signed long long *sllp; -extern unsigned long long *ullp; -extern float *fp; -extern signed int *sip; -extern unsigned int *uip; - -void foo0 (void) -{ - vd = vec_xl (0, vdp); -} - -void foo1 (void) -{ - vsll = vec_xl (0, vsllp); -} - -void foo2 (void) -{ - vull = vec_xl (0, vullp); -} - -void foo3 (void) -{ - vf = vec_xl (0, vfp); -} - -void foo4 (void) -{ - vsi = vec_xl (0, vsip); -} - -void foo5 (void) -{ - vui = vec_xl (0, vuip); -} - -void foo6 (void) -{ - vec_xst (vd, 0, vdp); -} - -void foo7 (void) -{ - vec_xst (vsll, 0, vsllp); -} - -void foo8 (void) -{ - vec_xst (vull, 0, vullp); -} - -void foo9 (void) -{ - vec_xst (vf, 0, vfp); -} - -void foo10 (void) -{ - vec_xst (vsi, 0, vsip); -} - -void foo11 (void) -{ - vec_xst (vui, 0, vuip); -} - -void foo20 (void) -{ - vd = vec_xl (0, dp); -} - -void foo21 (void) -{ - vsll = vec_xl (0, sllp); -} - -void foo22 (void) -{ - vull = vec_xl (0, ullp); -} - -void foo23 (void) -{ - vf = vec_xl (0, fp); -} - -void foo24 (void) -{ - vsi = vec_xl (0, sip); -} - -void foo25 (void) -{ - vui = vec_xl (0, uip); -} - -void foo26 (void) -{ - vec_xst (vd, 0, dp); -} - -void foo27 (void) -{ - vec_xst (vsll, 0, sllp); -} - -void foo28 (void) -{ - vec_xst (vull, 0, ullp); -} - -void foo29 (void) -{ - vec_xst (vf, 0, fp); -} - -void foo30 (void) -{ - vec_xst (vsi, 0, sip); -} - -void foo31 (void) -{ - vec_xst (vui, 0, uip); -} Index: gcc/testsuite/gcc.target/powerpc/vsx-elemrev-4.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/vsx-elemrev-4.c (revision 245016) +++ gcc/testsuite/gcc.target/powerpc/vsx-elemrev-4.c (working copy) @@ -1,233 +0,0 @@ -/* { dg-do compile { target { powerpc64-*-* } } } */ -/* { dg-skip-if "do not override mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */ -/* { dg-options "-mcpu=power9 -O0" } */ -/* { dg-require-effective-target powerpc_p9vector_ok } */ -/* { dg-skip-if "" { powerpc*-*-aix* } { "*" } { "" } } */ - -/* Following will match either lxv or lxvx, either stxv or stxvx. - This is purposeful as either is fine. */ -/* { dg-final { scan-assembler-times "lxv" 40 } } */ -/* { dg-final { scan-assembler-times "stxv" 40 } } */ - -#include <altivec.h> - -extern vector double vd, *vdp; -extern vector signed long long vsll, *vsllp; -extern vector unsigned long long vull, *vullp; -extern vector float vf, *vfp; -extern vector signed int vsi, *vsip; -extern vector unsigned int vui, *vuip; -extern vector signed short vss, *vssp; -extern vector unsigned short vus, *vusp; -extern vector signed char vsc, *vscp; -extern vector unsigned char vuc, *vucp; -extern double *dp; -extern signed long long *sllp; -extern unsigned long long *ullp; -extern float *fp; -extern signed int *sip; -extern unsigned int *uip; -extern signed short *ssp; -extern unsigned short *usp; -extern signed char *scp; -extern unsigned char *ucp; - -void foo0 (void) -{ - vd = vec_xl (0, vdp); -} - -void foo1 (void) -{ - vsll = vec_xl (0, vsllp); -} - -void foo2 (void) -{ - vull = vec_xl (0, vullp); -} - -void foo3 (void) -{ - vf = vec_xl (0, vfp); -} - -void foo4 (void) -{ - vsi = vec_xl (0, vsip); -} - -void foo5 (void) -{ - vui = vec_xl (0, vuip); -} - -void foo6 (void) -{ - vss = vec_xl (0, vssp); -} - -void foo7 (void) -{ - vus = vec_xl (0, vusp); -} - -void foo8 (void) -{ - vsc = vec_xl (0, vscp); -} - -void foo9 (void) -{ - vuc = vec_xl (0, vucp); -} - -void foo10 (void) -{ - vec_xst (vd, 0, vdp); -} - -void foo11 (void) -{ - vec_xst (vsll, 0, vsllp); -} - -void foo12 (void) -{ - vec_xst (vull, 0, vullp); -} - -void foo13 (void) -{ - vec_xst (vf, 0, vfp); -} - -void foo14 (void) -{ - vec_xst (vsi, 0, vsip); -} - -void foo15 (void) -{ - vec_xst (vui, 0, vuip); -} - -void foo16 (void) -{ - vec_xst (vss, 0, vssp); -} - -void foo17 (void) -{ - vec_xst (vus, 0, vusp); -} - -void foo18 (void) -{ - vec_xst (vsc, 0, vscp); -} - -void foo19 (void) -{ - vec_xst (vuc, 0, vucp); -} - -void foo20 (void) -{ - vd = vec_xl (0, dp); -} - -void foo21 (void) -{ - vsll = vec_xl (0, sllp); -} - -void foo22 (void) -{ - vull = vec_xl (0, ullp); -} - -void foo23 (void) -{ - vf = vec_xl (0, fp); -} - -void foo24 (void) -{ - vsi = vec_xl (0, sip); -} - -void foo25 (void) -{ - vui = vec_xl (0, uip); -} - -void foo26 (void) -{ - vss = vec_xl (0, ssp); -} - -void foo27 (void) -{ - vus = vec_xl (0, usp); -} - -void foo28 (void) -{ - vsc = vec_xl (0, scp); -} - -void foo29 (void) -{ - vuc = vec_xl (0, ucp); -} - -void foo30 (void) -{ - vec_xst (vd, 0, dp); -} - -void foo31 (void) -{ - vec_xst (vsll, 0, sllp); -} - -void foo32 (void) -{ - vec_xst (vull, 0, ullp); -} - -void foo33 (void) -{ - vec_xst (vf, 0, fp); -} - -void foo34 (void) -{ - vec_xst (vsi, 0, sip); -} - -void foo35 (void) -{ - vec_xst (vui, 0, uip); -} - -void foo36 (void) -{ - vec_xst (vss, 0, ssp); -} - -void foo37 (void) -{ - vec_xst (vus, 0, usp); -} - -void foo38 (void) -{ - vec_xst (vsc, 0, scp); -} - -void foo39 (void) -{ - vec_xst (vuc, 0, ucp); -}