1 /* { dg-do compile } */
2 /* { dg-options "-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 
test1qi(v1qi_t x,int c)8 v1qi_t test1qi(v1qi_t x, int c) {
9 	switch(c) {
10 	case 0: return x << -1; /* { dg-warning "shift count is negative" } */
11 	case 1: return x << 7;
12 	case 2: return x << 8; /* { dg-warning "shift count >= width" } */
13 	case ~0: return x >> -1; /* { dg-warning "shift count is negative" } */
14 	case ~1: return x >> 7;
15 	case ~2: return x >> 8; /* { dg-warning "shift count >= width" } */
16 	}
17 	return c < 0 ? x >> -c : x << c;
18 }
19 
test1hi(v1hi_t x,int c)20 v1hi_t test1hi(v1hi_t x, int c) {
21 	switch(c) {
22 	case 0: return x << -1; /* { dg-warning "shift count is negative" } */
23 	case 1: return x << 15;
24 	case 2: return x << 16; /* { dg-warning "shift count >= width" } */
25 	case ~0: return x >> -1; /* { dg-warning "shift count is negative" } */
26 	case ~1: return x >> 15;
27 	case ~2: return x >> 16; /* { dg-warning "shift count >= width" } */
28 	}
29 	return c < 0 ? x >> -c : x << c;
30 }
31 
test1si(v1si_t x,int c)32 v1si_t test1si(v1si_t x, int c) {
33 	switch(c) {
34 	case 0: return x << -1; /* { dg-warning "shift count is negative" } */
35 	case 1: return x << 31;
36 	case 2: return x << 32; /* { dg-warning "shift count >= width" } */
37 	case ~0: return x >> -1; /* { dg-warning "shift count is negative" } */
38 	case ~1: return x >> 31;
39 	case ~2: return x >> 32; /* { dg-warning "shift count >= width" } */
40 	}
41 	return c < 0 ? x >> -c : x << c;
42 }
43