aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
diff options
context:
space:
mode:
authorSerguei Katkov <serguei.katkov@azul.com>2019-07-22 05:15:34 +0000
committerSerguei Katkov <serguei.katkov@azul.com>2019-07-22 05:15:34 +0000
commitc6c31da86773c0a4c25386ee3a3c75c4b028269c (patch)
tree2bf229a7cc810244335a37e6e277bd7e323d870d /llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
parent6ef23e65818881c5d52a712835dcc9b12e24d689 (diff)
downloadllvm-c6c31da86773c0a4c25386ee3a3c75c4b028269c.zip
llvm-c6c31da86773c0a4c25386ee3a3c75c4b028269c.tar.gz
llvm-c6c31da86773c0a4c25386ee3a3c75c4b028269c.tar.bz2
[Loop Peeling] Fix the handling of branch weights of peeled off branches.
Current algorithm to update branch weights of latch block and its copies is based on the assumption that number of peeling iterations is approximately equal to trip count. However it is not correct. According to profitability check in one case we can decide to peel in case it helps to reduce the number of phi nodes. In this case the number of peeled iteration can be less then estimated trip count. This patch introduces another way to set the branch weights to peeled of branches. Let F is a weight of the edge from latch to header. Let E is a weight of the edge from latch to exit. F/(F+E) is a probability to go to loop and E/(F+E) is a probability to go to exit. Then, Estimated TripCount = F / E. For I-th (counting from 0) peeled off iteration we set the the weights for the peeled latch as (TC - I, 1). It gives us reasonable distribution, The probability to go to exit 1/(TC-I) increases. At the same time the estimated trip count of remaining loop reduces by I. As a result after peeling off N iteration the weights will be (F - N * E, E) and trip count of loop becomes F / E - N or TC - N. The idea is taken from the review of the patch D63918 proposed by Philip. Reviewers: reames, mkuper, iajbar, fhahn Reviewed By: reames Subscribers: hiraditya, zzheng, llvm-commits Differential Revision: https://reviews.llvm.org/D64235 llvm-svn: 366665
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp')
0 files changed, 0 insertions, 0 deletions