1/* PR rtl-optimization/64286 */
2/* { dg-do run } */
3/* { dg-options "-O2 -mavx2" } */
4/* { dg-require-effective-target avx2 } */
5
6#include <string.h>
7#include <stdlib.h>
8#include <x86intrin.h>
9#include "avx2-check.h"
10
11__m128i v;
12__m256i w;
13
14__attribute__((noinline, noclone)) void
15foo (__m128i *p, __m128i *q)
16{
17  __m128i a = _mm_loadu_si128 (p);
18  __m128i b = _mm_xor_si128 (a, v);
19  w = _mm256_cvtepu8_epi16 (a);
20  *q = b;
21}
22
23static void
24avx2_test (void)
25{
26  v = _mm_set1_epi8 (0x40);
27  __m128i c = _mm_set_epi8 (16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
28  __m128i d;
29  foo (&c, &d);
30  __m128i e = _mm_set_epi8 (0x50, 0x4f, 0x4e, 0x4d, 0x4c, 0x4b, 0x4a, 0x49,
31			    0x48, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41);
32  __m256i f = _mm256_set_epi16 (16, 15, 14, 13, 12, 11, 10, 9,
33				8, 7, 6, 5, 4, 3, 2, 1);
34  if (memcmp (&w, &f, sizeof (w)) != 0
35      || memcmp (&d, &e, sizeof (d)) != 0)
36    abort ();
37}
38