1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes='sroa<preserve-cfg>' -S | FileCheck %s --check-prefixes=CHECK,CHECK-PRESERVE-CFG
3 ; RUN: opt < %s -passes='sroa<modify-cfg>' -S | FileCheck %s --check-prefixes=CHECK,CHECK-MODIFY-CFG
5 declare void @llvm.assume(i1)
6 declare void @llvm.lifetime.start.p0(i64 %size, ptr nocapture %ptr)
7 declare void @llvm.lifetime.end.p0(i64 %size, ptr nocapture %ptr)
9 define void @positive_assume_uses(ptr %arg) {
10 ; CHECK-LABEL: @positive_assume_uses(
11 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(ptr [[ARG:%.*]]), "ignore"(ptr undef, i64 2) ]
12 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef, i64 8), "nonnull"(ptr [[ARG]]) ]
13 ; CHECK-NEXT: ret void
16 call void @llvm.assume(i1 true) ["nonnull"(ptr %arg), "align"(ptr %A, i64 2)]
18 call void @llvm.assume(i1 true) ["align"(ptr %A, i64 8), "nonnull"(ptr %arg)]
22 define void @negative_assume_condition_use() {
23 ; CHECK-LABEL: @negative_assume_condition_use(
24 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
25 ; CHECK-NEXT: [[CND:%.*]] = icmp eq ptr [[A]], null
26 ; CHECK-NEXT: call void @llvm.assume(i1 [[CND]])
27 ; CHECK-NEXT: store i32 1, ptr [[A]], align 4
28 ; CHECK-NEXT: ret void
31 %cnd = icmp eq ptr %A, null
32 call void @llvm.assume(i1 %cnd)
37 define void @positive_multiple_assume_uses() {
38 ; CHECK-LABEL: @positive_multiple_assume_uses(
39 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef, i64 8), "ignore"(ptr undef, i64 16) ]
40 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef), "ignore"(ptr undef, i64 2) ]
41 ; CHECK-NEXT: ret void
44 call void @llvm.assume(i1 true) ["align"(ptr %A, i64 8), "align"(ptr %A, i64 16)]
45 store {i8, i16} zeroinitializer, ptr %A
46 call void @llvm.assume(i1 true) ["nonnull"(ptr %A), "align"(ptr %A, i64 2)]
50 define void @positive_gep_assume_uses() {
51 ; CHECK-LABEL: @positive_gep_assume_uses(
52 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef, i64 8), "ignore"(ptr undef, i64 16) ]
53 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef), "ignore"(ptr undef, i64 2) ]
54 ; CHECK-NEXT: ret void
57 %B = getelementptr {i8, i16}, ptr %A, i32 0, i32 0
58 call void @llvm.lifetime.start.p0(i64 2, ptr %B)
59 call void @llvm.assume(i1 true) ["align"(ptr %B, i64 8), "align"(ptr %B, i64 16)]
60 store {i8, i16} zeroinitializer, ptr %A
61 call void @llvm.lifetime.end.p0(i64 2, ptr %B)
62 call void @llvm.assume(i1 true) ["nonnull"(ptr %B), "align"(ptr %B, i64 2)]
66 define void @positive_mixed_assume_uses() {
67 ; CHECK-LABEL: @positive_mixed_assume_uses(
68 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef), "ignore"(ptr undef, i64 8), "ignore"(ptr undef, i64 16) ]
69 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef), "ignore"(ptr undef, i64 2), "ignore"(ptr undef) ]
70 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef), "ignore"(ptr undef, i64 2), "ignore"(ptr undef) ]
71 ; CHECK-NEXT: ret void
74 call void @llvm.lifetime.start.p0(i64 2, ptr %A)
75 call void @llvm.assume(i1 true) ["nonnull"(ptr %A), "align"(ptr %A, i64 8), "align"(ptr %A, i64 16)]
77 call void @llvm.lifetime.end.p0(i64 2, ptr %A)
78 call void @llvm.assume(i1 true) ["nonnull"(ptr %A), "align"(ptr %A, i64 2), "nonnull"(ptr %A)]
79 call void @llvm.assume(i1 true) ["nonnull"(ptr %A), "align"(ptr %A, i64 2), "nonnull"(ptr %A)]
82 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
83 ; CHECK-MODIFY-CFG: {{.*}}
84 ; CHECK-PRESERVE-CFG: {{.*}}