[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / llvm / lib / CodeGen / MachineSizeOpts.cpp
blob53bed7397d0992e1e30194717b12ce7a016e5520
1 //===- MachineSizeOpts.cpp - code size optimization related code ----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains some shared machine IR code size optimization related
10 // code.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/MachineSizeOpts.h"
15 #include "llvm/CodeGen/MBFIWrapper.h"
16 #include "llvm/Analysis/ProfileSummaryInfo.h"
17 #include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
19 using namespace llvm;
21 extern cl::opt<bool> EnablePGSO;
22 extern cl::opt<bool> PGSOLargeWorkingSetSizeOnly;
23 extern cl::opt<bool> ForcePGSO;
24 extern cl::opt<int> PgsoCutoffInstrProf;
25 extern cl::opt<int> PgsoCutoffSampleProf;
27 bool llvm::shouldOptimizeForSize(const MachineFunction *MF,
28 ProfileSummaryInfo *PSI,
29 const MachineBlockFrequencyInfo *MBFI,
30 PGSOQueryType QueryType) {
31 return shouldFuncOptimizeForSizeImpl(MF, PSI, MBFI, QueryType);
34 bool llvm::shouldOptimizeForSize(const MachineBasicBlock *MBB,
35 ProfileSummaryInfo *PSI,
36 const MachineBlockFrequencyInfo *MBFI,
37 PGSOQueryType QueryType) {
38 assert(MBB);
39 return shouldOptimizeForSizeImpl(MBB, PSI, MBFI, QueryType);
42 bool llvm::shouldOptimizeForSize(const MachineBasicBlock *MBB,
43 ProfileSummaryInfo *PSI,
44 MBFIWrapper *MBFIW,
45 PGSOQueryType QueryType) {
46 assert(MBB);
47 if (!PSI || !MBFIW)
48 return false;
49 BlockFrequency BlockFreq = MBFIW->getBlockFreq(MBB);
50 return shouldOptimizeForSizeImpl(BlockFreq, PSI, &MBFIW->getMBFI(),
51 QueryType);