brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.0 KiB · bb3163a Raw
188 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -S -passes=verify,iroutliner < %s | FileCheck %s3; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s -check-prefix=NOCOST4 5; This test checks that we have different results from when the cost model6; is on versus when it is off.  That is, if the number of instructions needed to7; handle the arguments is greater than the number of instructions being added,8; we do not outline.9 10define void @function1() #0 {11; CHECK-LABEL: @function1(12; CHECK-NEXT:  entry:13; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 414; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 415; CHECK-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]])16; CHECK-NEXT:    ret void17;18; NOCOST-LABEL: @function1(19; NOCOST-NEXT:  entry:20; NOCOST-NEXT:    [[A:%.*]] = alloca i32, align 421; NOCOST-NEXT:    [[B:%.*]] = alloca i32, align 422; NOCOST-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]])23; NOCOST-NEXT:    ret void24;25entry:26  %a = alloca i32, align 427  %b = alloca i32, align 428  %0 = load i32, ptr %a, align 429  %1 = load i32, ptr %b, align 430  %add = add i32 %0, %131  %mul = mul i32 %0, %132  %sub = sub i32 %0, %133  %div = sdiv i32 %0, %134  %add1 = add i32 %0, %135  %mul1 = mul i32 %0, %136  %sub1 = sub i32 %0, %137  %div1 = sdiv i32 %0, %138  %add2 = add i32 %0, %139  %mul2 = mul i32 %0, %140  %sub2 = sub i32 %0, %141  %div2 = sdiv i32 %0, %142  ret void43}44 45define void @function2() #0 {46; CHECK-LABEL: @function2(47; CHECK-NEXT:  entry:48; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 449; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 450; CHECK-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]])51; CHECK-NEXT:    ret void52;53; NOCOST-LABEL: @function2(54; NOCOST-NEXT:  entry:55; NOCOST-NEXT:    [[A:%.*]] = alloca i32, align 456; NOCOST-NEXT:    [[B:%.*]] = alloca i32, align 457; NOCOST-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]])58; NOCOST-NEXT:    ret void59;60entry:61  %a = alloca i32, align 462  %b = alloca i32, align 463  %0 = load i32, ptr %a, align 464  %1 = load i32, ptr %b, align 465  %add = add i32 %0, %166  %mul = mul i32 %0, %167  %sub = sub i32 %0, %168  %div = sdiv i32 %0, %169  %add1 = add i32 %0, %170  %mul1 = mul i32 %0, %171  %sub1 = sub i32 %0, %172  %div1 = sdiv i32 %0, %173  %add2 = add i32 %0, %174  %mul2 = mul i32 %0, %175  %sub2 = sub i32 %0, %176  %div2 = sdiv i32 %0, %177  ret void78}79 80define void @function3() #0 {81; CHECK-LABEL: @function3(82; CHECK-NEXT:  entry:83; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 484; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 485; CHECK-NEXT:    [[OUTPUT:%.*]] = alloca i32, align 486; CHECK-NEXT:    [[RESULT:%.*]] = alloca i32, align 487; CHECK-NEXT:    store i32 2, ptr [[A]], align 488; CHECK-NEXT:    store i32 3, ptr [[B]], align 489; CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr [[A]], align 490; CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[B]], align 491; CHECK-NEXT:    [[ADD:%.*]] = add i32 [[TMP0]], [[TMP1]]92; CHECK-NEXT:    store i32 [[ADD]], ptr [[OUTPUT]], align 493; CHECK-NEXT:    [[TMP2:%.*]] = load i32, ptr [[OUTPUT]], align 494; CHECK-NEXT:    [[TMP3:%.*]] = load i32, ptr [[OUTPUT]], align 495; CHECK-NEXT:    [[MUL:%.*]] = mul i32 [[TMP2]], [[ADD]]96; CHECK-NEXT:    store i32 [[MUL]], ptr [[RESULT]], align 497; CHECK-NEXT:    ret void98;99; NOCOST-LABEL: @function3(100; NOCOST-NEXT:  entry:101; NOCOST-NEXT:    [[DOTLOC:%.*]] = alloca i32, align 4102; NOCOST-NEXT:    [[ADD_LOC:%.*]] = alloca i32, align 4103; NOCOST-NEXT:    [[A:%.*]] = alloca i32, align 4104; NOCOST-NEXT:    [[B:%.*]] = alloca i32, align 4105; NOCOST-NEXT:    [[OUTPUT:%.*]] = alloca i32, align 4106; NOCOST-NEXT:    [[RESULT:%.*]] = alloca i32, align 4107; NOCOST-NEXT:    call void @llvm.lifetime.start.p0(ptr [[ADD_LOC]])108; NOCOST-NEXT:    call void @llvm.lifetime.start.p0(ptr [[DOTLOC]])109; NOCOST-NEXT:    call void @outlined_ir_func_1(ptr [[A]], ptr [[B]], ptr [[OUTPUT]], ptr [[ADD_LOC]], ptr [[DOTLOC]])110; NOCOST-NEXT:    [[ADD_RELOAD:%.*]] = load i32, ptr [[ADD_LOC]], align 4111; NOCOST-NEXT:    [[DOTRELOAD:%.*]] = load i32, ptr [[DOTLOC]], align 4112; NOCOST-NEXT:    call void @llvm.lifetime.end.p0(ptr [[ADD_LOC]])113; NOCOST-NEXT:    call void @llvm.lifetime.end.p0(ptr [[DOTLOC]])114; NOCOST-NEXT:    [[TMP0:%.*]] = load i32, ptr [[OUTPUT]], align 4115; NOCOST-NEXT:    call void @outlined_ir_func_2(i32 [[DOTRELOAD]], i32 [[ADD_RELOAD]], ptr [[RESULT]])116; NOCOST-NEXT:    ret void117;118entry:119  %a = alloca i32, align 4120  %b = alloca i32, align 4121  %output = alloca i32, align 4122  %result = alloca i32, align 4123  store i32 2, ptr %a, align 4124  store i32 3, ptr %b, align 4125  %0 = load i32, ptr %a, align 4126  %1 = load i32, ptr %b, align 4127  %add = add i32 %0, %1128  store i32 %add, ptr %output, align 4129  %2 = load i32, ptr %output, align 4130  %3 = load i32, ptr %output, align 4131  %mul = mul i32 %2, %add132  store i32 %mul, ptr %result, align 4133  ret void134}135 136define void @function4() #0 {137; CHECK-LABEL: @function4(138; CHECK-NEXT:  entry:139; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 4140; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 4141; CHECK-NEXT:    [[OUTPUT:%.*]] = alloca i32, align 4142; CHECK-NEXT:    [[RESULT:%.*]] = alloca i32, align 4143; CHECK-NEXT:    store i32 2, ptr [[A]], align 4144; CHECK-NEXT:    store i32 3, ptr [[B]], align 4145; CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr [[A]], align 4146; CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[B]], align 4147; CHECK-NEXT:    [[ADD:%.*]] = add i32 [[TMP0]], [[TMP1]]148; CHECK-NEXT:    store i32 [[ADD]], ptr [[OUTPUT]], align 4149; CHECK-NEXT:    [[TMP2:%.*]] = load i32, ptr [[OUTPUT]], align 4150; CHECK-NEXT:    [[MUL:%.*]] = mul i32 [[TMP2]], [[ADD]]151; CHECK-NEXT:    store i32 [[MUL]], ptr [[RESULT]], align 4152; CHECK-NEXT:    ret void153;154; NOCOST-LABEL: @function4(155; NOCOST-NEXT:  entry:156; NOCOST-NEXT:    [[DOTLOC:%.*]] = alloca i32, align 4157; NOCOST-NEXT:    [[ADD_LOC:%.*]] = alloca i32, align 4158; NOCOST-NEXT:    [[A:%.*]] = alloca i32, align 4159; NOCOST-NEXT:    [[B:%.*]] = alloca i32, align 4160; NOCOST-NEXT:    [[OUTPUT:%.*]] = alloca i32, align 4161; NOCOST-NEXT:    [[RESULT:%.*]] = alloca i32, align 4162; NOCOST-NEXT:    call void @llvm.lifetime.start.p0(ptr [[ADD_LOC]])163; NOCOST-NEXT:    call void @llvm.lifetime.start.p0(ptr [[DOTLOC]])164; NOCOST-NEXT:    call void @outlined_ir_func_1(ptr [[A]], ptr [[B]], ptr [[OUTPUT]], ptr [[ADD_LOC]], ptr [[DOTLOC]])165; NOCOST-NEXT:    [[ADD_RELOAD:%.*]] = load i32, ptr [[ADD_LOC]], align 4166; NOCOST-NEXT:    [[DOTRELOAD:%.*]] = load i32, ptr [[DOTLOC]], align 4167; NOCOST-NEXT:    call void @llvm.lifetime.end.p0(ptr [[ADD_LOC]])168; NOCOST-NEXT:    call void @llvm.lifetime.end.p0(ptr [[DOTLOC]])169; NOCOST-NEXT:    call void @outlined_ir_func_2(i32 [[DOTRELOAD]], i32 [[ADD_RELOAD]], ptr [[RESULT]])170; NOCOST-NEXT:    ret void171;172entry:173  %a = alloca i32, align 4174  %b = alloca i32, align 4175  %output = alloca i32, align 4176  %result = alloca i32, align 4177  store i32 2, ptr %a, align 4178  store i32 3, ptr %b, align 4179  %0 = load i32, ptr %a, align 4180  %1 = load i32, ptr %b, align 4181  %add = add i32 %0, %1182  store i32 %add, ptr %output, align 4183  %2 = load i32, ptr %output, align 4184  %mul = mul i32 %2, %add185  store i32 %mul, ptr %result, align 4186  ret void187}188