• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-unknown-unknown -mcpu=generic | FileCheck %s --check-prefix=X86
3; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=generic | FileCheck %s --check-prefix=X64
4
5; Verify that we correctly lower ISD::READCYCLECOUNTER.
6
7
8define i64 @test_builtin_readcyclecounter() {
9; X86-LABEL: test_builtin_readcyclecounter:
10; X86:       # %bb.0:
11; X86-NEXT:    rdtsc
12; X86-NEXT:    retl
13;
14; X64-LABEL: test_builtin_readcyclecounter:
15; X64:       # %bb.0:
16; X64-NEXT:    rdtsc
17; X64-NEXT:    shlq $32, %rdx
18; X64-NEXT:    orq %rdx, %rax
19; X64-NEXT:    retq
20  %1 = tail call i64 @llvm.readcyclecounter()
21  ret i64 %1
22}
23
24; Verify that we correctly lower the Read Cycle Counter GCC x86 builtins
25; (i.e. RDTSC and RDTSCP).
26
27define i64 @test_builtin_rdtsc() {
28; X86-LABEL: test_builtin_rdtsc:
29; X86:       # %bb.0:
30; X86-NEXT:    rdtsc
31; X86-NEXT:    retl
32;
33; X64-LABEL: test_builtin_rdtsc:
34; X64:       # %bb.0:
35; X64-NEXT:    rdtsc
36; X64-NEXT:    shlq $32, %rdx
37; X64-NEXT:    orq %rdx, %rax
38; X64-NEXT:    retq
39  %1 = tail call i64 @llvm.x86.rdtsc()
40  ret i64 %1
41}
42
43define i64 @test_builtin_rdtscp(i8* %A) {
44; X86-LABEL: test_builtin_rdtscp:
45; X86:       # %bb.0:
46; X86-NEXT:    pushl %esi
47; X86-NEXT:    .cfi_def_cfa_offset 8
48; X86-NEXT:    .cfi_offset %esi, -8
49; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
50; X86-NEXT:    rdtscp
51; X86-NEXT:    movl %ecx, (%esi)
52; X86-NEXT:    popl %esi
53; X86-NEXT:    .cfi_def_cfa_offset 4
54; X86-NEXT:    retl
55;
56; X64-LABEL: test_builtin_rdtscp:
57; X64:       # %bb.0:
58; X64-NEXT:    rdtscp
59; X64-NEXT:    shlq $32, %rdx
60; X64-NEXT:    orq %rdx, %rax
61; X64-NEXT:    movl %ecx, (%rdi)
62; X64-NEXT:    retq
63  %1 = call { i64, i32 } @llvm.x86.rdtscp()
64  %2 = extractvalue { i64, i32 } %1, 1
65  %3 = bitcast i8* %A to i32*
66  store i32 %2, i32* %3, align 1
67  %4 = extractvalue { i64, i32 } %1, 0
68  ret i64 %4
69}
70
71declare i64 @llvm.readcyclecounter()
72declare { i64, i32 } @llvm.x86.rdtscp()
73declare i64 @llvm.x86.rdtsc()
74
75