62 lines · plain
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py2# RUN: llc -run-pass=peephole-opt -mtriple=x86_64-- %s -o - | FileCheck %s3 4# Linkers may change `addq xx@GOTTPOFF, %reg` to `leaq OFFSET(%reg), %reg`,5# so we must not depend upon the EFLAGS output. Verify that the TEST6# instruction won't be folded into the ADD.7 8# NOTE: the IR will no longer actually produce the input MIR after9# llvm.threadlocal.address intrinsic is annotated as having a nonnull10# result.11 12--- |13 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"14 target triple = "x86_64-unknown-linux-gnu"15 16 @x = external thread_local(initialexec) global i32, align 417 18 define i32 @foo() {19 %1 = tail call ptr @llvm.threadlocal.address.p0(ptr nonnull @x)20 %cmp = icmp eq ptr %1, null21 %zext = zext i1 %cmp to i3222 ret i32 %zext23 }24 25 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn26 declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #027 28 attributes #0 = { nocallback nofree nosync nounwind readnone speculatable willreturn }29 30...31---32name: foo33alignment: 1634tracksRegLiveness: true35registers:36 - { id: 0, class: gr64 }37 - { id: 1, class: gr64 }38 - { id: 2, class: gr8 }39 - { id: 3, class: gr32 }40frameInfo:41 maxAlignment: 142machineFunctionInfo: {}43body: |44 bb.0 (%ir-block.0):45 ; CHECK-LABEL: name: foo46 ; CHECK: [[MOV64rm:%[0-9]+]]:gr64 = MOV64rm $noreg, 1, $noreg, 0, $fs :: (load (s64) from `ptr addrspace(257) null`, addrspace 257)47 ; CHECK-NEXT: [[ADD64rm:%[0-9]+]]:gr64 = ADD64rm [[MOV64rm]], $rip, 1, $noreg, target-flags(x86-gottpoff) @x, $noreg, implicit-def dead $eflags :: (load (s64) from got)48 ; CHECK-NEXT: TEST64rr [[ADD64rm]], [[ADD64rm]], implicit-def $eflags49 ; CHECK-NEXT: [[SETCCr:%[0-9]+]]:gr8 = SETCCr 4, implicit $eflags50 ; CHECK-NEXT: [[MOVZX32rr8_:%[0-9]+]]:gr32 = MOVZX32rr8 killed [[SETCCr]]51 ; CHECK-NEXT: $eax = COPY [[MOVZX32rr8_]]52 ; CHECK-NEXT: RET 0, $eax53 %0:gr64 = MOV64rm $noreg, 1, $noreg, 0, $fs :: (load (s64) from `ptr addrspace(257) null`, addrspace 257)54 %1:gr64 = ADD64rm %0, $rip, 1, $noreg, target-flags(x86-gottpoff) @x, $noreg, implicit-def dead $eflags :: (load (s64) from got)55 TEST64rr %1, %1, implicit-def $eflags56 %2:gr8 = SETCCr 4, implicit $eflags57 %3:gr32 = MOVZX32rr8 killed %258 $eax = COPY %359 RET 0, $eax60 61...62