1 ; RUN: llvm-as < %s | llc | FileCheck %s
3 ; check that cmp/test is not scheduled before the add
4 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
5 target triple = "x86_64-unknown-linux-gnu"
7 @.str76843 = external dso_local constant [45 x i8] ; <ptr> [#uses=1]
8 @__profiling_callsite_timestamps_live = external dso_local global [1216 x i64] ; <ptr> [#uses=2]
10 define i32 @cl_init(i32 %initoptions) nounwind {
12 %retval.i = alloca i32 ; <ptr> [#uses=3]
13 %retval = alloca i32 ; <ptr> [#uses=2]
14 %initoptions.addr = alloca i32 ; <ptr> [#uses=2]
15 tail call void asm sideeffect "cpuid", "~{ax},~{bx},~{cx},~{dx},~{memory},~{dirflag},~{fpsr},~{flags}"() nounwind
16 %0 = tail call i64 @llvm.readcyclecounter() nounwind ; <i64> [#uses=1]
17 store i32 %initoptions, ptr %initoptions.addr
18 call void asm sideeffect "cpuid", "~{ax},~{bx},~{cx},~{dx},~{memory},~{dirflag},~{fpsr},~{flags}"() nounwind
19 %1 = call i64 @llvm.readcyclecounter() nounwind ; <i64> [#uses=1]
20 %call.i = call i32 @lt_dlinit() nounwind ; <i32> [#uses=1]
21 %tobool.i = icmp ne i32 %call.i, 0 ; <i1> [#uses=1]
22 br i1 %tobool.i, label %if.then.i, label %if.end.i
24 if.then.i: ; preds = %entry
25 %call1.i = call i32 @warn_dlerror(ptr @.str76843) nounwind ; <i32> [#uses=0]
26 store i32 -1, ptr %retval.i
27 br label %lt_init.exit
29 if.end.i: ; preds = %entry
30 store i32 0, ptr %retval.i
31 br label %lt_init.exit
33 lt_init.exit: ; preds = %if.end.i, %if.then.i
34 %2 = load i32, ptr %retval.i ; <i32> [#uses=1]
35 call void asm sideeffect "cpuid", "~{ax},~{bx},~{cx},~{dx},~{memory},~{dirflag},~{fpsr},~{flags}"() nounwind
36 %3 = call i64 @llvm.readcyclecounter() nounwind ; <i64> [#uses=1]
37 %4 = sub i64 %3, %1 ; <i64> [#uses=1]
38 %5 = atomicrmw add ptr getelementptr inbounds ([1216 x i64], ptr @__profiling_callsite_timestamps_live, i32 0, i32 51), i64 %4 monotonic
39 ;CHECK: lock {{xadd|addq}} %rdx, __profiling_callsite_timestamps_live
40 ;CHECK-NEXT: testl [[REG:%e[a-z]+]], [[REG]]
42 %cmp = icmp eq i32 %2, 0 ; <i1> [#uses=1]
43 br i1 %cmp, label %if.then, label %if.end
45 if.then: ; preds = %lt_init.exit
46 call void @cli_rarload()
49 if.end: ; preds = %if.then, %lt_init.exit
50 store i32 0, ptr %retval
51 %6 = load i32, ptr %retval ; <i32> [#uses=1]
52 tail call void asm sideeffect "cpuid", "~{ax},~{bx},~{cx},~{dx},~{memory},~{dirflag},~{fpsr},~{flags}"() nounwind
53 %7 = tail call i64 @llvm.readcyclecounter() nounwind ; <i64> [#uses=1]
54 %8 = sub i64 %7, %0 ; <i64> [#uses=1]
55 %9 = atomicrmw add ptr getelementptr inbounds ([1216 x i64], ptr @__profiling_callsite_timestamps_live, i32 0, i32 50), i64 %8 monotonic
59 declare void @cli_rarload() nounwind
61 declare i32 @lt_dlinit()
63 declare i32 @warn_dlerror(ptr) nounwind
65 declare i64 @llvm.readcyclecounter() nounwind