1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck %s --check-prefix=X64
3 ; RUN: llc < %s -mtriple=x86_64-linux-gnux32 | FileCheck %s --check-prefix=X32
4 ; RUN: llc < %s -mtriple=i386-linux-gnu | FileCheck %s --check-prefix=X86
6 declare ptr @llvm.thread.pointer()
8 define ptr @thread_pointer() nounwind {
9 ; X64-LABEL: thread_pointer:
11 ; X64-NEXT: movq %fs:0, %rax
14 ; X32-LABEL: thread_pointer:
16 ; X32-NEXT: movl %fs:0, %eax
19 ; X86-LABEL: thread_pointer:
21 ; X86-NEXT: movl %gs:0, %eax
23 %1 = tail call ptr @llvm.thread.pointer()
27 define i32 @thread_pointer2(i32 %i) nounwind {
28 ; X64-LABEL: thread_pointer2:
29 ; X64: # %bb.0: # %entry
30 ; X64-NEXT: movslq %edi, %rax
31 ; X64-NEXT: movl %fs:(,%rax,4), %eax
34 ; X32-LABEL: thread_pointer2:
35 ; X32: # %bb.0: # %entry
36 ; X32-NEXT: movl %fs:0, %eax
37 ; X32-NEXT: movl (%eax,%edi,4), %eax
40 ; X86-LABEL: thread_pointer2:
41 ; X86: # %bb.0: # %entry
42 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
43 ; X86-NEXT: movl %gs:(,%eax,4), %eax
46 %0 = tail call ptr @llvm.thread.pointer()
47 %arrayidx = getelementptr inbounds i32, ptr %0, i32 %i
48 %1 = load i32, ptr %arrayidx, align 4