aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/powerpc/vec-replace-word-runnable_2.c
blob: 153d1e3b62a443b6d1e88074f4631bc9a817c4f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* { dg-do run { target { power10_hw } } } */
/* { dg-options "-mdejagnu-cpu=power10 -save-temps" } */

#include <altivec.h>

#define DEBUG 0

#if DEBUG
#include <stdio.h>
#endif

extern void abort (void);

int
main (int argc, char *argv [])
{
  int i;
  vector unsigned long long int vresult_ullint;
  vector unsigned long long int expected_vresult_ullint;
  vector unsigned long long int src_va_ullint;
  unsigned int long long src_a_ullint;

  /* Replace doubleword size chunk specified as a constant that can be
     represented by an int.  Should generate a vinsd instruction.  Note, this
     test requires command line option -flax-vector-conversions.  */
  src_a_ullint = 456;
  src_va_ullint = (vector unsigned long long int) { 0, 11 };
  vresult_ullint = (vector unsigned long long int) { 0, 2 };
  expected_vresult_ullint = (vector unsigned long long int) { 0, 456 };
						 
  vresult_ullint = (vector unsigned long long int)
    vec_replace_unaligned ((vector unsigned char)src_va_ullint,
			   src_a_ullint, 0);

  if (!vec_all_eq (vresult_ullint, expected_vresult_ullint)) {
#if DEBUG
    printf("ERROR, vec_replace_unaligned ((vector unsigned char)src_vb_ullint, src_a_ullint, index)\n");
    for (i = 0; i < 2; i++)
      printf(" vresult_ullint[%d] = %d, expected_vresult_ullint[%d] = %d\n",
	     i, vresult_ullint[i], i, expected_vresult_ullint[i]);
#else
    abort();
#endif
  }
  
  return 0;
}

/* { dg-final { scan-assembler-times {\mvinsd\M} 1 } } */