invariant.start.ll
1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
; Test to make sure llvm.invariant.start calls are not treated as clobbers.
; RUN: opt < %s -newgvn -S | FileCheck %s
declare {}* @llvm.invariant.start.p0i8(i64, i8* nocapture) nounwind readonly
declare void @llvm.invariant.end.p0i8({}*, i64, i8* nocapture) nounwind
; We forward store to the load across the invariant.start intrinsic
define i8 @forward_store() {
; CHECK-LABEL: @forward_store
; CHECK: call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a)
; CHECK-NOT: load
; CHECK: ret i8 0
%a = alloca i8
store i8 0, i8* %a
%i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a)
%r = load i8, i8* %a
ret i8 %r
}
declare i8 @dummy(i8* nocapture) nounwind readonly
; We forward store to the load in the non-local analysis case,
; i.e. invariant.start is in another basic block.
define i8 @forward_store_nonlocal(i1 %cond) {
; CHECK-LABEL: forward_store_nonlocal
; CHECK: call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a)
; CHECK: ret i8 0
; CHECK: ret i8 %val
%a = alloca i8
store i8 0, i8* %a
%i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a)
br i1 %cond, label %loadblock, label %exit
loadblock:
%r = load i8, i8* %a
ret i8 %r
exit:
%val = call i8 @dummy(i8* %a)
ret i8 %val
}
; We should not value forward %foo to the invariant.end corresponding to %bar.
define i8 @forward_store1() {
; CHECK-LABEL: forward_store1
; CHECK: %foo = call {}* @llvm.invariant.start.p0i8
; CHECK-NOT: load
; CHECK: %bar = call {}* @llvm.invariant.start.p0i8
; CHECK: call void @llvm.invariant.end.p0i8({}* %bar, i64 1, i8* %a)
; CHECK: ret i8 0
%a = alloca i8
store i8 0, i8* %a
%foo = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a)
%r = load i8, i8* %a
%bar = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a)
call void @llvm.invariant.end.p0i8({}* %bar, i64 1, i8* %a)
ret i8 %r
}