1 ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
3 ; CHECK-SPIRV-NOT: OpCapability ExpectAssumeKHR
4 ; CHECK-SPIRV-NOT: OpExtension "SPV_KHR_expect_assume"
5 ; CHECK-SPIRV: OpFunction
6 ; CHECK-SPIRV-NOT: %[[#]] = OpExpectKHR %[[#]] %[[#]] %[[#]]
7 ; CHECK-SPIRV: %[[#RES1:]] = OpSConvert %[[#]] %[[#]]
8 ; CHECK-SPIRV: %[[#]] = OpINotEqual %[[#]] %[[#RES1]] %[[#]]
10 ; CHECK-SPIRV: OpFunction
11 ; CHECK-SPIRV: %[[#RES2:]] = OpSConvert %[[#]] %[[#]]
12 ; CHECK-SPIRV-NOT: %[[#]] = OpExpectKHR %[[#]] %[[#]] %[[#]]
13 ; CHECK-SPIRV: %[[#]] = OpINotEqual %[[#]] %[[#RES2]] %[[#]]
15 %"class._ZTSZ4mainE3$_0.anon" = type { i8 }
17 define spir_kernel void @_ZTSZ4mainE15kernel_function() {
19 %0 = alloca %"class._ZTSZ4mainE3$_0.anon", align 1
20 %1 = bitcast %"class._ZTSZ4mainE3$_0.anon"* %0 to i8*
21 call void @llvm.lifetime.start.p0i8(i64 1, i8* %1)
22 %2 = addrspacecast %"class._ZTSZ4mainE3$_0.anon"* %0 to %"class._ZTSZ4mainE3$_0.anon" addrspace(4)*
23 call spir_func void @"_ZZ4mainENK3$_0clEv"(%"class._ZTSZ4mainE3$_0.anon" addrspace(4)* %2)
24 %3 = bitcast %"class._ZTSZ4mainE3$_0.anon"* %0 to i8*
25 call void @llvm.lifetime.end.p0i8(i64 1, i8* %3)
29 declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
31 define internal spir_func void @"_ZZ4mainENK3$_0clEv"(%"class._ZTSZ4mainE3$_0.anon" addrspace(4)* %this) align 2 {
33 %this.addr = alloca %"class._ZTSZ4mainE3$_0.anon" addrspace(4)*, align 8
34 %a = alloca i32, align 4
35 %b = alloca i32, align 4
36 store %"class._ZTSZ4mainE3$_0.anon" addrspace(4)* %this, %"class._ZTSZ4mainE3$_0.anon" addrspace(4)** %this.addr, align 8
37 %this1 = load %"class._ZTSZ4mainE3$_0.anon" addrspace(4)*, %"class._ZTSZ4mainE3$_0.anon" addrspace(4)** %this.addr, align 8
38 %0 = bitcast i32* %a to i8*
39 call void @llvm.lifetime.start.p0i8(i64 4, i8* %0)
40 %call = call spir_func i32 @_Z12expect_consti(i32 1)
41 store i32 %call, i32* %a, align 4
42 %1 = bitcast i32* %b to i8*
43 call void @llvm.lifetime.start.p0i8(i64 4, i8* %1)
44 %call2 = call spir_func i32 @_Z10expect_funi(i32 2)
45 store i32 %call2, i32* %b, align 4
46 %2 = bitcast i32* %b to i8*
47 call void @llvm.lifetime.end.p0i8(i64 4, i8* %2)
48 %3 = bitcast i32* %a to i8*
49 call void @llvm.lifetime.end.p0i8(i64 4, i8* %3)
53 declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
55 define spir_func i32 @_Z12expect_consti(i32 %x) {
57 %retval = alloca i32, align 4
58 %x.addr = alloca i32, align 4
59 store i32 %x, i32* %x.addr, align 4
60 %0 = load i32, i32* %x.addr, align 4
61 %conv = sext i32 %0 to i64
62 %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
63 %tobool = icmp ne i64 %expval, 0
64 br i1 %tobool, label %if.then, label %if.end
66 if.then: ; preds = %entry
67 store i32 0, i32* %retval, align 4
70 if.end: ; preds = %entry
71 %1 = load i32, i32* %x.addr, align 4
72 store i32 %1, i32* %retval, align 4
75 return: ; preds = %if.end, %if.then
76 %2 = load i32, i32* %retval, align 4
80 define spir_func i32 @_Z10expect_funi(i32 %x) {
82 %retval = alloca i32, align 4
83 %x.addr = alloca i32, align 4
84 store i32 %x, i32* %x.addr, align 4
85 %0 = load i32, i32* %x.addr, align 4
86 %conv = sext i32 %0 to i64
87 %call = call spir_func i32 @_Z3foov()
88 %conv1 = sext i32 %call to i64
89 %expval = call i64 @llvm.expect.i64(i64 %conv, i64 %conv1)
90 %tobool = icmp ne i64 %expval, 0
91 br i1 %tobool, label %if.then, label %if.end
93 if.then: ; preds = %entry
94 store i32 0, i32* %retval, align 4
97 if.end: ; preds = %entry
98 %1 = load i32, i32* %x.addr, align 4
99 store i32 %1, i32* %retval, align 4
102 return: ; preds = %if.end, %if.then
103 %2 = load i32, i32* %retval, align 4
107 declare i64 @llvm.expect.i64(i64, i64)
109 declare spir_func i32 @_Z3foov()