1/* { dg-do run } */ 2/* { dg-options "-mavx2 -O2" } */ 3/* { dg-require-effective-target avx2 } */ 4 5#include "avx2-check.h" 6#include <string.h> 7 8#define NUM 20 9 10static void 11init_pblendb (char *src1, char *src2, char *mask, int seed) 12{ 13 int i, sign = 1; 14 15 for (i = 0; i < 32; i++) 16 { 17 src1[i] = (i + seed) * (i + seed) * sign; 18 src2[i] = (i + seed + 20) * sign; 19 sign = -sign; 20 21 if (sign > 0) 22 mask[i] = 1 << 7; 23 else 24 mask[i] = 0; 25 } 26} 27 28static void 29calc_pblendb (char *src1, char *src2, char *mask, char *dst) 30{ 31 int i; 32 33 memcpy (dst, src1, 32); 34 for (i = 0; i < 32; i++) 35 if (mask[i] & (1 << 7)) 36 dst[i] = src2[i]; 37} 38 39static void 40avx2_test (void) 41{ 42 union256i_b src1, src2, mask, dst; 43 char dst_ref[32]; 44 int i; 45 46 for (i = 0; i < NUM; i++) 47 { 48 init_pblendb (src1.a, src2.a, mask.a, i); 49 50 dst.x = _mm256_blendv_epi8 (src1.x, src2.x, mask.x); 51 calc_pblendb (src1.a, src2.a, mask.a, dst_ref); 52 53 if (check_union256i_b (dst, dst_ref)) 54 abort (); 55 } 56} 57