]> granicus.if.org Git - llvm/commit
[PowerPC] Add profitablilty check for conversion to mtctr loops
authorLei Huang <lei@ca.ibm.com>
Thu, 12 Oct 2017 16:43:33 +0000 (16:43 +0000)
committerLei Huang <lei@ca.ibm.com>
Thu, 12 Oct 2017 16:43:33 +0000 (16:43 +0000)
commit818cdb5df7fe6e14a94a9f069d0bb95db8a8a0a5
tree93f66cfa1e3d0815d3f511af807be83a54f4350c
parentfadd83b09ca61a360ed2fa733ea44f0a76ea5419
[PowerPC] Add profitablilty check for conversion to mtctr loops

Add profitability checks for modifying counted loops to use the mtctr instruction.

The latency of mtctr is only justified if there are more than 4 comparisons that
will be removed as a result.  Usually counted loops are formed relatively early
and before unrolling, so most low trip count loops often don't survive.  However
we want to ensure that if they do, we do not mistakenly update them to mtctr loops.

Use CodeMetrics to ensure we are only doing this for small loops with small trip counts.

Differential Revision: https://reviews.llvm.org/D38212

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315592 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPCCTRLoops.cpp
test/CodeGen/PowerPC/ctr-minmaxnum.ll
test/CodeGen/PowerPC/ctrloop-shortLoops.ll [new file with mode: 0644]