rs6000: Fix arguments for __builtin_altivec_tr_stxvrwx, __builtin_altivec_tr_stxvrhx

The third argument for __builtin_altivec_tr_stxvrhx should be short *
not int *.  Similarly, the third argument for __builtin_altivec_tr_stxvrwx
should be int * not short *.  This patch fixes the arguments in the two
builtins.

A runnable test case is added to test the __builtin_altivec_tr_stxvrbx,
__builtin_altivec_tr_stxvrhx, __builtin_altivec_tr_stxvrwx and
__builtin_altivec_tr_stxvrdx builtins.

gcc/
	* config/rs6000/rs6000-builtins.def (__builtin_altivec_tr_stxvrhx,
	__builtin_altivec_tr_stxvrwx): Fix type of third argument.

gcc/testsuite/
	* gcc.target/powerpc/builtin_altivec_tr_stxvr_runnable.c: New test
	for __builtin_altivec_tr_stxvrbx, __builtin_altivec_tr_stxvrhx,
	__builtin_altivec_tr_stxvrwx, __builtin_altivec_tr_stxvrdx.
This commit is contained in:
Carl Love 2023-06-02 11:11:12 -04:00
parent 4d935f52b0
commit 957798e44e
2 changed files with 106 additions and 2 deletions

View file

@ -3160,10 +3160,10 @@
void __builtin_altivec_tr_stxvrbx (vsq, signed long, signed char *);
TR_STXVRBX vsx_stxvrbx {stvec}
void __builtin_altivec_tr_stxvrhx (vsq, signed long, signed int *);
void __builtin_altivec_tr_stxvrhx (vsq, signed long, signed short *);
TR_STXVRHX vsx_stxvrhx {stvec}
void __builtin_altivec_tr_stxvrwx (vsq, signed long, signed short *);
void __builtin_altivec_tr_stxvrwx (vsq, signed long, signed int *);
TR_STXVRWX vsx_stxvrwx {stvec}
void __builtin_altivec_tr_stxvrdx (vsq, signed long, signed long long *);

View file

@ -0,0 +1,104 @@
/* Test of __builtin_vec_xst_trunc */
/* { dg-do run { target power10_hw } } */
/* { dg-require-effective-target int128 } */
/* { dg-options "-mdejagnu-cpu=power10 -save-temps" } */
#include <altivec.h>
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include <stdlib.h>
#define DEBUG 0
vector signed __int128 store_data =
{ (__int128) 0x8ACE000000000000 << 64 | (__int128) 0xfedcba9876543217ULL};
union conv_t {
vector signed __int128 vsi128;
unsigned long long ull[2];
} conv;
void abort (void);
int
main () {
int i;
signed long sl;
signed char sc, expected_sc;
signed short ss, expected_ss;
signed int si, expected_si;
signed long long int sll, expected_sll;
signed char *psc;
signed short *pss;
signed int *psi;
signed long long int *psll;
#if DEBUG
val.vsi128 = store_data;
printf("Data to store [%d] = 0x%llx %llx\n", i, val.ull[1], val.ull[0]);
#endif
psc = &sc;
pss = &ss;
psi = &si;
psll = &sll;
sl = 1;
sc = 0xA1;
expected_sc = 0xA1;
__builtin_altivec_tr_stxvrbx (store_data, sl, psc);
if (expected_sc != sc & 0xFF)
#if DEBUG
printf(" ERROR: Signed char = 0x%x doesn't match expected value 0x%x\n",
sc & 0xFF, expected_sc);
#else
abort();
#endif
ss = 0x52;
expected_ss = 0x1752;
__builtin_altivec_tr_stxvrhx (store_data, sl, pss);
if (expected_ss != ss & 0xFFFF)
#if DEBUG
printf(" ERROR: Signed short = 0x%x doesn't match expected value 0x%x\n",
ss, expected_ss) & 0xFFFF;
#else
abort();
#endif
si = 0x21;
expected_si = 0x54321721;
__builtin_altivec_tr_stxvrwx (store_data, sl, psi);
if (expected_si != si)
#if DEBUG
printf(" ERROR: Signed int = 0x%x doesn't match expected value 0x%x\n",
si, expected_si);
#else
abort();
#endif
sll = 0x12FFULL;
expected_sll = 0xdcba9876543217FF;
__builtin_altivec_tr_stxvrdx (store_data, sl, psll);
if (expected_sll != sll)
#if DEBUG
printf(" ERROR: Signed long long int = 0x%llx doesn't match expected value 0x%llx\n",
sll, expected_sll);
#else
abort();
#endif
return 0;
}
/* { dg-final { scan-assembler-times {\mstxvrbx\M} 1 } } */
/* { dg-final { scan-assembler-times {\mstxvrhx\M} 1 } } */
/* { dg-final { scan-assembler-times {\mstxvrwx\M} 1 } } */
/* { dg-final { scan-assembler-times {\mstxvrdx\M} 1 } } */