[llvm] [SimplifyCFG] Increase budget for FoldTwoEntryPHINode() if the branch is unpredictable. (PR #98495)

Wei Xiao via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 14 19:05:47 PDT 2024


================
@@ -3549,8 +3550,10 @@ static bool FoldTwoEntryPHINode(PHINode *PN, const TargetTransformInfo &TTI,
   // that need to be moved to the dominating block.
   SmallPtrSet<Instruction *, 4> AggressiveInsts;
   InstructionCost Cost = 0;
-  InstructionCost Budget =
-      TwoEntryPHINodeFoldingThreshold * TargetTransformInfo::TCC_Basic;
+  unsigned Threshold = TwoEntryPHINodeFoldingThreshold;
+  if (IsUnpredictable)
+    Threshold += TTI.getBranchMispredictPenalty();
----------------
williamweixiao wrote:

add "LLVM_DEBUG(dbgs() << ..." for debugging?

https://github.com/llvm/llvm-project/pull/98495


More information about the llvm-commits mailing list