summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/eh/simd-5.C
blob: 71e117ead2aabb9c2d998388c13a0ac87bc7e0e1 (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
// Test EH with V2SI SIMD registers actually restores correct values.
// Origin: Joseph Myers <joseph@codesourcery.com>
// { dg-options "-O" }
// { dg-do run { target { powerpc_spe && { ! *-*-vxworks* } } } }

extern "C" void abort (void);
extern "C" int memcmp (const void *, const void *, __SIZE_TYPE__);
typedef int __attribute__((vector_size (8))) v2si;

v2si a = { 1, 2 };
v2si b = { 3, 4 };
v2si c = { 4, 6 };
volatile v2si r;
v2si r2;

void
f ()
{
  register v2si v asm("r15");
  v = __builtin_spe_evaddw (b, c);
  asm volatile ("" : "+r" (v));
  r = v;
  throw 1;
}

int
main ()
{
  register v2si v asm("r15");
  v = __builtin_spe_evaddw (a, b);
  asm volatile ("" : "+r" (v));
  try
    {
      f ();
    }
  catch (int)
    {
      r = v;
      r2 = r;
      if (memcmp (&r2, &c, sizeof (v2si)))
	abort ();
    }
  return 0;
}