2018-04-09 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vshift-6.c
blob6f7a0b05b8892e1aded4c53e8f747206462af351
1 /* { dg-do compile } */
2 /* { dg-options "-Wshift-count-negative -Wshift-count-overflow" } */
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)));
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" } */
17 return c < 0 ? x >> -c : x << 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" } */
29 return c < 0 ? x >> -c : x << 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" } */
41 return c < 0 ? x >> -c : x << c;