1 /* { dg-require-effective-target vect_cond_mixed } */ 2 /* { dg-require-effective-target vect_float } */ 3 4 #include "tree-vect.h" 5 6 #define N 128 7 int d[N], e[N], f[N]; 8 unsigned char k[N]; 9 float a[N], b[N]; 10 11 __attribute__((noinline, noclone)) void f1(void)12f1 (void) 13 { 14 int i; 15 for (i = 0; i < N/4; i++) 16 { 17 k[4*i] = a[4*i] < b[4*i] ? 17 : 0; 18 k[4*i+1] = a[4*i+1] < b[4*i+1] ? 17 : 0; 19 k[4*i+2] = a[4*i+2] < b[4*i+2] ? 17 : 0; 20 k[4*i+3] = a[4*i+3] < b[4*i+3] ? 17 : 0; 21 } 22 } 23 24 __attribute__((noinline, noclone)) void f2(void)25f2 (void) 26 { 27 int i; 28 for (i = 0; i < N/2; ++i) 29 { 30 k[2*i] = a[2*i] < b[2*i] ? 0 : 24; 31 k[2*i+1] = a[2*i+1] < b[2*i+1] ? 7 : 4; 32 } 33 } 34 35 __attribute__((noinline, noclone)) void f3(void)36f3 (void) 37 { 38 int i; 39 for (i = 0; i < N/2; ++i) 40 { 41 k[2*i] = a[2*i] < b[2*i] ? 51 : 12; 42 k[2*i+1] = a[2*i+1] > b[2*i+1] ? 51 : 12; 43 } 44 } 45 46 __attribute__((noinline, noclone)) void f4(void)47f4 (void) 48 { 49 int i; 50 for (i = 0; i < N/2; ++i) 51 { 52 int d0 = d[2*i], e0 = e[2*i]; 53 int d1 = d[2*i+1], e1 = e[2*i+1]; 54 f[2*i] = a[2*i] >= b[2*i] ? d0 : e0; 55 f[2*i+1] = a[2*i+1] >= b[2*i+1] ? d1 : e1; 56 } 57 } 58 59 int main()60main () 61 { 62 int i; 63 64 check_vect (); 65 66 for (i = 0; i < N; i++) 67 { 68 switch (i % 9) 69 { 70 case 0: asm (""); a[i] = - i - 1; b[i] = i + 1; break; 71 case 1: a[i] = 0; b[i] = 0; break; 72 case 2: a[i] = i + 1; b[i] = - i - 1; break; 73 case 3: a[i] = i; b[i] = i + 7; break; 74 case 4: a[i] = i; b[i] = i; break; 75 case 5: a[i] = i + 16; b[i] = i + 3; break; 76 case 6: a[i] = - i - 5; b[i] = - i; break; 77 case 7: a[i] = - i; b[i] = - i; break; 78 case 8: a[i] = - i; b[i] = - i - 7; break; 79 } 80 d[i] = i; 81 e[i] = 2 * i; 82 } 83 84 f1 (); 85 for (i = 0; i < N; i++) 86 if (k[i] != ((i % 3) == 0 ? 17 : 0)) 87 abort (); 88 89 f2 (); 90 for (i = 0; i < N; i++) 91 { 92 switch (i % 9) 93 { 94 case 0: 95 case 6: 96 if (k[i] != ((i/9 % 2) == 0 ? 0 : 7)) 97 abort (); 98 break; 99 case 1: 100 case 5: 101 case 7: 102 if (k[i] != ((i/9 % 2) == 0 ? 4 : 24)) 103 abort (); 104 break; 105 case 2: 106 case 4: 107 case 8: 108 if (k[i] != ((i/9 % 2) == 0 ? 24 : 4)) 109 abort (); 110 break; 111 case 3: 112 if (k[i] != ((i/9 % 2) == 0 ? 7 : 0)) 113 abort (); 114 break; 115 } 116 } 117 118 f3 (); 119 120 f4 (); 121 for (i = 0; i < N; i++) 122 if (f[i] != ((i % 3) == 0 ? e[i] : d[i])) 123 abort (); 124 125 return 0; 126 } 127 128 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" } } */ 129