1 ; RUN: opt -O2 -mtriple=bpf-pc-linux %s | llvm-dis > %t1
2 ; RUN: llc %t1 -o - | FileCheck -check-prefixes=CHECK %s
3 ; RUN: opt -passes='default<O2>' -mtriple=bpf-pc-linux %s | llvm-dis > %t1
4 ; RUN: llc %t1 -o - | FileCheck -check-prefixes=CHECK %s
5 ; RUN: opt -O2 -mtriple=bpf-pc-linux -bpf-disable-serialize-icmp %s | llvm-dis > %t1
6 ; RUN: llc %t1 -o - | FileCheck -check-prefixes=CHECK-DISABLE %s
7 ; RUN: opt -passes='default<O2>' -mtriple=bpf-pc-linux -bpf-disable-serialize-icmp %s | llvm-dis > %t1
8 ; RUN: llc %t1 -o - | FileCheck -check-prefixes=CHECK-DISABLE %s
15 ; if (ret <= 0 || ret > 7)
20 ; clang -target bpf -O2 -S -emit-llvm -Xclang -disable-llvm-passes test.c
22 ; Function Attrs: nounwind
23 define dso_local i32 @test() #0 {
25 %retval = alloca i32, align 4
26 %ret = alloca i32, align 4
27 %cleanup.dest.slot = alloca i32, align 4
28 call void @llvm.lifetime.start.p0(i64 4, ptr %ret) #3
29 %call = call i32 @foo()
30 store i32 %call, ptr %ret, align 4, !tbaa !2
31 %0 = load i32, ptr %ret, align 4, !tbaa !2
32 %cmp = icmp sle i32 %0, 0
33 br i1 %cmp, label %if.then, label %lor.lhs.false
35 ; CHECK: [[REG1:r[0-9]+]] <<= 32
36 ; CHECK: [[REG1]] s>>= 32
37 ; CHECK: [[REG2:r[0-9]+]] = 1
38 ; CHECK: if [[REG2]] s> [[REG1]] goto
39 ; CHECK: if [[REG1]] s> 7 goto
41 ; CHECK-DISABLE: [[REG1:r[0-9]+]] += -8
42 ; CHECK-DISABLE: [[REG1]] <<= 32
43 ; CHECK-DISABLE: [[REG1]] >>= 32
44 ; CHECK-DISABLE: [[REG2:r[0-9]+]] = 4294967289
45 ; CHECK-DISABLE: if [[REG2]] > [[REG1]] goto
47 lor.lhs.false: ; preds = %entry
48 %1 = load i32, ptr %ret, align 4, !tbaa !2
49 %cmp1 = icmp sgt i32 %1, 7
50 br i1 %cmp1, label %if.then, label %if.end
52 if.then: ; preds = %lor.lhs.false, %entry
53 store i32 0, ptr %retval, align 4
54 store i32 1, ptr %cleanup.dest.slot, align 4
57 if.end: ; preds = %lor.lhs.false
58 %2 = load i32, ptr %ret, align 4, !tbaa !2
59 %call2 = call i32 @bar(i32 %2)
60 store i32 %call2, ptr %retval, align 4
61 store i32 1, ptr %cleanup.dest.slot, align 4
64 cleanup: ; preds = %if.end, %if.then
65 call void @llvm.lifetime.end.p0(i64 4, ptr %ret) #3
66 %3 = load i32, ptr %retval, align 4
70 ; Function Attrs: argmemonly nounwind willreturn
71 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
73 declare dso_local i32 @foo(...) #2
75 declare dso_local i32 @bar(i32) #2
77 ; Function Attrs: argmemonly nounwind willreturn
78 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
80 attributes #0 = { nounwind "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
81 attributes #1 = { argmemonly nounwind willreturn }
82 attributes #2 = { "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
83 attributes #3 = { nounwind }
85 !llvm.module.flags = !{!0}
88 !0 = !{i32 1, !"wchar_size", i32 4}
89 !1 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git ca9c5433a6c31e372092fcd8bfd0e4fddd7e8784)"}
91 !3 = !{!"int", !4, i64 0}
92 !4 = !{!"omnipotent char", !5, i64 0}
93 !5 = !{!"Simple C/C++ TBAA"}