|
LLVM 23.0.0git
|
This file implements a pass that converts X86 cmov instructions into branches when profitable. More...
#include "X86.h"#include "X86InstrInfo.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/DenseMap.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/CodeGen/MachineBasicBlock.h"#include "llvm/CodeGen/MachineFunction.h"#include "llvm/CodeGen/MachineFunctionPass.h"#include "llvm/CodeGen/MachineInstr.h"#include "llvm/CodeGen/MachineInstrBuilder.h"#include "llvm/CodeGen/MachineLoopInfo.h"#include "llvm/CodeGen/MachineOperand.h"#include "llvm/CodeGen/MachineRegisterInfo.h"#include "llvm/CodeGen/TargetInstrInfo.h"#include "llvm/CodeGen/TargetRegisterInfo.h"#include "llvm/CodeGen/TargetSchedule.h"#include "llvm/CodeGen/TargetSubtargetInfo.h"#include "llvm/IR/DebugLoc.h"#include "llvm/InitializePasses.h"#include "llvm/MC/MCSchedule.h"#include "llvm/Pass.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Target/CGPassBuilderOption.h"#include <algorithm>#include <cassert>#include <iterator>#include <utility>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "x86-cmov-conversion" |
Functions | |
| STATISTIC (NumOfSkippedCmovGroups, "Number of unsupported CMOV-groups") | |
| STATISTIC (NumOfCmovGroupCandidate, "Number of CMOV-group candidates") | |
| STATISTIC (NumOfLoopCandidate, "Number of CMOV-conversion profitable loops") | |
| STATISTIC (NumOfOptimizedCmovGroups, "Number of optimized CMOV-groups") | |
| static unsigned | getDepthOfOptCmov (unsigned TrueOpDepth, unsigned FalseOpDepth) |
| static bool | checkEFLAGSLive (MachineInstr *MI) |
| static void | packCmovGroup (MachineInstr *First, MachineInstr *Last) |
| Given /p First CMOV instruction and /p Last CMOV instruction representing a group of CMOV instructions, which may contain debug instructions in between, move all debug instructions to after the last CMOV instruction, making the CMOV group consecutive. | |
| INITIALIZE_PASS_BEGIN (X86CmovConversionLegacy, DEBUG_TYPE, "X86 cmov Conversion", false, false) INITIALIZE_PASS_END(X86CmovConversionLegacy | |
Variables | |
| static cl::opt< bool > | EnableCmovConverter ("x86-cmov-converter", cl::desc("Enable the X86 cmov-to-branch optimization."), cl::init(true), cl::Hidden) |
| static cl::opt< unsigned > | GainCycleThreshold ("x86-cmov-converter-threshold", cl::desc("Minimum gain per loop (in cycles) threshold."), cl::init(4), cl::Hidden) |
| static cl::opt< bool > | ForceMemOperand ("x86-cmov-converter-force-mem-operand", cl::desc("Convert cmovs to branches whenever they have memory operands."), cl::init(true), cl::Hidden) |
| static cl::opt< bool > | ForceAll ("x86-cmov-converter-force-all", cl::desc("Convert all cmovs to branches."), cl::init(false), cl::Hidden) |
| DEBUG_TYPE | |
| X86 cmov | Conversion |
| X86 cmov | false |
This file implements a pass that converts X86 cmov instructions into branches when profitable.
This pass is conservative. It transforms if and only if it can guarantee a gain with high confidence.
Thus, the optimization applies under the following conditions:
Note: This pass is assumed to run on SSA machine code.
Definition in file X86CmovConversion.cpp.
| #define DEBUG_TYPE "x86-cmov-conversion" |
Definition at line 78 of file X86CmovConversion.cpp.
|
static |
Definition at line 585 of file X86CmovConversion.cpp.
References E(), llvm::MachineBasicBlock::end(), I, MI, and llvm::MachineBasicBlock::successors().
| TrueOpDepth | depth cost of CMOV true value operand. |
| FalseOpDepth | depth cost of CMOV false value operand. |
Definition at line 386 of file X86CmovConversion.cpp.
References llvm::divideCeil().
| INITIALIZE_PASS_BEGIN | ( | X86CmovConversionLegacy | , |
| DEBUG_TYPE | , | ||
| "X86 cmov Conversion" | , | ||
| false | , | ||
| false | ) |
References DEBUG_TYPE, and INITIALIZE_PASS_DEPENDENCY.
|
static |
Given /p First CMOV instruction and /p Last CMOV instruction representing a group of CMOV instructions, which may contain debug instructions in between, move all debug instructions to after the last CMOV instruction, making the CMOV group consecutive.
Definition at line 614 of file X86CmovConversion.cpp.
References assert(), llvm::X86::COND_INVALID, E(), llvm::First, llvm::X86::getCondFromCMov(), I, llvm::Last, MBB, MI, and llvm::SmallVectorTemplateBase< T, bool >::push_back().
| STATISTIC | ( | NumOfCmovGroupCandidate | , |
| "Number of CMOV-group candidates" | ) |
| STATISTIC | ( | NumOfLoopCandidate | , |
| "Number of CMOV-conversion profitable loops" | ) |
| STATISTIC | ( | NumOfOptimizedCmovGroups | , |
| "Number of optimized CMOV-groups" | ) |
| STATISTIC | ( | NumOfSkippedCmovGroups | , |
| "Number of unsupported CMOV-groups" | ) |
| X86 cmov Conversion |
Definition at line 894 of file X86CmovConversion.cpp.
Referenced by llvm::TextEncodingConverter::create(), and performVectorTruncZeroCombine().
| DEBUG_TYPE |
Definition at line 894 of file X86CmovConversion.cpp.
|
static |
| X86 cmov false |
Definition at line 895 of file X86CmovConversion.cpp.
|
static |
|
static |