128 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s3 4; This test makes sure we are extracting the found similarity sections5; correctly at the call site.6 7define void @extract1() {8; CHECK-LABEL: @extract1(9; CHECK-NEXT: entry:10; CHECK-NEXT: [[A:%.*]] = alloca i32, align 411; CHECK-NEXT: [[B:%.*]] = alloca i32, align 412; CHECK-NEXT: [[C:%.*]] = alloca i32, align 413; CHECK-NEXT: call void @outlined_ir_func_1(ptr [[A]], ptr [[B]], ptr [[C]])14; CHECK-NEXT: ret void15;16entry:17 %a = alloca i32, align 418 %b = alloca i32, align 419 %c = alloca i32, align 420 store i32 2, ptr %a, align 421 store i32 3, ptr %b, align 422 store i32 4, ptr %c, align 423 %al = load i32, ptr %a24 %bl = load i32, ptr %b25 %cl = load i32, ptr %c26 ret void27}28 29define void @extract2() {30; CHECK-LABEL: @extract2(31; CHECK-NEXT: entry:32; CHECK-NEXT: [[A:%.*]] = alloca i32, align 433; CHECK-NEXT: [[B:%.*]] = alloca i32, align 434; CHECK-NEXT: [[C:%.*]] = alloca i32, align 435; CHECK-NEXT: call void @outlined_ir_func_1(ptr [[A]], ptr [[B]], ptr [[C]])36; CHECK-NEXT: ret void37;38entry:39 %a = alloca i32, align 440 %b = alloca i32, align 441 %c = alloca i32, align 442 store i32 2, ptr %a, align 443 store i32 3, ptr %b, align 444 store i32 4, ptr %c, align 445 %al = load i32, ptr %a46 %bl = load i32, ptr %b47 %cl = load i32, ptr %c48 ret void49}50 51; There are potential ouptuts in this sections, but we do not extract sections52; with outputs right now, since they cannot be consolidated.53define void @extract_outs1() #0 {54; CHECK-LABEL: @extract_outs1(55; CHECK-NEXT: entry:56; CHECK-NEXT: [[DOTLOC:%.*]] = alloca i32, align 457; CHECK-NEXT: [[ADD_LOC:%.*]] = alloca i32, align 458; CHECK-NEXT: [[A:%.*]] = alloca i32, align 459; CHECK-NEXT: [[B:%.*]] = alloca i32, align 460; CHECK-NEXT: [[OUTPUT:%.*]] = alloca i32, align 461; CHECK-NEXT: [[RESULT:%.*]] = alloca i32, align 462; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[ADD_LOC]])63; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[DOTLOC]])64; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[OUTPUT]], ptr [[ADD_LOC]], ptr [[DOTLOC]])65; CHECK-NEXT: [[ADD_RELOAD:%.*]] = load i32, ptr [[ADD_LOC]], align 466; CHECK-NEXT: [[DOTRELOAD:%.*]] = load i32, ptr [[DOTLOC]], align 467; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr [[ADD_LOC]])68; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr [[DOTLOC]])69; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[OUTPUT]], align 470; CHECK-NEXT: call void @outlined_ir_func_2(i32 [[DOTRELOAD]], i32 [[ADD_RELOAD]], ptr [[RESULT]])71; CHECK-NEXT: ret void72;73entry:74 %a = alloca i32, align 475 %b = alloca i32, align 476 %output = alloca i32, align 477 %result = alloca i32, align 478 store i32 2, ptr %a, align 479 store i32 3, ptr %b, align 480 %0 = load i32, ptr %a, align 481 %1 = load i32, ptr %b, align 482 %add = add i32 %0, %183 store i32 %add, ptr %output, align 484 %2 = load i32, ptr %output, align 485 %3 = load i32, ptr %output, align 486 %mul = mul i32 %2, %add87 store i32 %mul, ptr %result, align 488 ret void89}90 91; There are potential ouptuts in this sections, but we do not extract sections92; with outputs right now, since they cannot be consolidated.93define void @extract_outs2() #0 {94; CHECK-LABEL: @extract_outs2(95; CHECK-NEXT: entry:96; CHECK-NEXT: [[DOTLOC:%.*]] = alloca i32, align 497; CHECK-NEXT: [[ADD_LOC:%.*]] = alloca i32, align 498; CHECK-NEXT: [[A:%.*]] = alloca i32, align 499; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4100; CHECK-NEXT: [[OUTPUT:%.*]] = alloca i32, align 4101; CHECK-NEXT: [[RESULT:%.*]] = alloca i32, align 4102; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[ADD_LOC]])103; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[DOTLOC]])104; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[OUTPUT]], ptr [[ADD_LOC]], ptr [[DOTLOC]])105; CHECK-NEXT: [[ADD_RELOAD:%.*]] = load i32, ptr [[ADD_LOC]], align 4106; CHECK-NEXT: [[DOTRELOAD:%.*]] = load i32, ptr [[DOTLOC]], align 4107; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr [[ADD_LOC]])108; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr [[DOTLOC]])109; CHECK-NEXT: call void @outlined_ir_func_2(i32 [[DOTRELOAD]], i32 [[ADD_RELOAD]], ptr [[RESULT]])110; CHECK-NEXT: ret void111;112entry:113 %a = alloca i32, align 4114 %b = alloca i32, align 4115 %output = alloca i32, align 4116 %result = alloca i32, align 4117 store i32 2, ptr %a, align 4118 store i32 3, ptr %b, align 4119 %0 = load i32, ptr %a, align 4120 %1 = load i32, ptr %b, align 4121 %add = add i32 %0, %1122 store i32 %add, ptr %output, align 4123 %2 = load i32, ptr %output, align 4124 %mul = mul i32 %2, %add125 store i32 %mul, ptr %result, align 4126 ret void127}128