[llvm] 5c95162 - [IROutliner] Refactoring errors in the cost model from past patches.

Andrew Litteken via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 3 22:12:55 PST 2021


Author: Andrew Litteken
Date: 2021-01-04T00:11:18-06:00
New Revision: 5c951623bc8965fa1e89660f2f5f4a2944e4981a

URL: https://github.com/llvm/llvm-project/commit/5c951623bc8965fa1e89660f2f5f4a2944e4981a
DIFF: https://github.com/llvm/llvm-project/commit/5c951623bc8965fa1e89660f2f5f4a2944e4981a.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/IROutliner.cpp
    llvm/test/Transforms/IROutliner/opt-remarks.ll
    llvm/test/Transforms/IROutliner/outlining-cost-model.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp
index 3acde6b6ece0..0e5e1dd0886e 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 2a26e5b08784..7172908a84a8 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: <unknown>:0:0: outlined 2 regions with decrease of 2 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
-; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 6 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
-; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 7 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
-; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 8 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
-; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 9 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
+; CHECK: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 12 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
+; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 5 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
+; CHECK-NEXT: remark: <unknown>:0:0: outlined 2 regions with decrease of 2 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
 ; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 10 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
-; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 7 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
-; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 8 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
+; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 11 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
+; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 12 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
 ; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 13 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
+; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 14 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
 ; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 10 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
+; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 11 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
+; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 17 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
+; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 13 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
 
-; 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:        '<UNKNOWN LOCATION>'
+; YAML-NEXT:   - String:          ' '
+; YAML-NEXT:   - DebugLoc:        '<UNKNOWN LOCATION>'
+; 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:        '<UNKNOWN LOCATION>'
+; YAML-NEXT:   - String:          ' '
+; YAML-NEXT:   - DebugLoc:        '<UNKNOWN LOCATION>'
+; 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:        '<UNKNOWN LOCATION>'
 ; 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:        '<UNKNOWN LOCATION>'
 ; 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:        '<UNKNOWN LOCATION>'
 ; 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:        '<UNKNOWN LOCATION>'
 ; 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:        '<UNKNOWN LOCATION>'
 ; 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:        '<UNKNOWN LOCATION>'
 ; 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:        '<UNKNOWN LOCATION>'
 ; 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:        '<UNKNOWN LOCATION>'
 ; 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:        '<UNKNOWN LOCATION>'
 ; 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 3d47c2e7f0b1..c616d52e8646 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


        


More information about the llvm-commits mailing list