1 /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
2 /* { dg-require-effective-target powerpc_altivec_ok } */
3 /* { dg-options "-maltivec" } */
4
5 #include <altivec.h>
6
7 extern void abort (void);
8
vmului(vector unsigned char v,vector unsigned char i)9 vector unsigned char vmului(vector unsigned char v,
10 vector unsigned char i)
11 {
12 return v * i;
13 }
14
vmulsi(vector signed char v,vector signed char i)15 vector signed char vmulsi(vector signed char v,
16 vector signed char i)
17 {
18 return v * i;
19 }
20
main()21 int main ()
22 {
23 vector unsigned char a = {2, 4, 6, 8, 10, 12, 14, 16,
24 18, 20, 22, 24, 26, 28, 30, 32};
25 vector unsigned char b = {3, 6, 9, 12, 15, 18, 21, 24,
26 27, 30, 33, 36, 39, 42, 45, 48};
27 vector unsigned char c = vmului (a, b);
28 vector unsigned char expect_c = {6, 24, 54, 96, 150, 216, 38, 128,
29 230, 88, 214, 96, 246, 152, 70, 0};
30
31 vector signed char d = {2, -4, 6, -8, 10, -12, 14, -16,
32 18, -20, 22, -24, 26, -28, 30, -32};
33 vector signed char e = {3, 6, -9, -12, 15, 18, -21, -24,
34 27, 30, -33, -36, 39, 42, -45, -48};
35 vector signed char f = vmulsi (d, e);
36 vector signed char expect_f = {6, -24, -54, 96, -106, 40, -38, -128,
37 -26, -88, 42, 96, -10, 104, -70, 0};
38
39 vector signed char g = {127, -128, 126, -126, 125, -125, 124, -124,
40 123, -123, 122, -122, 121, -121, 120, -120};
41 vector signed char h = { 2, 2, -2, -2, 127, 127, -128, -128,
42 10, 10, -10, -10, 64, 65, -64, -65};
43 vector signed char i = vmulsi (g, h);
44 vector signed char expect_i = {-2, 0, 4, -4, 3, -3, 0, 0,
45 -50, 50, 60, -60, 64, 71, 0, 120};
46
47 if (!vec_all_eq (c, expect_c))
48 abort ();
49 if (!vec_all_eq (f, expect_f))
50 abort ();
51 if (!vec_all_eq (i, expect_i))
52 abort ();
53 }
54