111
|
1 /* { dg-do compile } */
|
|
2 /* { dg-options "-O1 -Wshift-count-negative -Wshift-count-overflow" } */
|
|
3
|
|
4 typedef unsigned int v1qi_t __attribute__((mode(QI), vector_size(1)));
|
|
5 typedef unsigned int v1hi_t __attribute__((mode(HI), vector_size(2)));
|
|
6 typedef unsigned int v1si_t __attribute__((mode(SI), vector_size(4)));
|
|
7
|
|
8 static const signed shift_neg = -1;
|
|
9 static const unsigned shift_qi = 8;
|
|
10 static const unsigned shift_hi = 16;
|
|
11 static const unsigned shift_si = 32;
|
|
12
|
|
13 v1qi_t test1qi(v1qi_t x, int c) {
|
|
14 switch(c) {
|
|
15 case 0: return x << shift_neg; /* { dg-warning "shift count is negative" } */
|
|
16 case 1: return x << (shift_qi - 1);
|
|
17 case 2: return x << shift_qi; /* { dg-warning "shift count >= width" } */
|
|
18 case ~0: return x >> shift_neg; /* { dg-warning "shift count is negative" } */
|
|
19 case ~1: return x >> (shift_qi - 1);
|
|
20 case ~2: return x >> shift_qi; /* { dg-warning "shift count >= width" } */
|
|
21 }
|
|
22 return c < 0 ? x >> -c : x << c;
|
|
23 }
|
|
24
|
|
25 v1hi_t test1hi(v1hi_t x, int c) {
|
|
26 switch(c) {
|
|
27 case 0: return x << shift_neg; /* { dg-warning "shift count is negative" } */
|
|
28 case 1: return x << (shift_hi - 1);
|
|
29 case 2: return x << shift_hi; /* { dg-warning "shift count >= width" } */
|
|
30 case ~0: return x >> shift_neg; /* { dg-warning "shift count is negative" } */
|
|
31 case ~1: return x >> (shift_hi - 1);
|
|
32 case ~2: return x >> shift_hi; /* { dg-warning "shift count >= width" } */
|
|
33 }
|
|
34 return c < 0 ? x >> -c : x << c;
|
|
35 }
|
|
36
|
|
37 v1si_t test1si(v1si_t x, int c) {
|
|
38 switch(c) {
|
|
39 case 0: return x << shift_neg; /* { dg-warning "shift count is negative" } */
|
|
40 case 1: return x << (shift_si - 1);
|
|
41 case 2: return x << shift_si; /* { dg-warning "shift count >= width" } */
|
|
42 case ~0: return x >> shift_neg; /* { dg-warning "shift count is negative" } */
|
|
43 case ~1: return x >> (shift_si - 1);
|
|
44 case ~2: return x >> shift_si; /* { dg-warning "shift count >= width" } */
|
|
45 }
|
|
46 return c < 0 ? x >> -c : x << c;
|
|
47 }
|