1#include <altivec.h> 2#include <stdio.h> 3 4vector unsigned int 5vector_fun (vector unsigned int a, vector unsigned int b) 6{ 7 vector unsigned int c; 8 a = ((vector unsigned int) vec_splat_u8(2)); 9 b = ((vector unsigned int) vec_splat_u8(3)); 10 11 c = vec_add (a, b); 12 return c; 13} 14 15int 16main () 17{ 18 vector unsigned int y; 19 vector unsigned int x; 20 vector unsigned int z; 21 int a; 22 23 /* This line may look unnecessary but we do need it, because we want to 24 have a line to do a next over (so that gdb refetches the registers) 25 and we don't want the code to change any vector registers. 26 The splat operations below modify the VRs,i 27 so we don't want to execute them yet. */ 28 a = 9; 29 x = ((vector unsigned int) vec_splat_u8 (-2)); 30 y = ((vector unsigned int) vec_splat_u8 (1)); 31 32 z = vector_fun (x, y); 33 x = vec_sld (x,y,2); 34 35 x = vec_add (x, ((vector unsigned int){5,6,7,8})); 36 z = (vector unsigned int) vec_splat_u8 ( -2); 37 y = vec_add (x, z); 38 z = (vector unsigned int) vec_cmpeq (x,y); 39 40 return 0; 41} 42