1 /* { dg-do run } */ 2 /* { dg-options "-O3" } */ 3 4 #include <stdlib.h> 5 6 #define N 64 7 8 #ifndef TYPE1 9 #define TYPE1 int 10 #define TYPE2 long long 11 #endif 12 13 signed TYPE1 a[N], b, g[N]; 14 unsigned TYPE1 c[N], h[N]; 15 signed TYPE2 d[N], e, j[N]; 16 unsigned TYPE2 f[N], k[N]; 17 18 #ifndef S 19 #define S(x) x 20 #endif 21 22 __attribute__((noinline)) void f1(void)23f1 (void) 24 { 25 int i; 26 for (i = 0; i < N; i++) 27 g[i] = a[i] << S (b); 28 } 29 30 __attribute__((noinline)) void f2(void)31f2 (void) 32 { 33 int i; 34 for (i = 0; i < N; i++) 35 g[i] = a[i] >> S (b); 36 } 37 38 __attribute__((noinline)) void f3(void)39f3 (void) 40 { 41 int i; 42 for (i = 0; i < N; i++) 43 h[i] = c[i] >> S (b); 44 } 45 46 __attribute__((noinline)) void f4(void)47f4 (void) 48 { 49 int i; 50 for (i = 0; i < N; i++) 51 j[i] = d[i] << S (e); 52 } 53 54 __attribute__((noinline)) void f5(void)55f5 (void) 56 { 57 int i; 58 for (i = 0; i < N; i++) 59 j[i] = d[i] >> S (e); 60 } 61 62 __attribute__((noinline)) void f6(void)63f6 (void) 64 { 65 int i; 66 for (i = 0; i < N; i++) 67 k[i] = f[i] >> S (e); 68 } 69 70 __attribute__((noinline)) void f7(void)71f7 (void) 72 { 73 int i; 74 for (i = 0; i < N; i++) 75 j[i] = d[i] << S (b); 76 } 77 78 __attribute__((noinline)) void f8(void)79f8 (void) 80 { 81 int i; 82 for (i = 0; i < N; i++) 83 j[i] = d[i] >> S (b); 84 } 85 86 __attribute__((noinline)) void f9(void)87f9 (void) 88 { 89 int i; 90 for (i = 0; i < N; i++) 91 k[i] = f[i] >> S (b); 92 } 93 94 int main()95main () 96 { 97 int i; 98 b = 7; 99 e = 12; 100 for (i = 0; i < N; i++) 101 { 102 asm (""); 103 c[i] = (rand () << 1) | (rand () & 1); 104 a[i] = c[i]; 105 d[i] = (rand () << 1) | (rand () & 1); 106 d[i] |= (unsigned long long) c[i] << 32; 107 f[i] = d[i]; 108 } 109 f1 (); 110 f3 (); 111 f4 (); 112 f6 (); 113 for (i = 0; i < N; i++) 114 if (g[i] != (signed TYPE1) (a[i] << S (b)) 115 || h[i] != (unsigned TYPE1) (c[i] >> S (b)) 116 || j[i] != (signed TYPE2) (d[i] << S (e)) 117 || k[i] != (unsigned TYPE2) (f[i] >> S (e))) 118 abort (); 119 f2 (); 120 f5 (); 121 f9 (); 122 for (i = 0; i < N; i++) 123 if (g[i] != (signed TYPE1) (a[i] >> S (b)) 124 || j[i] != (signed TYPE2) (d[i] >> S (e)) 125 || k[i] != (unsigned TYPE2) (f[i] >> S (b))) 126 abort (); 127 f7 (); 128 for (i = 0; i < N; i++) 129 if (j[i] != (signed TYPE2) (d[i] << S (b))) 130 abort (); 131 f8 (); 132 for (i = 0; i < N; i++) 133 if (j[i] != (signed TYPE2) (d[i] >> S (b))) 134 abort (); 135 return 0; 136 } 137