Clang Project

clang_source_code/test/Sema/builtins-x86.cpp
1// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
2//
3// Ensure that when we use builtins in C++ code with templates that compute the
4// valid immediate, the dead code with the invalid immediate doesn't error.
5// expected-no-diagnostics
6
7typedef short __v8hi __attribute__((__vector_size__(16)));
8
9template <int Imm>
10__v8hi test(__v8hi a) {
11    if (Imm < 4)
12      return __builtin_ia32_pshuflw(a, 0x55 * Imm);
13    else
14      return __builtin_ia32_pshuflw(a, 0x55 * (Imm - 4));
15}
16
17template __v8hi test<0>(__v8hi);
18template __v8hi test<1>(__v8hi);
19template __v8hi test<2>(__v8hi);
20template __v8hi test<3>(__v8hi);
21template __v8hi test<4>(__v8hi);
22template __v8hi test<5>(__v8hi);
23template __v8hi test<6>(__v8hi);
24template __v8hi test<7>(__v8hi);
25