1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=mem2reg -S -o - < %s | FileCheck %s
4 declare void @llvm.assume(i1)
5 declare void @llvm.lifetime.start.p0(i64 %size, ptr nocapture %ptr)
6 declare void @llvm.lifetime.end.p0(i64 %size, ptr nocapture %ptr)
8 define void @positive_assume_uses(ptr %arg) {
9 ; CHECK-LABEL: @positive_assume_uses(
10 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(ptr [[ARG:%.*]]), "ignore"(ptr undef, i64 2) ]
11 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef, i64 8), "nonnull"(ptr [[ARG]]) ]
12 ; CHECK-NEXT: ret void
15 call void @llvm.assume(i1 true) ["nonnull"(ptr %arg), "align"(ptr %A, i64 2)]
17 call void @llvm.assume(i1 true) ["align"(ptr %A, i64 8), "nonnull"(ptr %arg)]
21 define void @negative_assume_condition_use() {
22 ; CHECK-LABEL: @negative_assume_condition_use(
23 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
24 ; CHECK-NEXT: [[CND:%.*]] = icmp eq ptr [[A]], null
25 ; CHECK-NEXT: call void @llvm.assume(i1 [[CND]])
26 ; CHECK-NEXT: store i32 1, ptr [[A]], align 4
27 ; CHECK-NEXT: ret void
30 %cnd = icmp eq ptr %A, null
31 call void @llvm.assume(i1 %cnd)
36 define void @positive_multiple_assume_uses() {
37 ; CHECK-LABEL: @positive_multiple_assume_uses(
38 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef, i64 8), "ignore"(ptr undef, i64 16) ]
39 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef), "ignore"(ptr undef, i64 2) ]
40 ; CHECK-NEXT: ret void
43 call void @llvm.assume(i1 true) ["align"(ptr %A, i64 8), "align"(ptr %A, i64 16)]
44 store {i8, i16} zeroinitializer, ptr %A
45 call void @llvm.assume(i1 true) ["nonnull"(ptr %A), "align"(ptr %A, i64 2)]
49 define void @positive_gep_assume_uses() {
50 ; CHECK-LABEL: @positive_gep_assume_uses(
51 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef, i64 8), "ignore"(ptr undef, i64 16) ]
52 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef), "ignore"(ptr undef, i64 2) ]
53 ; CHECK-NEXT: ret void
56 %B = getelementptr {i8, i16}, ptr %A, i32 0, i32 0
57 call void @llvm.lifetime.start.p0(i64 2, ptr %B)
58 call void @llvm.assume(i1 true) ["align"(ptr %B, i64 8), "align"(ptr %B, i64 16)]
59 store {i8, i16} zeroinitializer, ptr %A
60 call void @llvm.lifetime.end.p0(i64 2, ptr %B)
61 call void @llvm.assume(i1 true) ["nonnull"(ptr %B), "align"(ptr %B, i64 2)]
65 define void @positive_mixed_assume_uses() {
66 ; CHECK-LABEL: @positive_mixed_assume_uses(
67 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef), "ignore"(ptr undef, i64 8), "ignore"(ptr undef, i64 16) ]
68 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef), "ignore"(ptr undef, i64 2), "ignore"(ptr undef) ]
69 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(ptr undef), "ignore"(ptr undef, i64 2), "ignore"(ptr undef) ]
70 ; CHECK-NEXT: ret void
73 call void @llvm.lifetime.start.p0(i64 2, ptr %A)
74 call void @llvm.assume(i1 true) ["nonnull"(ptr %A), "align"(ptr %A, i64 8), "align"(ptr %A, i64 16)]
76 call void @llvm.lifetime.end.p0(i64 2, ptr %A)
77 call void @llvm.assume(i1 true) ["nonnull"(ptr %A), "align"(ptr %A, i64 2), "nonnull"(ptr %A)]
78 call void @llvm.assume(i1 true) ["nonnull"(ptr %A), "align"(ptr %A, i64 2), "nonnull"(ptr %A)]