[llvm] r184835 - BlockFrequency: Bump up the entry frequency a bit.
Benjamin Kramer
benny.kra at googlemail.com
Tue Jun 25 06:34:40 PDT 2013
Author: d0k
Date: Tue Jun 25 08:34:40 2013
New Revision: 184835
URL: http://llvm.org/viewvc/llvm-project?rev=184835&view=rev
Log:
BlockFrequency: Bump up the entry frequency a bit.
This is a band-aid to fix the most severe regressions we're seeing from basing
spill decisions on block frequencies, until we have a better solution.
Modified:
llvm/trunk/include/llvm/Analysis/BlockFrequencyImpl.h
llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h
llvm/trunk/include/llvm/Support/BlockFrequency.h
llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp
llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp
llvm/trunk/test/Analysis/BlockFrequencyInfo/basic.ll
Modified: llvm/trunk/include/llvm/Analysis/BlockFrequencyImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BlockFrequencyImpl.h?rev=184835&r1=184834&r2=184835&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/BlockFrequencyImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/BlockFrequencyImpl.h Tue Jun 25 08:34:40 2013
@@ -33,7 +33,7 @@ class BlockFrequencyInfo;
class MachineBlockFrequencyInfo;
/// BlockFrequencyImpl implements block frequency algorithm for IR and
-/// Machine Instructions. Algorithm starts with value 1024 (START_FREQ)
+/// Machine Instructions. Algorithm starts with value ENTRY_FREQ
/// for the entry block and then propagates frequencies using branch weights
/// from (Machine)BranchProbabilityInfo. LoopInfo is not required because
/// algorithm can find "backedges" by itself.
Modified: llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h?rev=184835&r1=184834&r2=184835&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h Tue Jun 25 08:34:40 2013
@@ -43,10 +43,10 @@ public:
void print(raw_ostream &O, const Module *M) const;
/// getblockFreq - Return block frequency. Return 0 if we don't have the
- /// information. Please note that initial frequency is equal to 1024. It means
- /// that we should not rely on the value itself, but only on the comparison to
- /// the other block frequencies. We do this to avoid using of floating points.
- ///
+ /// information. Please note that initial frequency is equal to ENTRY_FREQ. It
+ /// means that we should not rely on the value itself, but only on the
+ /// comparison to the other block frequencies. We do this to avoid using of
+ /// floating points.
BlockFrequency getBlockFreq(const BasicBlock *BB) const;
};
Modified: llvm/trunk/include/llvm/Support/BlockFrequency.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/BlockFrequency.h?rev=184835&r1=184834&r2=184835&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/BlockFrequency.h (original)
+++ llvm/trunk/include/llvm/Support/BlockFrequency.h Tue Jun 25 08:34:40 2013
@@ -25,7 +25,7 @@ class BranchProbability;
class BlockFrequency {
uint64_t Frequency;
- static const int64_t ENTRY_FREQ = 1024;
+ static const int64_t ENTRY_FREQ = 1 << 14;
public:
BlockFrequency(uint64_t Freq = 0) : Frequency(Freq) { }
Modified: llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp?rev=184835&r1=184834&r2=184835&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp Tue Jun 25 08:34:40 2013
@@ -53,11 +53,6 @@ void BlockFrequencyInfo::print(raw_ostre
if (BFI) BFI->print(O);
}
-/// getblockFreq - Return block frequency. Return 0 if we don't have the
-/// information. Please note that initial frequency is equal to 1024. It means
-/// that we should not rely on the value itself, but only on the comparison to
-/// the other block frequencies. We do this to avoid using of floating points.
-///
BlockFrequency BlockFrequencyInfo::getBlockFreq(const BasicBlock *BB) const {
return BFI->getBlockFreq(BB);
}
Modified: llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp?rev=184835&r1=184834&r2=184835&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp Tue Jun 25 08:34:40 2013
@@ -50,11 +50,6 @@ bool MachineBlockFrequencyInfo::runOnMac
return false;
}
-/// getblockFreq - Return block frequency. Return 0 if we don't have the
-/// information. Please note that initial frequency is equal to 1024. It means
-/// that we should not rely on the value itself, but only on the comparison to
-/// the other block frequencies. We do this to avoid using of floating points.
-///
BlockFrequency MachineBlockFrequencyInfo::
getBlockFreq(const MachineBasicBlock *MBB) const {
return MBFI->getBlockFreq(MBB);
Modified: llvm/trunk/test/Analysis/BlockFrequencyInfo/basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BlockFrequencyInfo/basic.ll?rev=184835&r1=184834&r2=184835&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/BlockFrequencyInfo/basic.ll (original)
+++ llvm/trunk/test/Analysis/BlockFrequencyInfo/basic.ll Tue Jun 25 08:34:40 2013
@@ -2,12 +2,12 @@
define i32 @test1(i32 %i, i32* %a) {
; CHECK: Printing analysis {{.*}} for function 'test1'
-; CHECK: entry = 1024
+; CHECK: entry = 16384
entry:
br label %body
; Loop backedges are weighted and thus their bodies have a greater frequency.
-; CHECK: body = 31744
+; CHECK: body = 524288
body:
%iv = phi i32 [ 0, %entry ], [ %next, %body ]
%base = phi i32 [ 0, %entry ], [ %sum, %body ]
@@ -18,29 +18,29 @@ body:
%exitcond = icmp eq i32 %next, %i
br i1 %exitcond, label %exit, label %body
-; CHECK: exit = 1024
+; CHECK: exit = 16384
exit:
ret i32 %sum
}
define i32 @test2(i32 %i, i32 %a, i32 %b) {
; CHECK: Printing analysis {{.*}} for function 'test2'
-; CHECK: entry = 1024
+; CHECK: entry = 16384
entry:
%cond = icmp ult i32 %i, 42
br i1 %cond, label %then, label %else, !prof !0
; The 'then' branch is predicted more likely via branch weight metadata.
-; CHECK: then = 963
+; CHECK: then = 15420
then:
br label %exit
-; CHECK: else = 60
+; CHECK: else = 963
else:
br label %exit
-; FIXME: It may be a bug that we don't sum back to 1024.
-; CHECK: exit = 1023
+; FIXME: It may be a bug that we don't sum back to 16384.
+; CHECK: exit = 16383
exit:
%result = phi i32 [ %a, %then ], [ %b, %else ]
ret i32 %result
@@ -50,36 +50,36 @@ exit:
define i32 @test3(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
; CHECK: Printing analysis {{.*}} for function 'test3'
-; CHECK: entry = 1024
+; CHECK: entry = 16384
entry:
switch i32 %i, label %case_a [ i32 1, label %case_b
i32 2, label %case_c
i32 3, label %case_d
i32 4, label %case_e ], !prof !1
-; CHECK: case_a = 51
+; CHECK: case_a = 819
case_a:
br label %exit
-; CHECK: case_b = 51
+; CHECK: case_b = 819
case_b:
br label %exit
; The 'case_c' branch is predicted more likely via branch weight metadata.
-; CHECK: case_c = 819
+; CHECK: case_c = 13107
case_c:
br label %exit
-; CHECK: case_d = 51
+; CHECK: case_d = 819
case_d:
br label %exit
-; CHECK: case_e = 51
+; CHECK: case_e = 819
case_e:
br label %exit
-; FIXME: It may be a bug that we don't sum back to 1024.
-; CHECK: exit = 1023
+; FIXME: It may be a bug that we don't sum back to 16384.
+; CHECK: exit = 16383
exit:
%result = phi i32 [ %a, %case_a ],
[ %b, %case_b ],
More information about the llvm-commits
mailing list