| 1 |
/* { dg-do compile { target { powerpc*-*-* } } } */ |
| 2 |
/* { dg-skip-if "" { powerpc*-*-darwin* } } */ |
| 3 |
/* { dg-options "-mdejagnu-cpu=power8 -mvsx -O2 -ftree-vectorize -fvect-cost-model=dynamic -fno-unroll-loops -fno-unroll-all-loops" } */ |
| 4 |
/* { dg-require-effective-target powerpc_vsx } */ |
| 5 |
|
| 6 |
#include <altivec.h> |
| 7 |
|
| 8 |
typedef vector long long v_sign; |
| 9 |
typedef vector unsigned long long v_uns; |
| 10 |
typedef vector bool long long v_bool; |
| 11 |
typedef vector bool char v_bchar; |
| 12 |
typedef vector bool int v_bint; |
| 13 |
typedef vector bool short v_bshort; |
| 14 |
typedef vector signed int v_sint; |
| 15 |
typedef vector unsigned int v_uint; |
| 16 |
typedef vector signed char v_schar; |
| 17 |
typedef vector unsigned char v_uchar; |
| 18 |
typedef vector float v_float; |
| 19 |
|
| 20 |
v_sign sign_add_1 (v_sign a, v_sign b) |
| 21 |
{ |
| 22 |
return __builtin_altivec_vaddudm (a, b); |
| 23 |
} |
| 24 |
|
| 25 |
v_sign sign_add_2 (v_sign a, v_sign b) |
| 26 |
{ |
| 27 |
return vec_add (a, b); |
| 28 |
} |
| 29 |
|
| 30 |
v_sign sign_add_3 (v_sign a, v_sign b) |
| 31 |
{ |
| 32 |
return vec_vaddudm (a, b); |
| 33 |
} |
| 34 |
|
| 35 |
v_sign sign_sub_1 (v_sign a, v_sign b) |
| 36 |
{ |
| 37 |
return __builtin_altivec_vsubudm (a, b); |
| 38 |
} |
| 39 |
|
| 40 |
v_sign sign_sub_2 (v_sign a, v_sign b) |
| 41 |
{ |
| 42 |
return vec_sub (a, b); |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
v_sign sign_sub_3 (v_sign a, v_sign b) |
| 47 |
{ |
| 48 |
return vec_vsubudm (a, b); |
| 49 |
} |
| 50 |
|
| 51 |
v_sign sign_min_1 (v_sign a, v_sign b) |
| 52 |
{ |
| 53 |
return __builtin_altivec_vminsd (a, b); |
| 54 |
} |
| 55 |
|
| 56 |
v_sign sign_min_2 (v_sign a, v_sign b) |
| 57 |
{ |
| 58 |
return vec_min (a, b); |
| 59 |
} |
| 60 |
|
| 61 |
v_sign sign_min_3 (v_sign a, v_sign b) |
| 62 |
{ |
| 63 |
return vec_vminsd (a, b); |
| 64 |
} |
| 65 |
|
| 66 |
v_sign sign_max_1 (v_sign a, v_sign b) |
| 67 |
{ |
| 68 |
return __builtin_altivec_vmaxsd (a, b); |
| 69 |
} |
| 70 |
|
| 71 |
v_sign sign_max_2 (v_sign a, v_sign b) |
| 72 |
{ |
| 73 |
return vec_max (a, b); |
| 74 |
} |
| 75 |
|
| 76 |
v_sign sign_max_3 (v_sign a, v_sign b) |
| 77 |
{ |
| 78 |
return vec_vmaxsd (a, b); |
| 79 |
} |
| 80 |
|
| 81 |
v_sign sign_abs (v_sign a) |
| 82 |
{ |
| 83 |
return vec_abs (a); /* xor, vsubudm, vmaxsd. */ |
| 84 |
} |
| 85 |
|
| 86 |
v_bool sign_eq (v_sign a, v_sign b) |
| 87 |
{ |
| 88 |
return vec_cmpeq (a, b); |
| 89 |
} |
| 90 |
|
| 91 |
v_bool sign_lt (v_sign a, v_sign b) |
| 92 |
{ |
| 93 |
return vec_cmplt (a, b); |
| 94 |
} |
| 95 |
|
| 96 |
v_uns uns_add_2 (v_uns a, v_uns b) |
| 97 |
{ |
| 98 |
return vec_add (a, b); |
| 99 |
} |
| 100 |
|
| 101 |
v_uns uns_add_3 (v_uns a, v_uns b) |
| 102 |
{ |
| 103 |
return vec_vaddudm (a, b); |
| 104 |
} |
| 105 |
|
| 106 |
v_uns uns_sub_2 (v_uns a, v_uns b) |
| 107 |
{ |
| 108 |
return vec_sub (a, b); |
| 109 |
} |
| 110 |
|
| 111 |
v_uns uns_sub_3 (v_uns a, v_uns b) |
| 112 |
{ |
| 113 |
return vec_vsubudm (a, b); |
| 114 |
} |
| 115 |
|
| 116 |
v_uns uns_min_2 (v_uns a, v_uns b) |
| 117 |
{ |
| 118 |
return vec_min (a, b); |
| 119 |
} |
| 120 |
|
| 121 |
v_uns uns_min_3 (v_uns a, v_uns b) |
| 122 |
{ |
| 123 |
return vec_vminud (a, b); |
| 124 |
} |
| 125 |
|
| 126 |
v_uns uns_max_2 (v_uns a, v_uns b) |
| 127 |
{ |
| 128 |
return vec_max (a, b); |
| 129 |
} |
| 130 |
|
| 131 |
v_uns uns_max_3 (v_uns a, v_uns b) |
| 132 |
{ |
| 133 |
return vec_vmaxud (a, b); |
| 134 |
} |
| 135 |
|
| 136 |
v_bool uns_eq (v_uns a, v_uns b) |
| 137 |
{ |
| 138 |
return vec_cmpeq (a, b); |
| 139 |
} |
| 140 |
|
| 141 |
v_bool uns_lt (v_uns a, v_uns b) |
| 142 |
{ |
| 143 |
return vec_cmplt (a, b); |
| 144 |
} |
| 145 |
|
| 146 |
v_sign sign_rl_1 (v_sign a, v_sign b) |
| 147 |
{ |
| 148 |
return __builtin_altivec_vrld (a, b); |
| 149 |
} |
| 150 |
|
| 151 |
v_sign sign_rl_2 (v_sign a, v_uns b) |
| 152 |
{ |
| 153 |
return vec_rl (a, b); |
| 154 |
} |
| 155 |
|
| 156 |
v_uns uns_rl_2 (v_uns a, v_uns b) |
| 157 |
{ |
| 158 |
return vec_rl (a, b); |
| 159 |
} |
| 160 |
|
| 161 |
v_sign sign_sl_1 (v_sign a, v_sign b) |
| 162 |
{ |
| 163 |
return __builtin_altivec_vsld (a, b); |
| 164 |
} |
| 165 |
|
| 166 |
v_sign sign_sl_2 (v_sign a, v_uns b) |
| 167 |
{ |
| 168 |
return vec_sl (a, b); |
| 169 |
} |
| 170 |
|
| 171 |
v_sign sign_sl_3 (v_sign a, v_uns b) |
| 172 |
{ |
| 173 |
return vec_vsld (a, b); |
| 174 |
} |
| 175 |
|
| 176 |
v_uns uns_sl_2 (v_uns a, v_uns b) |
| 177 |
{ |
| 178 |
return vec_sl (a, b); |
| 179 |
} |
| 180 |
|
| 181 |
v_uns uns_sl_3 (v_uns a, v_uns b) |
| 182 |
{ |
| 183 |
return vec_vsld (a, b); |
| 184 |
} |
| 185 |
|
| 186 |
v_sign sign_sra_1 (v_sign a, v_sign b) |
| 187 |
{ |
| 188 |
return __builtin_altivec_vsrad (a, b); |
| 189 |
} |
| 190 |
|
| 191 |
v_sign sign_sra_2 (v_sign a, v_uns b) |
| 192 |
{ |
| 193 |
return vec_sra (a, b); |
| 194 |
} |
| 195 |
|
| 196 |
v_sign sign_sra_3 (v_sign a, v_uns b) |
| 197 |
{ |
| 198 |
return vec_vsrad (a, b); |
| 199 |
} |
| 200 |
|
| 201 |
v_bchar vbchar_eq (v_bchar a, v_bchar b) |
| 202 |
{ |
| 203 |
return vec_cmpeq (a, b); |
| 204 |
} |
| 205 |
|
| 206 |
v_bchar vbschar_eq (v_schar a, v_schar b) |
| 207 |
{ |
| 208 |
return vec_cmpeq (a, b); |
| 209 |
} |
| 210 |
|
| 211 |
v_bchar vuchar_eq (v_uchar a, v_uchar b) |
| 212 |
{ |
| 213 |
return vec_cmpeq (a, b); |
| 214 |
} |
| 215 |
|
| 216 |
v_bint vbint_eq (v_bint a, v_bint b) |
| 217 |
{ |
| 218 |
return vec_cmpeq (a, b); |
| 219 |
} |
| 220 |
|
| 221 |
v_bint vsint_eq (v_sint a, v_sint b) |
| 222 |
{ |
| 223 |
return vec_cmpeq (a, b); |
| 224 |
} |
| 225 |
|
| 226 |
v_bint vuint_eq (v_uint a, v_uint b) |
| 227 |
{ |
| 228 |
return vec_cmpeq (a, b); |
| 229 |
} |
| 230 |
|
| 231 |
v_bool vbool_eq (v_bool a, v_bool b) |
| 232 |
{ |
| 233 |
return vec_cmpeq (a, b); |
| 234 |
} |
| 235 |
|
| 236 |
v_bint vbint_ne (v_bint a, v_bint b) |
| 237 |
{ |
| 238 |
return vec_cmpne (a, b); |
| 239 |
} |
| 240 |
|
| 241 |
v_bint vsint_ne (v_sint a, v_sint b) |
| 242 |
{ |
| 243 |
return vec_cmpne (a, b); |
| 244 |
} |
| 245 |
|
| 246 |
v_bint vuint_ne (v_uint a, v_uint b) |
| 247 |
{ |
| 248 |
return vec_cmpne (a, b); |
| 249 |
} |
| 250 |
|
| 251 |
v_bool vbool_ne (v_bool a, v_bool b) |
| 252 |
{ |
| 253 |
return vec_cmpne (a, b); |
| 254 |
} |
| 255 |
|
| 256 |
v_bool vsign_ne (v_sign a, v_sign b) |
| 257 |
{ |
| 258 |
return vec_cmpne (a, b); |
| 259 |
} |
| 260 |
|
| 261 |
v_bool vuns_ne (v_uns a, v_uns b) |
| 262 |
{ |
| 263 |
return vec_cmpne (a, b); |
| 264 |
} |
| 265 |
|
| 266 |
v_bshort vbshort_ne (v_bshort a, v_bshort b) |
| 267 |
{ |
| 268 |
return vec_cmpne (a, b); |
| 269 |
} |
| 270 |
|
| 271 |
|
| 272 |
/* { dg-final { scan-assembler-times "vaddudm" 5 } } */ |
| 273 |
/* { dg-final { scan-assembler-times "vsubudm" 6 } } */ |
| 274 |
/* { dg-final { scan-assembler-times "vmaxsd" 4 } } */ |
| 275 |
/* { dg-final { scan-assembler-times "vminsd" 3 } } */ |
| 276 |
/* { dg-final { scan-assembler-times "vmaxud" 2 } } */ |
| 277 |
/* { dg-final { scan-assembler-times "vminud" 2 } } */ |
| 278 |
/* { dg-final { scan-assembler-times "vcmpequd" 6 } } */ |
| 279 |
/* { dg-final { scan-assembler-times "vcmpgtsd" 1 } } */ |
| 280 |
/* { dg-final { scan-assembler-times "vcmpgtud" 1 } } */ |
| 281 |
/* { dg-final { scan-assembler-times "vrld" 3 } } */ |
| 282 |
/* { dg-final { scan-assembler-times "vsld" 5 } } */ |
| 283 |
/* { dg-final { scan-assembler-times "vsrad" 3 } } */ |
| 284 |
/* { dg-final { scan-assembler-times "vcmpequb" 3 } } */ |
| 285 |
/* { dg-final { scan-assembler-times "vcmpequw" 6 } } */ |