| 1 | // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm < %s| FileCheck %s |
| 2 | |
| 3 | // Test that we have the structure definition, the gep offsets, the name of the |
| 4 | // global, the bit grab, and the icmp correct. |
| 5 | extern void a(const char *); |
| 6 | |
| 7 | // CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] } |
| 8 | // CHECK: @__cpu_features2 = external dso_local global i32 |
| 9 | |
| 10 | int main() { |
| 11 | __builtin_cpu_init(); |
| 12 | |
| 13 | // CHECK: call void @__cpu_indicator_init |
| 14 | |
| 15 | if (__builtin_cpu_supports("sse4.2")) |
| 16 | a("sse4.2"); |
| 17 | |
| 18 | // CHECK: [[LOAD:%[^ ]+]] = load i32, i32* getelementptr inbounds ({ i32, i32, i32, [1 x i32] }, { i32, i32, i32, [1 x i32] }* @__cpu_model, i32 0, i32 3, i32 0) |
| 19 | // CHECK: [[AND:%[^ ]+]] = and i32 [[LOAD]], 256 |
| 20 | // CHECK: = icmp eq i32 [[AND]], 256 |
| 21 | |
| 22 | if (__builtin_cpu_supports("gfni")) |
| 23 | a("gfni"); |
| 24 | |
| 25 | // CHECK: [[LOAD:%[^ ]+]] = load i32, i32* @__cpu_features2 |
| 26 | // CHECK: [[AND:%[^ ]+]] = and i32 [[LOAD]], 1 |
| 27 | // CHECK: = icmp eq i32 [[AND]], 1 |
| 28 | |
| 29 | return 0; |
| 30 | } |
| 31 | |
| 32 | // CHECK: declare dso_local void @__cpu_indicator_init() |
| 33 | |