From 7a8db3a41a5c3c94ddd3f8cc7be0f464463e46de Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 1 Nov 2009 03:42:55 +0000 Subject: [PATCH] if CostMetrics says to never duplicate some code, don't unswitch a loop. This prevents unswitching from duplicating indbr's. llvm-svn: 85705 --- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp index 223d2b9869c2..c7b00da159ce 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -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");