1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -mem2reg -S -o - < %s | FileCheck %s
3 ; RUN: opt -passes=mem2reg -S -o - < %s | FileCheck %s
5 declare void @llvm.assume(i1)
6 declare void @llvm.lifetime.start.p0i8(i64 %size, i8* nocapture %ptr)
7 declare void @llvm.lifetime.end.p0i8(i64 %size, i8* nocapture %ptr)
9 define void @positive_assume_uses(i32* %arg) {
10 ; CHECK-LABEL: @positive_assume_uses(
11 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(i32* [[ARG:%.*]]), "ignore"(i32* undef, i64 2) ]
12 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(i32* undef, i64 8), "nonnull"(i32* [[ARG]]) ]
13 ; CHECK-NEXT: ret void
16 call void @llvm.assume(i1 true) ["nonnull"(i32* %arg), "align"(i32* %A, i64 2)]
18 call void @llvm.assume(i1 true) ["align"(i32* %A, i64 8), "nonnull"(i32* %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: [[B:%.*]] = bitcast i32* [[A]] to i8*
26 ; CHECK-NEXT: [[CND:%.*]] = icmp eq i8* [[B]], null
27 ; CHECK-NEXT: call void @llvm.assume(i1 [[CND]])
28 ; CHECK-NEXT: store i32 1, i32* [[A]], align 4
29 ; CHECK-NEXT: ret void
32 %B = bitcast i32* %A to i8*
33 %cnd = icmp eq i8* %B, null
34 call void @llvm.assume(i1 %cnd)
39 define void @positive_multiple_assume_uses() {
40 ; CHECK-LABEL: @positive_multiple_assume_uses(
41 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"({ i8, i16 }* undef, i64 8), "ignore"({ i8, i16 }* undef, i64 16) ]
42 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"({ i8, i16 }* undef), "ignore"({ i8, i16 }* undef, i64 2) ]
43 ; CHECK-NEXT: ret void
46 call void @llvm.assume(i1 true) ["align"({i8, i16}* %A, i64 8), "align"({i8, i16}* %A, i64 16)]
47 store {i8, i16} zeroinitializer, {i8, i16}* %A
48 call void @llvm.assume(i1 true) ["nonnull"({i8, i16}* %A), "align"({i8, i16}* %A, i64 2)]
52 define void @positive_gep_assume_uses() {
53 ; CHECK-LABEL: @positive_gep_assume_uses(
54 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(i8* undef, i64 8), "ignore"(i8* undef, i64 16) ]
55 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(i8* undef), "ignore"(i8* undef, i64 2) ]
56 ; CHECK-NEXT: ret void
59 %B = getelementptr {i8, i16}, {i8, i16}* %A, i32 0, i32 0
60 call void @llvm.lifetime.start.p0i8(i64 2, i8* %B)
61 call void @llvm.assume(i1 true) ["align"(i8* %B, i64 8), "align"(i8* %B, i64 16)]
62 store {i8, i16} zeroinitializer, {i8, i16}* %A
63 call void @llvm.lifetime.end.p0i8(i64 2, i8* %B)
64 call void @llvm.assume(i1 true) ["nonnull"(i8* %B), "align"(i8* %B, i64 2)]
68 define void @positive_mixed_assume_uses() {
69 ; CHECK-LABEL: @positive_mixed_assume_uses(
70 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(i8* undef), "ignore"(i8* undef, i64 8), "ignore"(i8* undef, i64 16) ]
71 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(i8* undef), "ignore"(i8* undef, i64 2), "ignore"(i8* undef) ]
72 ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(i32* undef), "ignore"(i32* undef, i64 2), "ignore"(i8* undef) ]
73 ; CHECK-NEXT: ret void
76 %B = getelementptr i8, i8* %A, i32 0
77 %C = bitcast i8* %A to i32*
78 call void @llvm.lifetime.start.p0i8(i64 2, i8* %B)
79 call void @llvm.assume(i1 true) ["nonnull"(i8* %B), "align"(i8* %A, i64 8), "align"(i8* %B, i64 16)]
81 call void @llvm.lifetime.end.p0i8(i64 2, i8* %B)
82 call void @llvm.assume(i1 true) ["nonnull"(i8* %B), "align"(i8* %A, i64 2), "nonnull"(i8* %A)]
83 call void @llvm.assume(i1 true) ["nonnull"(i32* %C), "align"(i32* %C, i64 2), "nonnull"(i8* %A)]