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
5 ; Verify that we correctly lower ISD::READCYCLECOUNTER.
8 define i64 @test_builtin_readcyclecounter() {
9 ; X86-LABEL: test_builtin_readcyclecounter:
14 ; X64-LABEL: test_builtin_readcyclecounter:
17 ; X64-NEXT: shlq $32, %rdx
18 ; X64-NEXT: orq %rdx, %rax
20 %1 = tail call i64 @llvm.readcyclecounter()
24 ; Verify that we correctly lower the Read Cycle Counter GCC x86 builtins
25 ; (i.e. RDTSC and RDTSCP).
27 define i64 @test_builtin_rdtsc() {
28 ; X86-LABEL: test_builtin_rdtsc:
33 ; X64-LABEL: test_builtin_rdtsc:
36 ; X64-NEXT: shlq $32, %rdx
37 ; X64-NEXT: orq %rdx, %rax
39 %1 = tail call i64 @llvm.x86.rdtsc()
43 define i64 @test_builtin_rdtscp(ptr %A) {
44 ; X86-LABEL: test_builtin_rdtscp:
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
51 ; X86-NEXT: movl %ecx, (%esi)
53 ; X86-NEXT: .cfi_def_cfa_offset 4
56 ; X64-LABEL: test_builtin_rdtscp:
59 ; X64-NEXT: shlq $32, %rdx
60 ; X64-NEXT: orq %rdx, %rax
61 ; X64-NEXT: movl %ecx, (%rdi)
63 %1 = call { i64, i32 } @llvm.x86.rdtscp()
64 %2 = extractvalue { i64, i32 } %1, 1
65 store i32 %2, ptr %A, align 1
66 %3 = extractvalue { i64, i32 } %1, 0
70 declare i64 @llvm.readcyclecounter()
71 declare { i64, i32 } @llvm.x86.rdtscp()
72 declare i64 @llvm.x86.rdtsc()