From 5c951623bc8965fa1e89660f2f5f4a2944e4981a Mon Sep 17 00:00:00 2001 From: Andrew Litteken Date: Sun, 3 Jan 2021 23:44:20 -0600 Subject: [PATCH] [IROutliner] Refactoring errors in the cost model from past patches. There were was the reuse of a variable that should not have been occurred due to confusion during committing patches. --- llvm/lib/Transforms/IPO/IROutliner.cpp | 4 +- llvm/test/Transforms/IROutliner/opt-remarks.ll | 74 +++++++++++++++++----- .../Transforms/IROutliner/outlining-cost-model.ll | 8 +++ 3 files changed, 67 insertions(+), 19 deletions(-) diff --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp index 3acde6b6..0e5e1dd 100644 --- a/llvm/lib/Transforms/IPO/IROutliner.cpp +++ b/llvm/lib/Transforms/IPO/IROutliner.cpp @@ -1405,7 +1405,7 @@ void IROutliner::findCostBenefit(Module &M, OutlinableGroup &CurrentGroup) { << " instructions to cost for each argument in the new" << " function.\n"); CurrentGroup.Cost += - NumRegions * OverallArgumentNum * TargetTransformInfo::TCC_Basic; + OverallArgumentNum * TargetTransformInfo::TCC_Basic; LLVM_DEBUG(dbgs() << "Current Cost: " << CurrentGroup.Cost << "\n"); // Each argument needs to either be loaded into a register or onto the stack. @@ -1416,7 +1416,7 @@ void IROutliner::findCostBenefit(Module &M, OutlinableGroup &CurrentGroup) { << " function " << NumRegions << " times for the " << "needed argument handling at the call site.\n"); CurrentGroup.Cost += - OverallArgumentNum * TargetTransformInfo::TCC_Basic * NumRegions; + 2 * OverallArgumentNum * TargetTransformInfo::TCC_Basic * NumRegions; LLVM_DEBUG(dbgs() << "Current Cost: " << CurrentGroup.Cost << "\n"); CurrentGroup.Cost += findCostForOutputBlocks(M, CurrentGroup, TTI); diff --git a/llvm/test/Transforms/IROutliner/opt-remarks.ll b/llvm/test/Transforms/IROutliner/opt-remarks.ll index 2a26e5b..7172908 100644 --- a/llvm/test/Transforms/IROutliner/opt-remarks.ll +++ b/llvm/test/Transforms/IROutliner/opt-remarks.ll @@ -5,18 +5,48 @@ ; RUN: -pass-remarks-output=%t < %s ; RUN: cat %t | FileCheck -check-prefix=YAML %s -; CHECK: remark: :0:0: outlined 2 regions with decrease of 2 instructions at locations -; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 6 instructions at locations -; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 7 instructions at locations -; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 8 instructions at locations -; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 9 instructions at locations +; CHECK: remark: :0:0: did not outline 2 regions due to estimated increase of 12 instructions at locations +; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 5 instructions at locations +; CHECK-NEXT: remark: :0:0: outlined 2 regions with decrease of 2 instructions at locations ; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 10 instructions at locations -; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 7 instructions at locations -; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 8 instructions at locations +; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 11 instructions at locations +; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 12 instructions at locations ; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 13 instructions at locations +; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 14 instructions at locations ; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 10 instructions at locations +; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 11 instructions at locations +; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 17 instructions at locations +; CHECK-NEXT: remark: :0:0: did not outline 2 regions due to estimated increase of 13 instructions at locations -; YAML: --- !Passed +; YAML: --- !Missed +; YAML-NEXT: Pass: iroutliner +; YAML-NEXT: Name: WouldNotDecreaseSize +; YAML-NEXT: Function: function3 +; YAML-NEXT: Args: +; YAML-NEXT: - String: 'did not outline ' +; YAML-NEXT: - String: '2' +; YAML-NEXT: - String: ' regions due to estimated increase of ' +; YAML-NEXT: - InstructionIncrease: '12' +; YAML-NEXT: - String: ' instructions at locations ' +; YAML-NEXT: - DebugLoc: '' +; YAML-NEXT: - String: ' ' +; YAML-NEXT: - DebugLoc: '' +; YAML-NEXT: ... +; YAML-NEXT: --- !Missed +; YAML-NEXT: Pass: iroutliner +; YAML-NEXT: Name: WouldNotDecreaseSize +; YAML-NEXT: Function: function3 +; YAML-NEXT: Args: +; YAML-NEXT: - String: 'did not outline ' +; YAML-NEXT: - String: '2' +; YAML-NEXT: - String: ' regions due to estimated increase of ' +; YAML-NEXT: - InstructionIncrease: '5' +; YAML-NEXT: - String: ' instructions at locations ' +; YAML-NEXT: - DebugLoc: '' +; YAML-NEXT: - String: ' ' +; YAML-NEXT: - DebugLoc: '' +; YAML-NEXT: ... +; YAML-NEXT: --- !Passed ; YAML-NEXT: Pass: iroutliner ; YAML-NEXT: Name: Outlined ; YAML-NEXT: Function: function3.outlined @@ -38,7 +68,7 @@ ; YAML-NEXT: - String: 'did not outline ' ; YAML-NEXT: - String: '2' ; YAML-NEXT: - String: ' regions due to estimated increase of ' -; YAML-NEXT: - InstructionIncrease: '6' +; YAML-NEXT: - InstructionIncrease: '10' ; YAML-NEXT: - String: ' instructions at locations ' ; YAML-NEXT: - DebugLoc: '' ; YAML-NEXT: - String: ' ' @@ -52,7 +82,7 @@ ; YAML-NEXT: - String: 'did not outline ' ; YAML-NEXT: - String: '2' ; YAML-NEXT: - String: ' regions due to estimated increase of ' -; YAML-NEXT: - InstructionIncrease: '7' +; YAML-NEXT: - InstructionIncrease: '11' ; YAML-NEXT: - String: ' instructions at locations ' ; YAML-NEXT: - DebugLoc: '' ; YAML-NEXT: - String: ' ' @@ -66,7 +96,7 @@ ; YAML-NEXT: - String: 'did not outline ' ; YAML-NEXT: - String: '2' ; YAML-NEXT: - String: ' regions due to estimated increase of ' -; YAML-NEXT: - InstructionIncrease: '8' +; YAML-NEXT: - InstructionIncrease: '12' ; YAML-NEXT: - String: ' instructions at locations ' ; YAML-NEXT: - DebugLoc: '' ; YAML-NEXT: - String: ' ' @@ -80,7 +110,7 @@ ; YAML-NEXT: - String: 'did not outline ' ; YAML-NEXT: - String: '2' ; YAML-NEXT: - String: ' regions due to estimated increase of ' -; YAML-NEXT: - InstructionIncrease: '9' +; YAML-NEXT: - InstructionIncrease: '13' ; YAML-NEXT: - String: ' instructions at locations ' ; YAML-NEXT: - DebugLoc: '' ; YAML-NEXT: - String: ' ' @@ -94,7 +124,7 @@ ; YAML-NEXT: - String: 'did not outline ' ; YAML-NEXT: - String: '2' ; YAML-NEXT: - String: ' regions due to estimated increase of ' -; YAML-NEXT: - InstructionIncrease: '10' +; YAML-NEXT: - InstructionIncrease: '14' ; YAML-NEXT: - String: ' instructions at locations ' ; YAML-NEXT: - DebugLoc: '' ; YAML-NEXT: - String: ' ' @@ -108,7 +138,7 @@ ; YAML-NEXT: - String: 'did not outline ' ; YAML-NEXT: - String: '2' ; YAML-NEXT: - String: ' regions due to estimated increase of ' -; YAML-NEXT: - InstructionIncrease: '7' +; YAML-NEXT: - InstructionIncrease: '10' ; YAML-NEXT: - String: ' instructions at locations ' ; YAML-NEXT: - DebugLoc: '' ; YAML-NEXT: - String: ' ' @@ -122,7 +152,7 @@ ; YAML-NEXT: - String: 'did not outline ' ; YAML-NEXT: - String: '2' ; YAML-NEXT: - String: ' regions due to estimated increase of ' -; YAML-NEXT: - InstructionIncrease: '8' +; YAML-NEXT: - InstructionIncrease: '11' ; YAML-NEXT: - String: ' instructions at locations ' ; YAML-NEXT: - DebugLoc: '' ; YAML-NEXT: - String: ' ' @@ -136,7 +166,7 @@ ; YAML-NEXT: - String: 'did not outline ' ; YAML-NEXT: - String: '2' ; YAML-NEXT: - String: ' regions due to estimated increase of ' -; YAML-NEXT: - InstructionIncrease: '13' +; YAML-NEXT: - InstructionIncrease: '17' ; YAML-NEXT: - String: ' instructions at locations ' ; YAML-NEXT: - DebugLoc: '' ; YAML-NEXT: - String: ' ' @@ -150,7 +180,7 @@ ; YAML-NEXT: - String: 'did not outline ' ; YAML-NEXT: - String: '2' ; YAML-NEXT: - String: ' regions due to estimated increase of ' -; YAML-NEXT: - InstructionIncrease: '10' +; YAML-NEXT: - InstructionIncrease: '13' ; YAML-NEXT: - String: ' instructions at locations ' ; YAML-NEXT: - DebugLoc: '' ; YAML-NEXT: - String: ' ' @@ -205,10 +235,15 @@ entry: %mul = mul i32 %0, %1 %sub = sub i32 %0, %1 %div = sdiv i32 %0, %1 + %add1 = add i32 %0, %1 + %mul1 = mul i32 %0, %1 + %sub1 = sub i32 %0, %1 + %div1 = sdiv i32 %0, %1 %add2 = add i32 %0, %1 %mul2 = mul i32 %0, %1 %sub2 = sub i32 %0, %1 %div2 = sdiv i32 %0, %1 + %mul3 = mul i32 %0, %1 ret void } @@ -222,9 +257,14 @@ entry: %mul = mul i32 %0, %1 %sub = sub i32 %0, %1 %div = sdiv i32 %0, %1 + %add1 = add i32 %0, %1 + %mul1 = mul i32 %0, %1 + %sub1 = sub i32 %0, %1 + %div1 = sdiv i32 %0, %1 %add2 = add i32 %0, %1 %mul2 = mul i32 %0, %1 %sub2 = sub i32 %0, %1 %div2 = sdiv i32 %0, %1 + %div3 = sdiv i32 %0, %1 ret void } diff --git a/llvm/test/Transforms/IROutliner/outlining-cost-model.ll b/llvm/test/Transforms/IROutliner/outlining-cost-model.ll index 3d47c2e..c616d52 100644 --- a/llvm/test/Transforms/IROutliner/outlining-cost-model.ll +++ b/llvm/test/Transforms/IROutliner/outlining-cost-model.ll @@ -31,6 +31,10 @@ entry: %mul = mul i32 %0, %1 %sub = sub i32 %0, %1 %div = sdiv i32 %0, %1 + %add1 = add i32 %0, %1 + %mul1 = mul i32 %0, %1 + %sub1 = sub i32 %0, %1 + %div1 = sdiv i32 %0, %1 %add2 = add i32 %0, %1 %mul2 = mul i32 %0, %1 %sub2 = sub i32 %0, %1 @@ -62,6 +66,10 @@ entry: %mul = mul i32 %0, %1 %sub = sub i32 %0, %1 %div = sdiv i32 %0, %1 + %add1 = add i32 %0, %1 + %mul1 = mul i32 %0, %1 + %sub1 = sub i32 %0, %1 + %div1 = sdiv i32 %0, %1 %add2 = add i32 %0, %1 %mul2 = mul i32 %0, %1 %sub2 = sub i32 %0, %1 -- 2.7.4