LLVM 20.0.0git
|
Finalize v8.1-m low-overhead loops by converting the associated pseudo instructions into machine operations. More...
#include "ARM.h"
#include "ARMBaseInstrInfo.h"
#include "ARMBaseRegisterInfo.h"
#include "ARMBasicBlockInfo.h"
#include "ARMSubtarget.h"
#include "MVETailPredUtils.h"
#include "Thumb2InstrInfo.h"
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/CodeGen/LivePhysRegs.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineLoopUtils.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/ReachingDefAnalysis.h"
#include "llvm/MC/MCInstrDesc.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "arm-low-overhead-loops" |
#define | ARM_LOW_OVERHEAD_LOOPS_NAME "ARM Low Overhead Loops pass" |
Variables | |
static cl::opt< bool > | DisableTailPredication ("arm-loloops-disable-tailpred", cl::Hidden, cl::desc("Disable tail-predication in the ARM LowOverheadLoop pass"), cl::init(false)) |
static cl::opt< bool > | DisableOmitDLS ("arm-disable-omit-dls", cl::Hidden, cl::desc("Disable omitting 'dls lr, lr' instructions"), cl::init(false)) |
ReachingDefAnalysis & | RDA |
ReachingDefAnalysis InstSet & | ToRemove |
ReachingDefAnalysis InstSet InstSet & | Ignore |
SmallPtrSet< MachineInstr *, 2 > | Uses |
return | false |
Finalize v8.1-m low-overhead loops by converting the associated pseudo instructions into machine operations.
The expectation is that the loop contains three pseudo instructions:
In addition to this, we also look for the presence of the VCTP instruction, which determines whether we can generated the tail-predicated low-overhead loop form.
Assumptions and Dependencies: Low-overhead loops are constructed and executed using a setup instruction: DLS, WLS, DLSTP or WLSTP and an instruction that loops back: LE or LETP. WLS(TP) and LE(TP) are branching instructions with a (large) limited range but fixed polarity: WLS can only branch forwards and LE can only branch backwards. These restrictions mean that this pass is dependent upon block layout and block sizes, which is why it's the last pass to run. The same is true for ConstantIslands, but this pass does not increase the size of the basic blocks, nor does it change the CFG. Instructions are mainly removed during the transform and pseudo instructions are replaced by real ones. In some cases, when we have to revert to a 'normal' loop, we have to introduce multiple instructions for a single pseudo (see RevertWhile and RevertLoopEnd). To handle this situation, t2WhileLoopStartLR and t2LoopEnd are defined to be as large as this maximum sequence of replacement instructions.
A note on VPR.P0 (the lane mask): VPT, VCMP, VPNOT and VCTP won't overwrite VPR.P0 when they update it in a "VPT Active" context (which includes low-overhead loops and vpt blocks). They will simply "and" the result of their calculation with the current value of VPR.P0. You can think of it like this:
/// if VPT active: ; Between a DLSTP/LETP, or for predicated instrs /// VPR.P0 &= Value /// else /// VPR.P0 = Value ///
When we're inside the low-overhead loop (between DLSTP and LETP), we always fall in the "VPT active" case, so we can consider that all VPR writes by one of those instruction is actually a "and".
Definition in file ARMLowOverheadLoops.cpp.
#define ARM_LOW_OVERHEAD_LOOPS_NAME "ARM Low Overhead Loops pass" |
Definition at line 76 of file ARMLowOverheadLoops.cpp.
#define DEBUG_TYPE "arm-low-overhead-loops" |
Definition at line 75 of file ARMLowOverheadLoops.cpp.
|
static |
Definition at line 836 of file ARMLowOverheadLoops.cpp.
References MI, and producesDoubleWidthResult().
Referenced by producesFalseLanesZero().
|
static |
Definition at line 106 of file ARMLowOverheadLoops.cpp.
References MI, llvm::MCInstrDesc::TSFlags, llvm::ARMII::VecSize, and llvm::ARMII::VecSizeShift.
|
static |
Definition at line 97 of file ARMLowOverheadLoops.cpp.
References MI.
Referenced by shouldInspect().
if | ( | !RDA. | isSafeToRemoveMI, Uses, Ignore | ) |
Definition at line 582 of file ARMLowOverheadLoops.cpp.
References llvm::SmallPtrSetImpl< PtrType >::begin(), llvm::ReachingDefAnalysis::collectKilledOperands(), llvm::dbgs(), llvm::SmallPtrSetImpl< PtrType >::end(), LLVM_DEBUG, MI, RDA, ToRemove, and Uses.
INITIALIZE_PASS | ( | ARMLowOverheadLoops | , |
DEBUG_TYPE | , | ||
ARM_LOW_OVERHEAD_LOOPS_NAME | , | ||
false | , | ||
false | |||
) |
|
static |
Definition at line 101 of file ARMLowOverheadLoops.cpp.
References llvm::ARMII::DomainMask, llvm::ARMII::DomainMVE, and MI.
Referenced by shouldInspect().
|
static |
Definition at line 118 of file ARMLowOverheadLoops.cpp.
References llvm::ARMII::HorizontalReduction, MI, and llvm::MCInstrDesc::TSFlags.
Referenced by producesFalseLanesZero().
|
static |
Definition at line 809 of file ARMLowOverheadLoops.cpp.
References llvm::MachineOperand::getReg(), and llvm::MachineOperand::isReg().
Referenced by producesFalseLanesZero().
|
static |
Definition at line 93 of file ARMLowOverheadLoops.cpp.
References MI.
Referenced by shouldInspect().
|
static |
Definition at line 88 of file ARMLowOverheadLoops.cpp.
References llvm::findFirstVPTPredOperandIdx(), and MI.
Referenced by producesFalseLanesZero().
|
static |
Definition at line 826 of file ARMLowOverheadLoops.cpp.
References llvm::ARMII::DoubleWidthResult, MI, and llvm::MCInstrDesc::TSFlags.
Referenced by canGenerateNonZeros().
|
static |
Definition at line 865 of file ARMLowOverheadLoops.cpp.
References canGenerateNonZeros(), llvm::dbgs(), llvm::SmallPtrSetImplBase::empty(), llvm::findFirstVPTPredOperandIdx(), llvm::ReachingDefAnalysis::getGlobalReachingDefs(), llvm::MachineOperand::getOperandNo(), llvm::MachineOperand::getReg(), isHorizontalReduction(), llvm::MachineOperand::isReg(), isRegInClass(), llvm::MachineOperand::isUse(), isVectorPredicated(), LLVM_DEBUG, MI, and RDA.
|
static |
Definition at line 817 of file ARMLowOverheadLoops.cpp.
References MI, llvm::ARMII::RetainsPreviousHalfElement, and llvm::MCInstrDesc::TSFlags.
|
static |
Definition at line 112 of file ARMLowOverheadLoops.cpp.
References hasVPRUse(), isDomainMVE(), isVectorPredicate(), and MI.
|
static |
Definition at line 1127 of file ARMLowOverheadLoops.cpp.
References llvm::SmallPtrSetImpl< PtrType >::contains(), llvm::PseudoSourceValue::FixedStack, I, Idx, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::is_contained(), llvm::PseudoSourceValue::kind(), MI, ML, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorBase< Size_T >::size(), and llvm::MachineBasicBlock::successors().
|
static |
|
static |
return false |
Definition at line 598 of file ARMLowOverheadLoops.cpp.
ReachingDefAnalysis InstSet InstSet& Ignore |
Definition at line 534 of file ARMLowOverheadLoops.cpp.
Referenced by llvm::ReachingDefAnalysis::isSafeToDefRegAt(), llvm::ReachingDefAnalysis::isSafeToRemove(), and llvm::sys::unicode::startsWith().
ReachingDefAnalysis& RDA |
Definition at line 533 of file ARMLowOverheadLoops.cpp.
Referenced by if(), and producesFalseLanesZero().
ReachingDefAnalysis InstSet& ToRemove |
Definition at line 534 of file ARMLowOverheadLoops.cpp.
Referenced by llvm::AA::PointerInfo::State::addAccess(), analyzeAndPruneOutputBlocks(), llvm::LoopVectorizationCostModel::calculateRegisterUsage(), checkAndReplaceCmp(), checkAndReplaceCondition(), checkAndReplaceMinMax(), llvm::LoopAccessInfoManager::clear(), llvm::EliminateDuplicatePHINodes(), EliminateDuplicatePHINodesNaiveImpl(), EliminateDuplicatePHINodesSetBasedImpl(), llvm::objcopy::elf::RelocSectionWithSymtabBase< DynamicSymbolTableSection >::finalize(), findBasePointer(), llvm::objcopy::coff::handleArgs(), if(), llvm::ReachingDefAnalysis::isSafeToRemove(), legalizeAndOptimizeInductions(), llvm::SPIRV::RequirementHandler::removeCapabilityIf(), llvm::objcopy::elf::Section::removeSectionReferences(), llvm::objcopy::elf::SymbolTableSection::removeSectionReferences(), llvm::objcopy::elf::GroupSection::removeSectionReferences(), llvm::objcopy::elf::DynamicRelocationSection::removeSectionReferences(), llvm::objcopy::elf::Object::removeSections(), llvm::objcopy::coff::Object::removeSections(), llvm::objcopy::wasm::Object::removeSections(), llvm::objcopy::macho::SymbolTable::removeSymbols(), llvm::objcopy::elf::Object::removeSymbols(), llvm::objcopy::elf::SymbolTableSection::removeSymbols(), llvm::objcopy::elf::RelocationSection::removeSymbols(), llvm::objcopy::elf::GroupSection::removeSymbols(), llvm::objcopy::coff::Object::removeSymbols(), removeUbsanTraps(), removeUnreachableFunctions(), replaceSubOverflowUses(), SPIRVStripConvergentIntrinsics::runOnFunction(), sinkMinMaxInBB(), llvm::JumpThreadingPass::threadGuard(), llvm::DbgValueHistoryMap::trimLocationRanges(), and tryToSimplifyOverflowMath().
SmallPtrSet<MachineInstr *, 2> Uses |
Definition at line 578 of file ARMLowOverheadLoops.cpp.
Referenced by if().