1 /* Test that using a character splat to set up a shift-left
2 for a doubleword vector works correctly after gimple folding. */
3
4 /* { dg-do run { target { p8vector_hw } } } */
5 /* { dg-options "-O2 -mpower8-vector" } */
6
7 #include <altivec.h>
8
9 typedef __vector unsigned long long vui64_t;
10
11 static inline vui64_t
12 vec_sldi (vui64_t vra, const unsigned int shb)
13 {
14 vui64_t lshift;
15 vui64_t result;
16
17 /* Note legitimate use of wrong-type splat due to expectation that only
18 lower 6-bits are read. */
19 lshift = (vui64_t) vec_splat_s8 (shb);
20
21 /* Vector Shift Left Doublewords based on the lower 6-bits
22 of corresponding element of lshift. */
23 result = vec_vsld (vra, lshift);
24
25 return result;
26 }
27
28 __attribute__ ((noinline)) vui64_t
29 test_sldi_4 (vui64_t a)
30 {
31 return vec_sldi (a, 4);
32 }
33
34 int
35 main ()
36 {
37 vui64_t x = {-256, 1025};
38 x = test_sldi_4 (x);
39 if (x[0] != -4096 || x[1] != 16400)
40 __builtin_abort ();
41 return 0;
42 }