[PowerPC] Eliminate compares - add i32 sext/zext handling for SETULT/SETUGT
[llvm-core.git] / test / Transforms / EarlyCSE / invariant.start.ll
blob8b468a5b308a135f8b515767dec405f17c941a99
1 ; RUN: opt < %s -S -early-cse | FileCheck %s
2 ; RUN: opt < %s -S -passes=early-cse | FileCheck %s
4 declare {}* @llvm.invariant.start.p0i8(i64, i8* nocapture) nounwind readonly
5 declare void @llvm.invariant.end.p0i8({}*, i64, i8* nocapture) nounwind
7 ; Check that we do load-load forwarding over invariant.start, since it does not
8 ; clobber memory
9 define i8 @test1(i8 *%P) {
10   ; CHECK-LABEL: @test1(
11   ; CHECK-NEXT: %V1 = load i8, i8* %P
12   ; CHECK-NEXT: %i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %P)
13   ; CHECK-NEXT: ret i8 0
16   %V1 = load i8, i8* %P
17   %i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %P)
18   %V2 = load i8, i8* %P
19   %Diff = sub i8 %V1, %V2
20   ret i8 %Diff
24 ; Trivial Store->load forwarding over invariant.start
25 define i8 @test2(i8 *%P) {
26   ; CHECK-LABEL: @test2(
27   ; CHECK-NEXT: store i8 42, i8* %P
28   ; CHECK-NEXT: %i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %P)
29   ; CHECK-NEXT: ret i8 42
32   store i8 42, i8* %P
33   %i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %P)
34   %V1 = load i8, i8* %P
35   ret i8 %V1
38 ; We can DSE over invariant.start calls, since the first store to
39 ; %P is valid, and the second store is actually unreachable based on semantics
40 ; of invariant.start.
41 define void @test3(i8* %P) {
43 ; CHECK-LABEL: @test3(
44 ; CHECK-NEXT:  %i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %P)
45 ; CHECK-NEXT:  store i8 60, i8* %P
48   store i8 50, i8* %P
49   %i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %P)
50   store i8 60, i8* %P
51   ret void
55 ; FIXME: Now the first store can actually be eliminated, since there is no read within
56 ; the invariant region, between start and end.
57 define void @test4(i8* %P) {
59 ; CHECK-LABEL: @test4(
60 ; CHECK-NEXT: store i8 50, i8* %P
61 ; CHECK-NEXT:  %i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %P)
62 ; CHECK-NEXT: call void @llvm.invariant.end.p0i8({}* %i, i64 1, i8* %P)
63 ; CHECK-NEXT:  store i8 60, i8* %P
66   store i8 50, i8* %P
67   %i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %P)
68   call void @llvm.invariant.end.p0i8({}* %i, i64 1, i8* %P)
69   store i8 60, i8* %P
70   ret void