From 1f917f69ff07f09b6dbb670971f57f8efe718b84 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Thu, 14 Jul 2022 20:50:02 +0200 Subject: Vendor import of llvm-project main llvmorg-15-init-16436-g18a6ab5b8d1f. --- llvm/lib/Analysis/BranchProbabilityInfo.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'llvm/lib/Analysis/BranchProbabilityInfo.cpp') diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp index 1d880424e55c..428ae8975c30 100644 --- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp +++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp @@ -15,6 +15,7 @@ #include "llvm/ADT/SCCIterator.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/PostDominators.h" #include "llvm/Analysis/TargetLibraryInfo.h" @@ -629,9 +630,10 @@ computeUnlikelySuccessors(const BasicBlock *BB, Loop *L, if (!CmpLHSConst || !llvm::is_contained(successors(BB), B)) continue; // First collapse InstChain + const DataLayout &DL = BB->getModule()->getDataLayout(); for (Instruction *I : llvm::reverse(InstChain)) { - CmpLHSConst = ConstantExpr::get(I->getOpcode(), CmpLHSConst, - cast(I->getOperand(1)), true); + CmpLHSConst = ConstantFoldBinaryOpOperands( + I->getOpcode(), CmpLHSConst, cast(I->getOperand(1)), DL); if (!CmpLHSConst) break; } @@ -826,9 +828,8 @@ void BranchProbabilityInfo::computeEestimateBlockWeight( if (auto BBWeight = getInitialEstimatedBlockWeight(BB)) // If we were able to find estimated weight for the block set it to this // block and propagate up the IR. - propagateEstimatedBlockWeight(getLoopBlock(BB), DT, PDT, - BBWeight.getValue(), BlockWorkList, - LoopWorkList); + propagateEstimatedBlockWeight(getLoopBlock(BB), DT, PDT, BBWeight.value(), + BlockWorkList, LoopWorkList); // BlockWorklist/LoopWorkList contains blocks/loops with at least one // successor/exit having estimated weight. Try to propagate weight to such -- cgit v1.3