[llvm] [NFC] Prefer compile-time branching in function template (PR #203698)

Shanzhi Chen via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 13 04:12:36 PDT 2026


https://github.com/chenshanzhi created https://github.com/llvm/llvm-project/pull/203698

None

>From 11b1ab81319c50809512c3f730b637ecb13431a5 Mon Sep 17 00:00:00 2001
From: Shanzhi Chen <chenshanzhi at huawei.com>
Date: Fri, 12 Jun 2026 20:12:57 +0800
Subject: [PATCH] [NFC] Prefer compile-time branching in function template

---
 llvm/include/llvm/Analysis/ProfileSummaryInfo.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
index 02c412729081a..96af93dfc9cf4 100644
--- a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
+++ b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
@@ -309,7 +309,7 @@ class ProfileSummaryInfo {
   bool isHotOrColdBlockNthPercentile(int PercentileCutoff, const BBType *BB,
                                      BFIT *BFI) const {
     auto Count = BFI->getBlockProfileCount(BB);
-    if (isHot)
+    if constexpr (isHot)
       return Count && isHotCountNthPercentile(PercentileCutoff, *Count);
     else
       return Count && isColdCountNthPercentile(PercentileCutoff, *Count);
@@ -320,7 +320,7 @@ class ProfileSummaryInfo {
                                      BlockFrequency BlockFreq,
                                      BFIT *BFI) const {
     auto Count = BFI->getProfileCountFromFreq(BlockFreq);
-    if (isHot)
+    if constexpr (isHot)
       return Count && isHotCountNthPercentile(PercentileCutoff, *Count);
     else
       return Count && isColdCountNthPercentile(PercentileCutoff, *Count);



More information about the llvm-commits mailing list