95 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -S -passes=iroutliner -ir-outlining-no-cost < %s | FileCheck %s3 4; These functions are constructed slightly differently so that they require5; the same output blocks for the values used outside of the region. We are6; checking that two output blocks are created with the same store instructions.7 8define void @outline_outputs1() #0 {9; CHECK-LABEL: @outline_outputs1(10; CHECK-NEXT: entry:11; CHECK-NEXT: [[DOTLOC:%.*]] = alloca i32, align 412; CHECK-NEXT: [[ADD_LOC:%.*]] = alloca i32, align 413; CHECK-NEXT: [[A:%.*]] = alloca i32, align 414; CHECK-NEXT: [[B:%.*]] = alloca i32, align 415; CHECK-NEXT: [[OUTPUT:%.*]] = alloca i32, align 416; CHECK-NEXT: [[RESULT:%.*]] = alloca i32, align 417; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[ADD_LOC]])18; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[DOTLOC]])19; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[OUTPUT]], ptr [[ADD_LOC]], ptr [[DOTLOC]])20; CHECK-NEXT: [[ADD_RELOAD:%.*]] = load i32, ptr [[ADD_LOC]], align 421; CHECK-NEXT: [[DOTRELOAD:%.*]] = load i32, ptr [[DOTLOC]], align 422; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr [[ADD_LOC]])23; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr [[DOTLOC]])24; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[OUTPUT]], align 425; CHECK-NEXT: call void @outlined_ir_func_1(i32 [[DOTRELOAD]], i32 [[ADD_RELOAD]], ptr [[RESULT]])26; CHECK-NEXT: ret void27;28entry:29 %a = alloca i32, align 430 %b = alloca i32, align 431 %output = alloca i32, align 432 %result = alloca i32, align 433 store i32 2, ptr %a, align 434 store i32 3, ptr %b, align 435 %0 = load i32, ptr %a, align 436 %1 = load i32, ptr %b, align 437 %add = add i32 %0, %138 store i32 %add, ptr %output, align 439 %2 = load i32, ptr %output, align 440 %3 = load i32, ptr %output, align 441 %mul = mul i32 %2, %add42 store i32 %mul, ptr %result, align 443 ret void44}45 46define void @outline_outputs2() #0 {47; CHECK-LABEL: @outline_outputs2(48; CHECK-NEXT: entry:49; CHECK-NEXT: [[DOTLOC:%.*]] = alloca i32, align 450; CHECK-NEXT: [[ADD_LOC:%.*]] = alloca i32, align 451; CHECK-NEXT: [[A:%.*]] = alloca i32, align 452; CHECK-NEXT: [[B:%.*]] = alloca i32, align 453; CHECK-NEXT: [[OUTPUT:%.*]] = alloca i32, align 454; CHECK-NEXT: [[RESULT:%.*]] = alloca i32, align 455; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[ADD_LOC]])56; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[DOTLOC]])57; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[OUTPUT]], ptr [[ADD_LOC]], ptr [[DOTLOC]])58; CHECK-NEXT: [[ADD_RELOAD:%.*]] = load i32, ptr [[ADD_LOC]], align 459; CHECK-NEXT: [[DOTRELOAD:%.*]] = load i32, ptr [[DOTLOC]], align 460; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr [[ADD_LOC]])61; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr [[DOTLOC]])62; CHECK-NEXT: call void @outlined_ir_func_1(i32 [[DOTRELOAD]], i32 [[ADD_RELOAD]], ptr [[RESULT]])63; CHECK-NEXT: ret void64;65entry:66 %a = alloca i32, align 467 %b = alloca i32, align 468 %output = alloca i32, align 469 %result = alloca i32, align 470 store i32 2, ptr %a, align 471 store i32 3, ptr %b, align 472 %0 = load i32, ptr %a, align 473 %1 = load i32, ptr %b, align 474 %add = add i32 %0, %175 store i32 %add, ptr %output, align 476 %2 = load i32, ptr %output, align 477 %mul = mul i32 %2, %add78 store i32 %mul, ptr %result, align 479 ret void80}81 82; CHECK: define internal void @outlined_ir_func_0(ptr [[ARG0:%.*]], ptr [[ARG1:%.*]], ptr [[ARG2:%.*]], ptr [[ARG3:%.*]], ptr [[ARG4:%.*]]) #1 {83; CHECK: entry_to_outline:84; CHECK-NEXT: store i32 2, ptr [[ARG0]], align 485; CHECK-NEXT: store i32 3, ptr [[ARG1]], align 486; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARG0]], align 487; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARG1]], align 488; CHECK-NEXT: [[ADD:%.*]] = add i32 [[TMP0]], [[TMP1]]89; CHECK-NEXT: store i32 [[ADD]], ptr [[ARG2]], align 490; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[ARG2]], align 491 92; CHECK: entry_after_outline.exitStub:93; CHECK-NEXT: store i32 [[ADD]], ptr [[ARG3]], align 494; CHECK-NEXT: store i32 [[TMP2]], ptr [[ARG4]], align 495