From a71b00847764803d6a3f1e9c105d087ff17b9dc1 Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Mon, 30 Nov 2009 18:56:45 +0000 Subject: [PATCH] Reprioritize tests for tail duplication to be aggressive about indirect branches even when optimizing for code size. Unless we find evidence to the contrary in the future, the special treatment for indirect branches does not have a significant effect on code size, and performance still matters with -Os. llvm-svn: 90147 --- lib/CodeGen/TailDuplication.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/TailDuplication.cpp b/lib/CodeGen/TailDuplication.cpp index 68fa2099c81..9c0b596c33f 100644 --- a/lib/CodeGen/TailDuplication.cpp +++ b/lib/CodeGen/TailDuplication.cpp @@ -116,14 +116,14 @@ bool TailDuplicatePass::TailDuplicate(MachineBasicBlock *TailBB, // duplicate only one, because one branch instruction can be eliminated to // compensate for the duplication. unsigned MaxDuplicateCount; - if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize)) - MaxDuplicateCount = 1; - else if (!TailBB->empty() && TailBB->back().getDesc().isIndirectBranch()) + if (!TailBB->empty() && TailBB->back().getDesc().isIndirectBranch()) // If the target has hardware branch prediction that can handle indirect // branches, duplicating them can often make them predictable when there // are common paths through the code. The limit needs to be high enough // to allow undoing the effects of tail merging. MaxDuplicateCount = 20; + else if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize)) + MaxDuplicateCount = 1; else MaxDuplicateCount = TailDuplicateSize;