|
LLVM 23.0.0git
|
#include "InstCombineInternal.h"#include "llvm/Analysis/ValueTracking.h"#include "llvm/IR/GetElementPtrTypeIterator.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/PatternMatch.h"#include "llvm/IR/ProfDataUtils.h"#include "llvm/Support/KnownBits.h"#include "llvm/Transforms/InstCombine/InstCombiner.h"Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "instcombine" |
Functions | |
| static bool | ShrinkDemandedConstant (Instruction *I, unsigned OpNo, const APInt &Demanded) |
| Check to see if the specified operand of the specified instruction is a constant integer. | |
| static Value * | simplifyShiftSelectingPackedElement (Instruction *I, const APInt &DemandedMask, InstCombinerImpl &IC, unsigned Depth) |
| Let N = 2 * M. | |
| static unsigned | getBitWidth (Type *Ty, const DataLayout &DL) |
| Returns the bitwidth of the given scalar or pointer type. | |
| static Constant * | getFPClassConstant (Type *Ty, FPClassTest Mask, bool IsCanonicalizing=false) |
| For floating-point classes that resolve to a single bit pattern, return that value. | |
| static Value * | simplifyDemandedFPClassFabs (KnownFPClass &Known, Value *Src, FPClassTest DemandedMask, KnownFPClass KnownSrc, bool NSZ) |
Perform multiple-use aware simplfications for fabs(Src). | |
| static FastMathFlags | inferFastMathValueFlags (FastMathFlags FMF, FPClassTest ValidResults, ArrayRef< KnownFPClass > Known) |
Try to set an inferred no-nans or no-infs in FMF. | |
| static FPClassTest | adjustDemandedMaskFromFlags (FPClassTest DemandedMask, FastMathFlags FMF) |
| static Value * | simplifyDemandedFPClassResult (Instruction *FPOp, FastMathFlags FMF, FPClassTest DemandedMask, KnownFPClass &Known, ArrayRef< KnownFPClass > KnownSrcs) |
| Apply epilog fixups to a floating-point intrinsic. | |
| static Value * | simplifyDemandedFPClassFnegFabs (KnownFPClass &Known, Value *Src, FPClassTest DemandedMask, KnownFPClass KnownSrc, bool NSZ) |
Perform multiple-use aware simplfications for fneg(fabs(Src)). | |
| static Value * | simplifyDemandedFPClassCopysignMag (Value *MagSrc, FPClassTest DemandedMask, KnownFPClass KnownSrc, bool NSZ) |
| static Value * | simplifyDemandedFPClassMinMax (KnownFPClass &Known, Intrinsic::ID IID, const CallInst *CI, FPClassTest DemandedMask, KnownFPClass KnownLHS, KnownFPClass KnownRHS, const Function &F, bool NSZ) |
| static Value * | simplifyDemandedUseFPClassFPTrunc (InstCombinerImpl &IC, Instruction &I, FastMathFlags FMF, FPClassTest DemandedMask, KnownFPClass &Known, unsigned Depth) |
Variables | |
| static cl::opt< bool > | VerifyKnownBits ("instcombine-verify-known-bits", cl::desc("Verify that computeKnownBits() and " "SimplifyDemandedBits() are consistent"), cl::Hidden, cl::init(false)) |
| static cl::opt< unsigned > | SimplifyDemandedVectorEltsDepthLimit ("instcombine-simplify-vector-elts-depth", cl::desc("Depth limit when simplifying vector instructions and their operands"), cl::Hidden, cl::init(10)) |
| #define DEBUG_TYPE "instcombine" |
Definition at line 26 of file InstCombineSimplifyDemanded.cpp.
|
static |
Definition at line 2087 of file InstCombineSimplifyDemanded.cpp.
References llvm::fcInf, llvm::fcNan, llvm::FastMathFlags::noInfs(), and llvm::FastMathFlags::noNaNs().
Referenced by llvm::InstCombinerImpl::SimplifyDemandedUseFPClass(), and llvm::InstCombinerImpl::SimplifyMultipleUseDemandedFPClass().
|
static |
Returns the bitwidth of the given scalar or pointer type.
For vector types, returns the element type's bitwidth.
Definition at line 123 of file InstCombineSimplifyDemanded.cpp.
References llvm::BitWidth, and DL.
|
static |
For floating-point classes that resolve to a single bit pattern, return that value.
Definition at line 2008 of file InstCombineSimplifyDemanded.cpp.
References llvm::fcNan, llvm::fcNegInf, llvm::fcNegZero, llvm::fcNone, llvm::fcPosInf, llvm::fcPosZero, llvm::fcQNan, llvm::PoisonValue::get(), llvm::ConstantFP::getInfinity(), llvm::Constant::getNullValue(), llvm::ConstantFP::getQNaN(), and llvm::ConstantFP::getZero().
Referenced by llvm::InstCombinerImpl::SimplifyDemandedFPClass(), simplifyDemandedFPClassMinMax(), simplifyDemandedFPClassResult(), llvm::InstCombinerImpl::SimplifyDemandedUseFPClass(), and llvm::InstCombinerImpl::SimplifyMultipleUseDemandedFPClass().
|
static |
Try to set an inferred no-nans or no-infs in FMF.
ValidResults is a mask of known valid results for the operator (already computed from the result, and the known operand inputs in Known)
Definition at line 2067 of file InstCombineSimplifyDemanded.cpp.
References llvm::all_of(), llvm::fcInf, llvm::fcNan, llvm::fcNone, llvm::KnownFPClass::isKnownNeverInfinity(), llvm::KnownFPClass::isKnownNeverNaN(), llvm::FastMathFlags::noInfs(), llvm::FastMathFlags::noNaNs(), llvm::FastMathFlags::setNoInfs(), and llvm::FastMathFlags::setNoNaNs().
Referenced by simplifyDemandedFPClassResult(), and llvm::InstCombinerImpl::SimplifyDemandedUseFPClass().
|
static |
Check to see if the specified operand of the specified instruction is a constant integer.
If so, check to see if there are any bits set in the constant that are not demanded. If so, shrink the constant and return true.
Definition at line 43 of file InstCombineSimplifyDemanded.cpp.
References assert(), llvm::CallingConv::C, I, llvm::PatternMatch::m_APInt(), and llvm::PatternMatch::match().
Referenced by llvm::TargetLowering::ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), and llvm::InstCombinerImpl::SimplifyDemandedUseBits().
|
static |
Definition at line 2146 of file InstCombineSimplifyDemanded.cpp.
References llvm::fcNegative, llvm::fcNegZero, llvm::fcNone, llvm::fcPositive, llvm::fcPosZero, llvm::KnownFPClass::isKnownAlways(), and llvm::KnownFPClass::SignBit.
Referenced by llvm::InstCombinerImpl::SimplifyDemandedUseFPClass(), and llvm::InstCombinerImpl::SimplifyMultipleUseDemandedFPClass().
|
static |
Perform multiple-use aware simplfications for fabs(Src).
Returns a replacement value if it's simplified, otherwise nullptr. Updates Known with the known fpclass if not simplified.
Definition at line 2042 of file InstCombineSimplifyDemanded.cpp.
References llvm::KnownFPClass::fabs(), llvm::fcInf, llvm::fcNan, llvm::fcNegative, llvm::fcNone, llvm::KnownFPClass::isKnownNever(), llvm::KnownFPClass::knownNot(), llvm::KnownFPClass::OrderedLessThanZeroMask, and llvm::KnownFPClass::SignBit.
Referenced by llvm::InstCombinerImpl::SimplifyDemandedUseFPClass(), and llvm::InstCombinerImpl::SimplifyMultipleUseDemandedFPClass().
|
static |
Perform multiple-use aware simplfications for fneg(fabs(Src)).
Returns a replacement value if it's simplified, otherwise nullptr. Updates Known with the known fpclass if not simplified.
Definition at line 2124 of file InstCombineSimplifyDemanded.cpp.
References llvm::KnownFPClass::fabs(), llvm::fcInf, llvm::fcNan, llvm::fcNone, llvm::KnownFPClass::fneg(), llvm::KnownFPClass::isKnownNever(), llvm::KnownFPClass::knownNot(), llvm::KnownFPClass::OrderedGreaterThanZeroMask, and llvm::KnownFPClass::SignBit.
Referenced by llvm::InstCombinerImpl::SimplifyDemandedUseFPClass(), and llvm::InstCombinerImpl::SimplifyMultipleUseDemandedFPClass().
|
static |
Definition at line 2173 of file InstCombineSimplifyDemanded.cpp.
References llvm::cannotOrderStrictlyGreater(), llvm::cannotOrderStrictlyLess(), F, llvm::fcNan, llvm::CallBase::getArgOperand(), llvm::Type::getFltSemantics(), getFPClassConstant(), llvm::Type::getScalarType(), llvm::Value::getType(), llvm::KnownFPClass::isKnownNever(), llvm::KnownFPClass::KnownFPClasses, llvm::KnownFPClass::knownNot(), llvm_unreachable, llvm::KnownFPClass::maximum, llvm::KnownFPClass::maximumnum, llvm::KnownFPClass::minimum, llvm::KnownFPClass::minimumnum, llvm::KnownFPClass::minMaxLike(), and Mode.
Referenced by llvm::InstCombinerImpl::SimplifyDemandedUseFPClass(), and llvm::InstCombinerImpl::SimplifyMultipleUseDemandedFPClass().
|
static |
Apply epilog fixups to a floating-point intrinsic.
See if the result can fold to a constant, or apply fast math flags.
Definition at line 2099 of file InstCombineSimplifyDemanded.cpp.
References llvm::Instruction::dropUBImplyingAttrsAndMetadata(), getFPClassConstant(), llvm::Value::getType(), inferFastMathValueFlags(), llvm::KnownFPClass::KnownFPClasses, and llvm::Instruction::setFastMathFlags().
Referenced by llvm::InstCombinerImpl::SimplifyDemandedUseFPClass(), and simplifyDemandedUseFPClassFPTrunc().
|
static |
Definition at line 2259 of file InstCombineSimplifyDemanded.cpp.
References llvm::Depth, llvm::fcNegInf, llvm::fcNegNormal, llvm::fcNegSubnormal, llvm::fcNegZero, llvm::fcPosInf, llvm::fcPosNormal, llvm::fcPosSubnormal, llvm::fcPosZero, llvm::KnownFPClass::fptrunc(), I, llvm::KnownFPClass::knownNot(), llvm::InstCombinerImpl::SimplifyDemandedFPClass(), and simplifyDemandedFPClassResult().
Referenced by llvm::InstCombinerImpl::SimplifyDemandedUseFPClass().
|
static |
Let N = 2 * M.
Given an N-bit integer representing a pack of two M-bit integers, we can select one of the packed integers by right-shifting by either zero or M (which is the most straightforward to check if M is a power of 2), and then isolating the lower M bits. In this case, we can represent the shift as a select on whether the shr amount is nonzero.
Definition at line 70 of file InstCombineSimplifyDemanded.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::InstCombiner::computeKnownBits(), llvm::IRBuilderBase::CreateICmpEQ(), llvm::IRBuilderBase::CreateSelectWithUnknownProfile(), DEBUG_TYPE, llvm::Depth, llvm::APInt::getActiveBits(), llvm::KnownBits::getMaxValue(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::Value::getType(), I, llvm::APInt::isIntN(), llvm::isPowerOf2_64(), llvm::Lower, llvm::PatternMatch::m_c_DisjointOr(), llvm::PatternMatch::m_ConstantInt(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), Select, llvm::IRBuilderBase::SetInsertPoint(), llvm::Upper, and llvm::KnownBits::Zero.
Referenced by llvm::InstCombinerImpl::SimplifyDemandedUseBits().
|
static |
Referenced by llvm::InstCombinerImpl::SimplifyDemandedVectorElts().
|
static |
Referenced by llvm::InstCombinerImpl::SimplifyDemandedUseBits().