[llvm] d3c0ed3 - [NFCI][metadata][LibCallsShrinkWrap] Use create{Unlikely,Likely}BranchWeights (#89465)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 10 13:13:11 PDT 2024


Author: Vitaly Buka
Date: 2024-06-10T13:13:08-07:00
New Revision: d3c0ed387c478dc07daac575b2ec1216b8044b56

URL: https://github.com/llvm/llvm-project/commit/d3c0ed387c478dc07daac575b2ec1216b8044b56
DIFF: https://github.com/llvm/llvm-project/commit/d3c0ed387c478dc07daac575b2ec1216b8044b56.diff

LOG: [NFCI][metadata][LibCallsShrinkWrap] Use create{Unlikely,Likely}BranchWeights (#89465)

It does not look like 2000 is needed here in particular.

Follow up to #89464

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp
    llvm/test/Transforms/Util/libcalls-shrinkwrap-double.ll
    llvm/test/Transforms/Util/libcalls-shrinkwrap-float.ll
    llvm/test/Transforms/Util/libcalls-shrinkwrap-long-double.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp b/llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp
index 6220f85093096..9fe655e548c22 100644
--- a/llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp
+++ b/llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp
@@ -467,7 +467,7 @@ Value *LibCallsShrinkWrap::generateCondForPow(CallInst *CI,
 void LibCallsShrinkWrap::shrinkWrapCI(CallInst *CI, Value *Cond) {
   assert(Cond != nullptr && "ShrinkWrapCI is not expecting an empty call inst");
   MDNode *BranchWeights =
-      MDBuilder(CI->getContext()).createBranchWeights(1, 2000);
+      MDBuilder(CI->getContext()).createUnlikelyBranchWeights();
 
   Instruction *NewInst =
       SplitBlockAndInsertIfThen(Cond, CI, false, BranchWeights, &DTU);

diff  --git a/llvm/test/Transforms/Util/libcalls-shrinkwrap-double.ll b/llvm/test/Transforms/Util/libcalls-shrinkwrap-double.ll
index 1866fc98fc8d8..4ac216f85c74c 100644
--- a/llvm/test/Transforms/Util/libcalls-shrinkwrap-double.ll
+++ b/llvm/test/Transforms/Util/libcalls-shrinkwrap-double.ll
@@ -448,4 +448,4 @@ define void @test_pow_strictfp(i32 %int_val, double %exp) strictfp {
 
 declare double @pow(double, double)
 
-; CHECK: ![[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 2000}
+; CHECK: ![[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 1048575}

diff  --git a/llvm/test/Transforms/Util/libcalls-shrinkwrap-float.ll b/llvm/test/Transforms/Util/libcalls-shrinkwrap-float.ll
index 2a08041e2b1e5..f4dc79759d17e 100644
--- a/llvm/test/Transforms/Util/libcalls-shrinkwrap-float.ll
+++ b/llvm/test/Transforms/Util/libcalls-shrinkwrap-float.ll
@@ -350,4 +350,4 @@ declare float @log2f(float)
 declare float @logbf(float)
 declare float @log1pf(float)
 
-; CHECK: ![[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 2000}
+; CHECK: ![[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 1048575}

diff  --git a/llvm/test/Transforms/Util/libcalls-shrinkwrap-long-double.ll b/llvm/test/Transforms/Util/libcalls-shrinkwrap-long-double.ll
index 076e958086daa..c2b981c81c75d 100644
--- a/llvm/test/Transforms/Util/libcalls-shrinkwrap-long-double.ll
+++ b/llvm/test/Transforms/Util/libcalls-shrinkwrap-long-double.ll
@@ -351,4 +351,4 @@ declare x86_fp80 @log2l(x86_fp80)
 declare x86_fp80 @logbl(x86_fp80)
 declare x86_fp80 @log1pl(x86_fp80)
 
-; CHECK: ![[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 2000}
+; CHECK: ![[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 1048575}


        


More information about the llvm-commits mailing list