1; RUN: llc < %s -march=x86-64 -mcpu=generic | FileCheck %s
2; RUN: llc < %s -march=x86 -mcpu=generic | FileCheck %s --check-prefix=CHECK --check-prefix=X86
3
4; Verify that we correctly lower ISD::READCYCLECOUNTER.
5
6
7define i64 @test_builtin_readcyclecounter() {
8  %1 = tail call i64 @llvm.readcyclecounter()
9  ret i64 %1
10}
11; CHECK-LABEL: test_builtin_readcyclecounter
12; CHECK: rdtsc
13; X86-NOT: shlq
14; X86-NOT: or
15; CHECK-NOT: mov
16; CHECK: ret
17
18
19; Verify that we correctly lower the Read Cycle Counter GCC x86 builtins
20; (i.e. RDTSC and RDTSCP).
21
22define i64 @test_builtin_rdtsc() {
23  %1 = tail call i64 @llvm.x86.rdtsc()
24  ret i64 %1
25}
26; CHECK-LABEL: test_builtin_rdtsc
27; CHECK: rdtsc
28; X86-NOT: shlq
29; X86-NOT: or
30; CHECK-NOT: mov
31; CHECK: ret
32
33
34define i64 @test_builtin_rdtscp(i8* %A) {
35  %1 = tail call i64 @llvm.x86.rdtscp(i8* %A)
36  ret i64 %1
37}
38; CHECK-LABEL: test_builtin_rdtscp
39; CHECK: rdtscp
40; X86-NOT: shlq
41; CHECK:   movl	%ecx, (%{{[a-z0-9]+}})
42; X86-NOT: shlq
43; CHECK: ret
44
45
46declare i64 @llvm.readcyclecounter()
47declare i64 @llvm.x86.rdtscp(i8*)
48declare i64 @llvm.x86.rdtsc()
49
50