if CostMetrics says to never duplicate some code, don't unswitch a loop.
authorChris Lattner <sabre@nondot.org>
Sun, 1 Nov 2009 03:42:55 +0000 (03:42 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 1 Nov 2009 03:42:55 +0000 (03:42 +0000)
This prevents unswitching from duplicating indbr's.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85705 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopUnswitch.cpp

index 223d2b9869c2750aa1f73145ced354777f78cc89..c7b00da159cee47443c2b61f6676522deb4e5ba6 100644 (file)
@@ -430,7 +430,8 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val){
     // large numbers of branches which cause loop unswitching to go crazy.
     // This is a very ad-hoc heuristic.
     if (Metrics.NumInsts > Threshold ||
-        Metrics.NumBlocks * 5 > Threshold) {
+        Metrics.NumBlocks * 5 > Threshold ||
+        Metrics.NeverInline) {
       DEBUG(errs() << "NOT unswitching loop %"
             << currentLoop->getHeader()->getName() << ", cost too high: "
             << currentLoop->getBlocks().size() << "\n");