1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -sroa -S -o - < %s | FileCheck %s 3; RUN: opt -passes=sroa -S -o - < %s | FileCheck %s 4 5declare void @llvm.assume(i1) 6declare void @llvm.lifetime.start.p0i8(i64 %size, i8* nocapture %ptr) 7declare void @llvm.lifetime.end.p0i8(i64 %size, i8* nocapture %ptr) 8 9define 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 14; 15 %A = alloca i32 16 call void @llvm.assume(i1 true) ["nonnull"(i32* %arg), "align"(i32* %A, i64 2)] 17 store i32 1, i32* %A 18 call void @llvm.assume(i1 true) ["align"(i32* %A, i64 8), "nonnull"(i32* %arg)] 19 ret void 20} 21 22define 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 30; 31 %A = alloca i32 32 %B = bitcast i32* %A to i8* 33 %cnd = icmp eq i8* %B, null 34 call void @llvm.assume(i1 %cnd) 35 store i32 1, i32* %A 36 ret void 37} 38 39define 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 44; 45 %A = alloca {i8, i16} 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)] 49 ret void 50} 51 52define 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 57; 58 %A = alloca {i8, i16} 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)] 65 ret void 66} 67 68define 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 74; 75 %A = alloca i8 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)] 80 store i8 1, i8* %A 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)] 84 ret void 85} 86