class GeneratedRTChecks

Declaration

class GeneratedRTChecks { /* full declaration omitted */ };

Description

Helper struct to manage generating runtime checks for vectorization. The runtime checks are created up-front in temporary blocks to allow better estimating the cost and un-linked from the existing IR. After deciding to vectorize, the checks are moved back. If deciding not to vectorize, the temporary blocks are completely removed.

Declared at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:1844

Member Variables

private llvm::BasicBlock* SCEVCheckBlock = nullptr
Basic block which contains the generated SCEV checks, if any.
private llvm::Value* SCEVCheckCond = nullptr
The value representing the result of the generated SCEV checks. If it is nullptr, either no SCEV checks have been generated or they have been used.
private llvm::BasicBlock* MemCheckBlock = nullptr
Basic block which contains the generated memory runtime checks, if any.
private llvm::Value* MemRuntimeCheckCond = nullptr
The value representing the result of the generated memory runtime checks. If it is nullptr, either no memory runtime checks have been generated or they have been used.
private llvm::DominatorTree* DT
private llvm::LoopInfo* LI
private llvm::TargetTransformInfo* TTI
private llvm::SCEVExpander SCEVExp
private llvm::SCEVExpander MemCheckExp
private bool CostTooHigh = false

Method Overview

  • public void Create(llvm::Loop * L, const llvm::LoopAccessInfo & LAI, const llvm::SCEVPredicate & UnionPred, llvm::ElementCount VF, unsigned int IC)
  • public GeneratedRTChecks(llvm::ScalarEvolution & SE, llvm::DominatorTree * DT, llvm::LoopInfo * LI, llvm::TargetTransformInfo * TTI, const llvm::DataLayout & DL)
  • public llvm::BasicBlock * emitMemRuntimeChecks(llvm::BasicBlock * Bypass, llvm::BasicBlock * LoopVectorPreHeader)
  • public llvm::BasicBlock * emitSCEVChecks(llvm::BasicBlock * Bypass, llvm::BasicBlock * LoopVectorPreHeader, llvm::BasicBlock * LoopExitBlock)
  • public llvm::InstructionCost getCost()
  • public ~GeneratedRTChecks()

Methods

void Create(llvm::Loop* L,
            const llvm::LoopAccessInfo& LAI,
            const llvm::SCEVPredicate& UnionPred,
            llvm::ElementCount VF,
            unsigned int IC)

Description

Generate runtime checks in SCEVCheckBlock and MemCheckBlock, so we can accurately estimate the cost of the runtime checks. The blocks are un-linked from the IR and is added back during vector code generation. If there is no vector code generation, the check blocks are removed completely.

Declared at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:1880

Parameters

llvm::Loop* L
const llvm::LoopAccessInfo& LAI
const llvm::SCEVPredicate& UnionPred
llvm::ElementCount VF
unsigned int IC

GeneratedRTChecks(llvm::ScalarEvolution& SE,
                  llvm::DominatorTree* DT,
                  llvm::LoopInfo* LI,
                  llvm::TargetTransformInfo* TTI,
                  const llvm::DataLayout& DL)

Declared at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:1870

Parameters

llvm::ScalarEvolution& SE
llvm::DominatorTree* DT
llvm::LoopInfo* LI
llvm::TargetTransformInfo* TTI
const llvm::DataLayout& DL

llvm::BasicBlock* emitMemRuntimeChecks(
    llvm::BasicBlock* Bypass,
    llvm::BasicBlock* LoopVectorPreHeader)

Description

Adds the generated MemCheckBlock before \p LoopVectorPreHeader and adjusts the branches to branch to the vector preheader or \p Bypass, depending on the generated condition.

Declared at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2074

Parameters

llvm::BasicBlock* Bypass
llvm::BasicBlock* LoopVectorPreHeader

llvm::BasicBlock* emitSCEVChecks(
    llvm::BasicBlock* Bypass,
    llvm::BasicBlock* LoopVectorPreHeader,
    llvm::BasicBlock* LoopExitBlock)

Description

Adds the generated SCEVCheckBlock before \p LoopVectorPreHeader and adjusts the branches to branch to the vector preheader or \p Bypass, depending on the generated condition.

Declared at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2038

Parameters

llvm::BasicBlock* Bypass
llvm::BasicBlock* LoopVectorPreHeader
llvm::BasicBlock* LoopExitBlock

llvm::InstructionCost getCost()

Declared at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:1966

~GeneratedRTChecks()

Description

Remove the created SCEV & memory runtime check blocks & instructions, if unused.

Declared at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2006