101 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; Checks that move-auto-init can move instruction passed unclobbering memory3; instructions.4; RUN: opt < %s -S -passes='move-auto-init' -verify-memoryssa | FileCheck %s5 6target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"7 8define i32 @foo(i32 noundef %0, i32 noundef %1, i32 noundef %2) #0 {9; CHECK-LABEL: @foo(10; CHECK-NEXT: [[TMP4:%.*]] = alloca [100 x i8], align 1611; CHECK-NEXT: [[TMP5:%.*]] = alloca [2 x i8], align 112; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds [100 x i8], ptr [[TMP4]], i64 0, i64 013; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr nonnull [[TMP4]]) #[[ATTR3:[0-9]+]]14; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds [2 x i8], ptr [[TMP5]], i64 0, i64 015; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr nonnull [[TMP5]]) #[[ATTR3]]16; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds [2 x i8], ptr [[TMP5]], i64 0, i64 117; CHECK-NEXT: [[TMP9:%.*]] = icmp eq i32 [[TMP1:%.*]], 018; CHECK-NEXT: br i1 [[TMP9]], label [[TMP15:%.*]], label [[TMP10:%.*]]19; CHECK: 10:20; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(100) [[TMP6]], i8 -86, i64 100, i1 false), !annotation [[META0:![0-9]+]]21; CHECK-NEXT: [[TMP11:%.*]] = sext i32 [[TMP0:%.*]] to i6422; CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds [100 x i8], ptr [[TMP4]], i64 0, i64 [[TMP11]]23; CHECK-NEXT: store i8 12, ptr [[TMP12]], align 124; CHECK-NEXT: [[TMP13:%.*]] = load i8, ptr [[TMP6]], align 1625; CHECK-NEXT: [[TMP14:%.*]] = sext i8 [[TMP13]] to i3226; CHECK-NEXT: br label [[TMP22:%.*]]27; CHECK: 15:28; CHECK-NEXT: [[TMP16:%.*]] = icmp eq i32 [[TMP2:%.*]], 029; CHECK-NEXT: br i1 [[TMP16]], label [[TMP22]], label [[TMP17:%.*]]30; CHECK: 17:31; CHECK-NEXT: store i8 -86, ptr [[TMP7]], align 1, !annotation [[META0]]32; CHECK-NEXT: store i8 -86, ptr [[TMP8]], align 1, !annotation [[META0]]33; CHECK-NEXT: [[TMP18:%.*]] = sext i32 [[TMP0]] to i6434; CHECK-NEXT: [[TMP19:%.*]] = getelementptr inbounds [2 x i8], ptr [[TMP5]], i64 0, i64 [[TMP18]]35; CHECK-NEXT: store i8 12, ptr [[TMP19]], align 136; CHECK-NEXT: [[TMP20:%.*]] = load i8, ptr [[TMP7]], align 137; CHECK-NEXT: [[TMP21:%.*]] = sext i8 [[TMP20]] to i3238; CHECK-NEXT: br label [[TMP22]]39; CHECK: 22:40; CHECK-NEXT: [[TMP23:%.*]] = phi i32 [ [[TMP14]], [[TMP10]] ], [ [[TMP21]], [[TMP17]] ], [ 0, [[TMP15]] ]41; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr nonnull [[TMP5]]) #[[ATTR3]]42; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr nonnull [[TMP4]]) #[[ATTR3]]43; CHECK-NEXT: ret i32 [[TMP23]]44;45 46 %4 = alloca [100 x i8], align 1647 %5 = alloca [2 x i8], align 148 %6 = getelementptr inbounds [100 x i8], ptr %4, i64 0, i64 049 call void @llvm.lifetime.start.p0(ptr nonnull %4) #350 ; This memset must move.51 call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(100) %6, i8 -86, i64 100, i1 false), !annotation !052 %7 = getelementptr inbounds [2 x i8], ptr %5, i64 0, i64 053 call void @llvm.lifetime.start.p0(ptr nonnull %5) #354 ; This store must move.55 store i8 -86, ptr %7, align 1, !annotation !056 %8 = getelementptr inbounds [2 x i8], ptr %5, i64 0, i64 157 ; This store must move.58 store i8 -86, ptr %8, align 1, !annotation !059 %9 = icmp eq i32 %1, 060 br i1 %9, label %15, label %1061 6210:63 %11 = sext i32 %0 to i6464 %12 = getelementptr inbounds [100 x i8], ptr %4, i64 0, i64 %1165 store i8 12, ptr %12, align 166 %13 = load i8, ptr %6, align 1667 %14 = sext i8 %13 to i3268 br label %2269 7015:71 %16 = icmp eq i32 %2, 072 br i1 %16, label %22, label %1773 7417:75 %18 = sext i32 %0 to i6476 %19 = getelementptr inbounds [2 x i8], ptr %5, i64 0, i64 %1877 store i8 12, ptr %19, align 178 %20 = load i8, ptr %7, align 179 %21 = sext i8 %20 to i3280 br label %2281 8222:83 %23 = phi i32 [ %14, %10 ], [ %21, %17 ], [ 0, %15 ]84 call void @llvm.lifetime.end.p0(ptr nonnull %5) #385 call void @llvm.lifetime.end.p0(ptr nonnull %4) #386 ret i32 %2387}88 89declare void @llvm.lifetime.start.p0(ptr nocapture) #190 91declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #292 93declare void @llvm.lifetime.end.p0(ptr nocapture) #194 95attributes #0 = { mustprogress nofree nosync nounwind readnone uwtable willreturn }96attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn }97attributes #2 = { argmemonly mustprogress nofree nounwind willreturn writeonly }98attributes #3 = { nounwind }99 100!0 = !{!"auto-init"}101