1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; Test to make sure llvm.invariant.start calls are not treated as clobbers.
3 ; RUN: opt < %s -passes=dse -S | FileCheck %s
5 declare ptr @llvm.invariant.start.p0(i64, ptr nocapture) nounwind readonly
7 ; We could remove either store here. The first store is dead in the
8 ; conventional sense, because there is a later killing store. The second store
9 ; is undefined behavior by the semantics of invariant.start, and as such
11 define void @test(ptr %p) {
13 ; CHECK-NEXT: store i8 3, ptr [[P:%.*]], align 4
14 ; CHECK-NEXT: ret void
16 store i8 1, ptr %p, align 4
17 %i = call ptr @llvm.invariant.start.p0(i64 1, ptr %p)
18 store i8 3, ptr %p, align 4
22 ; FIXME: We should be able to remove the first store to p, even though p and q
24 define void @test2(ptr %p, ptr %q) {
25 ; CHECK-LABEL: @test2(
26 ; CHECK-NEXT: store i8 1, ptr [[P:%.*]], align 4
27 ; CHECK-NEXT: store i8 2, ptr [[Q:%.*]], align 4
28 ; CHECK-NEXT: [[I:%.*]] = call ptr @llvm.invariant.start.p0(i64 1, ptr [[Q]])
29 ; CHECK-NEXT: store i8 3, ptr [[P]], align 4
30 ; CHECK-NEXT: ret void
32 store i8 1, ptr %p, align 4
33 store i8 2, ptr %q, align 4
34 %i = call ptr @llvm.invariant.start.p0(i64 1, ptr %q)
35 store i8 3, ptr %p, align 4