LLVM
8.0.1
|
#include "llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h"
#include "AggressiveInstCombineInternal.h"
#include "llvm-c/Initialization.h"
#include "llvm-c/Transforms/AggressiveInstCombine.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Pass.h"
#include "llvm/Transforms/Utils/Local.h"
Go to the source code of this file.
Classes | |
struct | MaskOps |
This is used by foldAnyOrAllBitsSet() to capture a source value (Root) and the bit indexes (Mask) needed by a masked compare. More... | |
Macros | |
#define | DEBUG_TYPE "aggressive-instcombine" |
Functions | |
static bool | foldGuardedRotateToFunnelShift (Instruction &I) |
Match a pattern for a bitwise rotate operation that partially guards against undefined behavior by branching around the rotation when the shift amount is 0. More... | |
static bool | matchAndOrChain (Value *V, MaskOps &MOps) |
This is a recursive helper for foldAnyOrAllBitsSet() that walks through a chain of 'and' or 'or' instructions looking for shift ops of a common source value. More... | |
static bool | foldAnyOrAllBitsSet (Instruction &I) |
Match patterns that correspond to "any-bits-set" and "all-bits-set". More... | |
static bool | foldUnusualPatterns (Function &F, DominatorTree &DT) |
This is the entry point for folds that could be implemented in regular InstCombine, but they are separated because they are not expected to occur frequently and/or have more than a constant-length pattern match. More... | |
static bool | runImpl (Function &F, TargetLibraryInfo &TLI, DominatorTree &DT) |
This is the entry point for all transforms. More... | |
INITIALIZE_PASS_BEGIN (AggressiveInstCombinerLegacyPass, "aggressive-instcombine", "Combine pattern based expressions", false, false) INITIALIZE_PASS_END(AggressiveInstCombinerLegacyPass | |
void | LLVMInitializeAggressiveInstCombiner (LLVMPassRegistryRef R) |
void | LLVMAddAggressiveInstCombinerPass (LLVMPassManagerRef PM) |
See llvm::createAggressiveInstCombinerPass function. More... | |
Variables | |
aggressive | instcombine |
aggressive Combine pattern based | expressions |
aggressive Combine pattern based | false |
#define DEBUG_TYPE "aggressive-instcombine" |
Definition at line 34 of file AggressiveInstCombine.cpp.
|
static |
Match patterns that correspond to "any-bits-set" and "all-bits-set".
These will include a chain of 'or' or 'and'-shifted bits from a common source value: and (or (lshr X, C), ...), 1 –> (X & CMask) != 0 and (and (lshr X, C), ...), 1 –> (X & CMask) == CMask Note: "any-bits-clear" and "all-bits-clear" are variations of these patterns that differ only with a final 'not' of the result. We expect that final 'not' to be folded with the compare that we create here (invert predicate).
Definition at line 223 of file AggressiveInstCombine.cpp.
References llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::IRBuilder< T, Inserter >::CreateICmpEQ(), llvm::IRBuilder< T, Inserter >::CreateIsNotNull(), llvm::IRBuilder< T, Inserter >::CreateZExt(), llvm::ConstantInt::get(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Value(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), matchAndOrChain(), and llvm::Value::replaceAllUsesWith().
Referenced by foldUnusualPatterns().
|
static |
Match a pattern for a bitwise rotate operation that partially guards against undefined behavior by branching around the rotation when the shift amount is 0.
Definition at line 65 of file AggressiveInstCombine.cpp.
References assert(), F(), llvm::Intrinsic::fshl, llvm::Intrinsic::fshr, llvm::Intrinsic::getDeclaration(), llvm::BasicBlock::getFirstInsertionPt(), llvm::PHINode::getIncomingBlock(), llvm::Instruction::getModule(), llvm::User::getNumOperands(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::Type::getScalarSizeInBits(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), I, llvm::CmpInst::ICMP_EQ, llvm::isPowerOf2_32(), llvm::PatternMatch::m_Br(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZeroInt(), llvm::PatternMatch::match(), matchRotate(), llvm::Intrinsic::not_intrinsic, llvm::Value::replaceAllUsesWith(), X, and Y.
Referenced by foldUnusualPatterns().
|
static |
This is the entry point for folds that could be implemented in regular InstCombine, but they are separated because they are not expected to occur frequently and/or have more than a constant-length pattern match.
Definition at line 258 of file AggressiveInstCombine.cpp.
References foldAnyOrAllBitsSet(), foldGuardedRotateToFunnelShift(), I, llvm::DominatorTree::isReachableFromEntry(), llvm::make_range(), and llvm::SimplifyInstructionsInBlock().
Referenced by runImpl().
INITIALIZE_PASS_BEGIN | ( | AggressiveInstCombinerLegacyPass | , |
"aggressive-instcombine" | , | ||
"Combine pattern based expressions" | , | ||
false | , | ||
false | |||
) |
Referenced by llvm::AggressiveInstCombinePass::run().
This is a recursive helper for foldAnyOrAllBitsSet() that walks through a chain of 'and' or 'or' instructions looking for shift ops of a common source value.
Examples: or (or (or X, (X >> 3)), (X >> 5)), (X >> 8) returns { X, 0x129 } and (and (X >> 1), 1), (X >> 4) returns { X, 0x12 }
Definition at line 177 of file AggressiveInstCombine.cpp.
References MaskOps::FoundAnd1, llvm::APInt::getBitWidth(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Value(), MaskOps::Mask, llvm::PatternMatch::match(), MaskOps::MatchAndChain, MaskOps::Root, and llvm::APInt::setBit().
Referenced by foldAnyOrAllBitsSet().
|
static |
This is the entry point for all transforms.
Pass manager differences are handled in the callers of this function.
Definition at line 286 of file AggressiveInstCombine.cpp.
References llvm::AnalysisUsage::addPreserved(), llvm::AnalysisUsage::addRequired(), F(), foldUnusualPatterns(), llvm::Module::getDataLayout(), llvm::GlobalValue::getParent(), llvm::TruncInstCombine::run(), runOnFunction(), and llvm::AnalysisUsage::setPreservesCFG().
Referenced by INITIALIZE_PASS(), llvm::RewriteSymbolPass::RewriteSymbolPass(), llvm::LowerInvokePass::run(), llvm::Float2IntPass::run(), llvm::AggressiveInstCombinePass::run(), llvm::AlignmentFromAssumptionsPass::run(), llvm::MemCpyOptPass::run(), llvm::GVN::run(), llvm::SLPVectorizerPass::run(), llvm::LoopVectorizePass::run(), llvm::JumpThreadingPass::run(), llvm::NaryReassociatePass::run(), llvm::SROA::run(), llvm::ConstantHoistingPass::run(), and llvm::RewriteSymbolPass::run().
aggressive Combine pattern based expressions |
Definition at line 334 of file AggressiveInstCombine.cpp.
aggressive Combine pattern based false |
Definition at line 334 of file AggressiveInstCombine.cpp.
aggressive instcombine |
Definition at line 334 of file AggressiveInstCombine.cpp.