#include "llvm/CodeGen/ExpandVectorPredication.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Analysis/VectorUtils.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include <optional>
usingnamespacellvm;
VPLegalization;
VPTransform;
#define VPINTERNAL_VPLEGAL_CASES …
#define VPINTERNAL_CASE(X) …
static cl::opt<std::string> EVLTransformOverride(
"expandvp-override-evl-transform", cl::init(""), cl::Hidden,
cl::desc("Options: <empty>" VPINTERNAL_VPLEGAL_CASES
". If non-empty, ignore "
"TargetTransformInfo and "
"always use this transformation for the %evl parameter (Used in "
"testing)."));
static cl::opt<std::string> MaskTransformOverride(
"expandvp-override-mask-transform", cl::init(""), cl::Hidden,
cl::desc("Options: <empty>" VPINTERNAL_VPLEGAL_CASES
". If non-empty, Ignore "
"TargetTransformInfo and "
"always use this transformation for the %mask parameter (Used in "
"testing)."));
#undef VPINTERNAL_CASE
#define VPINTERNAL_CASE(X) …
static VPTransform parseOverrideOption(const std::string &TextOpt) { … }
#undef VPINTERNAL_VPLEGAL_CASES
static bool anyExpandVPOverridesSet() { … }
#define DEBUG_TYPE …
STATISTIC(NumFoldedVL, "Number of folded vector length params");
STATISTIC(NumLoweredVPOps, "Number of folded vector predication operations");
static bool isAllTrueMask(Value *MaskVal) { … }
static Constant *getSafeDivisor(Type *DivTy) { … }
static void transferDecorations(Value &NewVal, VPIntrinsic &VPI) { … }
static void replaceOperation(Value &NewOp, VPIntrinsic &OldOp) { … }
static bool maySpeculateLanes(VPIntrinsic &VPI) { … }
namespace {
struct CachingVPExpander { … };
Value *CachingVPExpander::createStepVector(IRBuilder<> &Builder, Type *LaneTy,
unsigned NumElems) { … }
Value *CachingVPExpander::convertEVLToMask(IRBuilder<> &Builder,
Value *EVLParam,
ElementCount ElemCount) { … }
Value *
CachingVPExpander::expandPredicationInBinaryOperator(IRBuilder<> &Builder,
VPIntrinsic &VPI) { … }
Value *CachingVPExpander::expandPredicationToIntCall(
IRBuilder<> &Builder, VPIntrinsic &VPI, unsigned UnpredicatedIntrinsicID) { … }
Value *CachingVPExpander::expandPredicationToFPCall(
IRBuilder<> &Builder, VPIntrinsic &VPI, unsigned UnpredicatedIntrinsicID) { … }
static Value *getNeutralReductionElement(const VPReductionIntrinsic &VPI,
Type *EltTy) { … }
Value *
CachingVPExpander::expandPredicationInReduction(IRBuilder<> &Builder,
VPReductionIntrinsic &VPI) { … }
Value *CachingVPExpander::expandPredicationToCastIntrinsic(IRBuilder<> &Builder,
VPIntrinsic &VPI) { … }
Value *
CachingVPExpander::expandPredicationInMemoryIntrinsic(IRBuilder<> &Builder,
VPIntrinsic &VPI) { … }
Value *CachingVPExpander::expandPredicationInComparison(IRBuilder<> &Builder,
VPCmpIntrinsic &VPI) { … }
bool CachingVPExpander::discardEVLParameter(VPIntrinsic &VPI) { … }
std::pair<Value *, bool> CachingVPExpander::foldEVLIntoMask(VPIntrinsic &VPI) { … }
Value *CachingVPExpander::expandPredication(VPIntrinsic &VPI) { … }
void sanitizeStrategy(VPIntrinsic &VPI, VPLegalization &LegalizeStrat) { … }
VPLegalization
CachingVPExpander::getVPLegalizationStrategy(const VPIntrinsic &VPI) const { … }
VPExpansionDetails
CachingVPExpander::expandVectorPredication(VPIntrinsic &VPI) { … }
}
VPExpansionDetails
llvm::expandVectorPredicationIntrinsic(VPIntrinsic &VPI,
const TargetTransformInfo &TTI) { … }