|
LLVM 23.0.0git
|
#include "InstCombineInternal.h"#include "llvm/ADT/APFloat.h"#include "llvm/ADT/APInt.h"#include "llvm/ADT/APSInt.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/Bitset.h"#include "llvm/ADT/STLFunctionalExtras.h"#include "llvm/ADT/SmallBitVector.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/ADT/StringExtras.h"#include "llvm/Analysis/AliasAnalysis.h"#include "llvm/Analysis/AssumeBundleQueries.h"#include "llvm/Analysis/AssumptionCache.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Analysis/Loads.h"#include "llvm/Analysis/MemoryBuiltins.h"#include "llvm/Analysis/ValueTracking.h"#include "llvm/Analysis/VectorUtils.h"#include "llvm/IR/AttributeMask.h"#include "llvm/IR/Attributes.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/BundleAttributes.h"#include "llvm/IR/Constant.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/DebugInfo.h"#include "llvm/IR/DerivedTypes.h"#include "llvm/IR/Function.h"#include "llvm/IR/GlobalVariable.h"#include "llvm/IR/InlineAsm.h"#include "llvm/IR/InstrTypes.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Intrinsics.h"#include "llvm/IR/IntrinsicsAArch64.h"#include "llvm/IR/IntrinsicsAMDGPU.h"#include "llvm/IR/IntrinsicsARM.h"#include "llvm/IR/IntrinsicsHexagon.h"#include "llvm/IR/LLVMContext.h"#include "llvm/IR/Metadata.h"#include "llvm/IR/PatternMatch.h"#include "llvm/IR/ProfDataUtils.h"#include "llvm/IR/Statepoint.h"#include "llvm/IR/Type.h"#include "llvm/IR/User.h"#include "llvm/IR/Value.h"#include "llvm/IR/ValueHandle.h"#include "llvm/Support/AtomicOrdering.h"#include "llvm/Support/Casting.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Compiler.h"#include "llvm/Support/Debug.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/KnownBits.h"#include "llvm/Support/KnownFPClass.h"#include "llvm/Support/MathExtras.h"#include "llvm/Support/TypeSize.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/InstCombine/InstCombiner.h"#include "llvm/Transforms/Utils/AssumeBundleBuilder.h"#include "llvm/Transforms/Utils/Local.h"#include "llvm/Transforms/Utils/SimplifyLibCalls.h"#include <algorithm>#include <cassert>#include <cstdint>#include <optional>#include <utility>#include <vector>#include "llvm/Transforms/Utils/InstructionWorklist.h"Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "instcombine" |
Functions | |
| STATISTIC (NumSimplified, "Number of library calls simplified") | |
| static Type * | getPromotedType (Type *Ty) |
| Return the specified type promoted as it would be to pass though a va_arg area. | |
| static bool | hasUndefSource (AnyMemTransferInst *MI) |
| Recognize a memcpy/memmove from a trivially otherwise unused alloca. | |
| static Instruction * | simplifyInvariantGroupIntrinsic (IntrinsicInst &II, InstCombinerImpl &IC) |
| This function transforms launder.invariant.group and strip.invariant.group like: launder(launder(x)) -> launder(x) (the result is not the argument) launder(strip(x)) -> launder(x) strip(strip(x)) -> strip(x) (the result is not the argument) strip(launder(x)) -> strip(x) This is legal because it preserves the most recent information about the presence or absence of invariant.group. | |
| static Instruction * | foldCttzCtlz (IntrinsicInst &II, InstCombinerImpl &IC) |
| static Instruction * | foldCtpop (IntrinsicInst &II, InstCombinerImpl &IC) |
| static Instruction * | simplifyNeonTbl (IntrinsicInst &II, InstCombiner &IC, bool IsExtension) |
| Convert tbl/tbx intrinsics to shufflevector if the mask is constant, and at most two source operands are actually referenced. | |
| static bool | haveSameOperands (const IntrinsicInst &I, const IntrinsicInst &E, unsigned NumOperands) |
| static bool | removeTriviallyEmptyRange (IntrinsicInst &EndI, InstCombinerImpl &IC, std::function< bool(const IntrinsicInst &)> IsStart) |
| static CallInst * | canonicalizeConstantArg0ToArg1 (CallInst &Call) |
| static Instruction * | createOverflowTuple (IntrinsicInst *II, Value *Result, Constant *Overflow) |
Creates a result tuple for an overflow intrinsic II with a given Result and a constant Overflow value. | |
| static bool | inputDenormalIsIEEE (const Function &F, const Type *Ty) |
| static bool | inputDenormalIsDAZ (const Function &F, const Type *Ty) |
| static FCmpInst::Predicate | fpclassTestIsFCmp0 (FPClassTest Mask, const Function &F, Type *Ty) |
| static std::optional< bool > | getKnownSign (Value *Op, const SimplifyQuery &SQ) |
| static std::optional< bool > | getKnownSignOrZero (Value *Op, const SimplifyQuery &SQ) |
| static bool | signBitMustBeTheSame (Value *Op0, Value *Op1, const SimplifyQuery &SQ) |
Return true if two values Op0 and Op1 are known to have the same sign. | |
| static bool | ldexpSaturatingAddIsSafe (Type *FpTy, Type *ExpTy) |
| static Instruction * | moveAddAfterMinMax (IntrinsicInst *II, InstCombiner::BuilderTy &Builder) |
| Try to canonicalize min/max(X + C0, C1) as min/max(X, C1 - C0) + C0. | |
| static Instruction * | foldClampRangeOfTwo (IntrinsicInst *II, InstCombiner::BuilderTy &Builder) |
| If we have a clamp pattern like max (min X, 42), 41 – where the output can only be one of two possible constant values – turn that into a select of constants. | |
| static Value * | reassociateMinMaxWithConstants (IntrinsicInst *II, IRBuilderBase &Builder, const SimplifyQuery &SQ) |
| If this min/max has a constant operand and an operand that is a matching min/max with a constant operand, constant-fold the 2 constant operands. | |
| static Instruction * | reassociateMinMaxWithConstantInOperand (IntrinsicInst *II, InstCombiner::BuilderTy &Builder) |
| If this min/max has a matching min/max operand with a constant, try to push the constant operand into this instruction. | |
| static Instruction * | factorizeMinMaxTree (IntrinsicInst *II) |
| Reduce a sequence of min/max intrinsics with a common operand. | |
| template<Intrinsic::ID IntrID> | |
| static Instruction * | foldBitOrderCrossLogicOp (Value *V, InstCombiner::BuilderTy &Builder) |
| Fold the following cases and accepts bswap and bitreverse intrinsics: bswap(logic_op(bswap(x), y)) --> logic_op(x, bswap(y)) bswap(logic_op(bswap(x), bswap(y))) --> logic_op(x, y) (ignores multiuse) | |
| static bool | isIdempotentBinaryIntrinsic (Intrinsic::ID IID) |
| Helper to match idempotent binary intrinsics, namely, intrinsics where f(f(x, y), y) == f(x, y) holds. | |
| static Value * | foldIdempotentBinaryIntrinsicRecurrence (InstCombinerImpl &IC, IntrinsicInst *II) |
| Attempt to simplify value-accumulating recurrences of kind: umax.acc = phi i8 [ umax, backedge ], [ a, entry ] umax = call i8 @llvm.umax.i8(i8 umax.acc, i8 b) And let the idempotent binary intrinsic be hoisted, when the operands are known to be loop-invariant. | |
| static Value * | simplifyReductionOperand (Value *Arg, bool CanReorderLanes) |
| template<Intrinsic::ID IntrID> | |
| static Value * | foldMinimumOverTrailingOrLeadingZeroCount (Value *I0, Value *I1, const DataLayout &DL, InstCombiner::BuilderTy &Builder) |
| Fold an unsigned minimum of trailing or leading zero bits counts: umin(cttz(CtOp1, ZeroUndef), ConstOp) --> cttz(CtOp1 | (1 << ConstOp)) umin(ctlz(CtOp1, ZeroUndef), ConstOp) --> ctlz(CtOp1 | (SignedMin >> ConstOp)) umin(cttz(CtOp1), cttz(CtOp2)) --> cttz(CtOp1 | CtOp2) umin(ctlz(CtOp1), ctlz(CtOp2)) --> ctlz(CtOp1 | CtOp2) | |
| static bool | leftDistributesOverRight (Instruction::BinaryOps LOp, bool HasNUW, bool HasNSW, Intrinsic::ID ROp) |
| Return whether "X LOp (Y ROp Z)" is always equal to "(X LOp Y) ROp (X LOp Z)". | |
| static bool | rightDistributesOverLeft (Instruction::BinaryOps LOp, bool HasNUW, bool HasNSW, Intrinsic::ID ROp) |
| Return whether "(X ROp Y) LOp Z" is always equal to "(X LOp Z) ROp (Y LOp Z)". | |
| static Value * | foldIntrinsicUsingDistributiveLaws (IntrinsicInst *II, InstCombiner::BuilderTy &Builder) |
| static Instruction * | foldNeonShift (IntrinsicInst *II, InstCombinerImpl &IC) |
| static Bitset< 256 > | parseFormatStringSpecifiers (StringRef FormatStr) |
| static bool | isAspectNeeded (StringRef Aspect, CallInst *CI, unsigned FirstArgIdx, const std::optional< Bitset< 256 > > &Specifiers) |
| static void | referenceAspect (StringRef Aspect, StringRef ImplName, Module *M, IRBuilderBase &B) |
| static Value * | optimizeModularFormat (CallInst *CI, IRBuilderBase &B) |
| static IntrinsicInst * | findInitTrampolineFromAlloca (Value *TrampMem) |
| static IntrinsicInst * | findInitTrampolineFromBB (IntrinsicInst *AdjustTramp, Value *TrampMem) |
| static IntrinsicInst * | findInitTrampoline (Value *Callee) |
Variables | |
| static cl::opt< unsigned > | GuardWideningWindow ("instcombine-guard-widening-window", cl::init(3), cl::desc("How wide an instruction window to bypass looking for " "another guard")) |
| #define DEBUG_TYPE "instcombine" |
Definition at line 84 of file InstCombineCalls.cpp.
Definition at line 920 of file InstCombineCalls.cpp.
References assert(), Call, and llvm::isa().
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
Creates a result tuple for an overflow intrinsic II with a given Result and a constant Overflow value.
Definition at line 933 of file InstCombineCalls.cpp.
References llvm::cast(), llvm::InsertValueInst::Create(), llvm::ConstantStruct::get(), llvm::PoisonValue::get(), and II.
|
static |
Reduce a sequence of min/max intrinsics with a common operand.
Definition at line 1455 of file InstCombineCalls.cpp.
References A(), assert(), B(), llvm::CallingConv::C, llvm::CallInst::Create(), D(), llvm::dyn_cast(), llvm::Intrinsic::getOrInsertDeclaration(), II, LHS, Mod, and RHS.
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
Definition at line 4654 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), findInitTrampolineFromAlloca(), findInitTrampolineFromBB(), llvm::IntrinsicInst::getIntrinsicID(), llvm::User::getOperand(), and IT.
|
static |
Definition at line 4594 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), llvm::User::getOperand(), II, llvm::isa(), llvm::Value::stripPointerCasts(), and llvm::Value::users().
Referenced by findInitTrampoline().
|
static |
Definition at line 4633 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), E(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), I, II, and llvm::Instruction::mayWriteToMemory().
Referenced by findInitTrampoline().
|
static |
Fold the following cases and accepts bswap and bitreverse intrinsics: bswap(logic_op(bswap(x), y)) --> logic_op(x, bswap(y)) bswap(logic_op(bswap(x), bswap(y))) --> logic_op(x, y) (ignores multiuse)
Definition at line 1613 of file InstCombineCalls.cpp.
References llvm::cast(), llvm::BinaryOperator::Create(), llvm::isa(), llvm::PatternMatch::m_BitwiseLogic(), llvm::PatternMatch::m_Intrinsic(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), X, and Y.
|
static |
If we have a clamp pattern like max (min X, 42), 41 – where the output can only be one of two possible constant values – turn that into a select of constants.
Definition at line 1353 of file InstCombineCalls.cpp.
References llvm::CmpInst::BAD_ICMP_PREDICATE, llvm::SelectInst::Create(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, II, llvm_unreachable, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_SMax(), llvm::PatternMatch::m_SMin(), llvm::PatternMatch::m_UMax(), llvm::PatternMatch::m_UMin(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and X.
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
Definition at line 657 of file InstCombineCalls.cpp.
References assert(), llvm::BitWidth, llvm::InstCombiner::Builder, llvm::InstCombiner::computeKnownBits(), llvm::ConstantRange::contains(), llvm::KnownBits::countMaxPopulation(), llvm::KnownBits::countMinPopulation(), llvm::CallInst::Create(), llvm::CastInst::Create(), llvm::IRBuilderBase::CreateICmp(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateSub(), llvm::IRBuilderBase::CreateUnaryIntrinsic(), F, llvm::IRBuilderBase::getFalse(), llvm::Constant::getNullValue(), llvm::Intrinsic::getOrInsertDeclaration(), llvm::InstCombiner::getSimplifyQuery(), llvm::SimplifyQuery::getWithInstruction(), llvm::APInt::getZero(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_NE, II, llvm::isKnownNonZero(), llvm::InstCombiner::isKnownToBeAPowerOfTwo(), llvm::Lower, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_BitReverse(), llvm::PatternMatch::m_BSwap(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_FShl(), llvm::PatternMatch::m_FShr(), llvm::MIPatternMatch::m_Neg(), llvm::MIPatternMatch::m_Not(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), Range, llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), llvm::ConstantRange::Unsigned, llvm::Upper, X, Y, and llvm::KnownBits::Zero.
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
Definition at line 481 of file InstCombineCalls.cpp.
References assert(), llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::InstCombiner::computeKnownBits(), llvm::KnownBits::countMaxLeadingZeros(), llvm::KnownBits::countMaxTrailingZeros(), llvm::KnownBits::countMinLeadingZeros(), llvm::KnownBits::countMinTrailingZeros(), llvm::CallInst::Create(), llvm::IRBuilderBase::CreateBinaryIntrinsic(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::BinaryOperator::CreateNot(), llvm::IRBuilderBase::CreateSub(), llvm::IRBuilderBase::CreateZExt(), F, llvm::SelectPatternResult::Flavor, llvm::IRBuilderBase::getFalse(), llvm::Constant::getNullValue(), llvm::Intrinsic::getOrInsertDeclaration(), llvm::Type::getScalarSizeInBits(), llvm::InstCombiner::getSimplifyQuery(), llvm::IRBuilderBase::getTrue(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::Value::hasOneUse(), II, llvm::isKnownNonZero(), llvm::APInt::isZero(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_BitReverse(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_Exact(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_Intrinsic(), llvm::PatternMatch::m_LShr(), llvm::MIPatternMatch::m_Neg(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_NUWShl(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shift(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::matchSelectPattern(), llvm::KnownBits::One, Range, llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), llvm::Instruction::setHasNoSignedWrap(), llvm::Instruction::setHasNoUnsignedWrap(), llvm::SPF_ABS, llvm::SPF_NABS, llvm::InstCombinerImpl::tryGetLog2(), X, and Y.
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
Attempt to simplify value-accumulating recurrences of kind: umax.acc = phi i8 [ umax, backedge ], [ a, entry ] umax = call i8 @llvm.umax.i8(i8 umax.acc, i8 b) And let the idempotent binary intrinsic be hoisted, when the operands are known to be loop-invariant.
Definition at line 1673 of file InstCombineCalls.cpp.
References llvm::InstCombiner::Builder, llvm::cast(), llvm::IRBuilderBase::CreateBinaryIntrinsic(), llvm::DominatorTree::dominates(), llvm::InstCombiner::getDominatorTree(), II, llvm::isa(), isIdempotentBinaryIntrinsic(), and llvm::matchSimpleBinaryIntrinsicRecurrence().
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
Definition at line 1807 of file InstCombineCalls.cpp.
References A(), B(), llvm::CallingConv::C, llvm::cast(), D(), llvm::dyn_cast(), llvm::Operator::getOpcode(), llvm::User::getOperand(), llvm::OverflowingBinaryOperator::hasNoSignedWrap(), llvm::OverflowingBinaryOperator::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), II, llvm::OverflowingBinaryOperator::isCommutative(), leftDistributesOverRight(), LHS, RHS, rightDistributesOverLeft(), llvm::Instruction::setHasNoSignedWrap(), llvm::Instruction::setHasNoUnsignedWrap(), and std::swap().
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
Fold an unsigned minimum of trailing or leading zero bits counts: umin(cttz(CtOp1, ZeroUndef), ConstOp) --> cttz(CtOp1 | (1 << ConstOp)) umin(ctlz(CtOp1, ZeroUndef), ConstOp) --> ctlz(CtOp1 | (SignedMin >> ConstOp)) umin(cttz(CtOp1), cttz(CtOp2)) --> cttz(CtOp1 | CtOp2) umin(ctlz(CtOp1), ctlz(CtOp2)) --> ctlz(CtOp1 | CtOp2)
Definition at line 1728 of file InstCombineCalls.cpp.
References llvm::BitWidth, llvm::CallingConv::C, llvm::cast(), llvm::ConstantFoldBinaryOpOperands(), DL, llvm::APInt::getSignedMinValue(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::PatternMatch::m_CheckedInt(), llvm::PatternMatch::m_Intrinsic(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
Definition at line 1864 of file InstCombineCalls.cpp.
References B(), llvm::InstCombiner::Builder, llvm::CallingConv::C, Check, llvm::dyn_cast(), llvm::dyn_cast_or_null(), E(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), I, II, and llvm::InstCombiner::replaceInstUsesWith().
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
Mask) is equivalent to fcmp o__ x, 0.0 with the floating-point environment assumed for F for type Ty Definition at line 994 of file InstCombineCalls.cpp.
References llvm::CmpInst::BAD_FCMP_PREDICATE, F, llvm::CmpInst::FCMP_OEQ, llvm::CmpInst::FCMP_OGE, llvm::CmpInst::FCMP_OGT, llvm::CmpInst::FCMP_OLE, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::FCMP_ONE, llvm::fcNan, llvm::fcNegative, llvm::fcNegInf, llvm::fcNegNormal, llvm::fcNegSubnormal, llvm::fcNegZero, llvm::fcPosInf, llvm::fcPositive, llvm::fcPosNormal, llvm::fcPosSubnormal, llvm::fcPosZero, llvm::fcSubnormal, llvm::fcZero, inputDenormalIsDAZ(), and inputDenormalIsIEEE().
|
static |
Definition at line 1193 of file InstCombineCalls.cpp.
References llvm::computeKnownBits(), llvm::SimplifyQuery::CxtI, llvm::SimplifyQuery::DL, llvm::CmpInst::ICMP_SLT, llvm::isImpliedByDomCondition(), llvm::KnownBits::isNegative(), llvm::KnownBits::isNonNegative(), llvm::PatternMatch::m_NSWSub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), X, and Y.
Referenced by getKnownSignOrZero(), signBitMustBeTheSame(), and llvm::InstCombinerImpl::visitCallInst().
|
static |
Definition at line 1207 of file InstCombineCalls.cpp.
References llvm::SimplifyQuery::CxtI, llvm::SimplifyQuery::DL, getKnownSign(), llvm::CmpInst::ICMP_SLE, llvm::isImpliedByDomCondition(), llvm::PatternMatch::m_NSWSub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), X, and Y.
Referenced by llvm::InstCombinerImpl::visitCallInst().
Return the specified type promoted as it would be to pass though a va_arg area.
Definition at line 100 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), and llvm::Type::getInt32Ty().
|
static |
Recognize a memcpy/memmove from a trivially otherwise unused alloca.
TODO: This should probably be integrated with visitAllocSites, but that requires a deeper change to allow either unread or unwritten objects.
Definition at line 111 of file InstCombineCalls.cpp.
References llvm::cast(), llvm::isa(), and MI.
Referenced by llvm::InstCombinerImpl::SimplifyAnyMemTransfer().
|
static |
Definition at line 862 of file InstCombineCalls.cpp.
References assert(), E(), and I.
Referenced by removeTriviallyEmptyRange().
Definition at line 986 of file InstCombineCalls.cpp.
References F.
Referenced by fpclassTestIsFCmp0().
Definition at line 981 of file InstCombineCalls.cpp.
References F, and llvm::DenormalMode::IEEE.
|
static |
Definition at line 4463 of file InstCombineCalls.cpp.
References llvm::Bitset< NumBits >::any(), llvm::any_of(), llvm::CallBase::arg_begin(), llvm::CallBase::arg_end(), and llvm::make_range().
Referenced by optimizeModularFormat().
|
static |
Helper to match idempotent binary intrinsics, namely, intrinsics where f(f(x, y), y) == f(x, y) holds.
Definition at line 1650 of file InstCombineCalls.cpp.
Referenced by foldIdempotentBinaryIntrinsicRecurrence().
Definition at line 1235 of file InstCombineCalls.cpp.
References llvm::Type::getFltSemantics(), llvm::APFloat::getLargest(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::APFloat::getSmallest(), llvm::APFloat::isInfinity(), llvm::APFloat::isZero(), llvm::maxIntN(), llvm::minIntN(), llvm::APFloatBase::rmNearestTiesToEven, llvm::scalbn(), and llvm::APFloatBase::semanticsHasInf().
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
Return whether "X LOp (Y ROp Z)" is always equal to "(X LOp Y) ROp (X LOp Z)".
Definition at line 1767 of file InstCombineCalls.cpp.
Referenced by foldIntrinsicUsingDistributiveLaws(), llvm::InstCombinerImpl::foldUsingDistributiveLaws(), rightDistributesOverLeft(), rightDistributesOverLeft(), and tryFactorization().
|
static |
Try to canonicalize min/max(X + C0, C1) as min/max(X, C1 - C0) + C0.
This can trigger other combines.
Definition at line 1254 of file InstCombineCalls.cpp.
References llvm::Add, assert(), llvm::cast(), II, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_APInt(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::APInt::ssub_ov(), llvm::APInt::usub_ov(), and X.
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
Definition at line 4501 of file InstCombineCalls.cpp.
References llvm::ArrayRef(), assert(), B(), llvm::cast(), llvm::Instruction::clone(), llvm::ArrayRef< T >::drop_front(), llvm::ArrayRef< T >::empty(), llvm::CallBase::getArgOperand(), llvm::StringRef::getAsInteger(), llvm::CallBase::getCalledFunction(), llvm::getConstantStringInfo(), llvm::CallBase::getFnAttr(), llvm::Instruction::getModule(), llvm::Attribute::getValueAsString(), llvm::CallBase::hasFnAttr(), isAspectNeeded(), parseFormatStringSpecifiers(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), referenceAspect(), llvm::ArrayRef< T >::size(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::sort(), and llvm::split().
Definition at line 4439 of file InstCombineCalls.cpp.
References llvm::StringRef::find_first_not_of(), I, llvm::StringRef::npos, llvm::Bitset< NumBits >::set(), and llvm::StringRef::size().
Referenced by optimizeModularFormat().
|
static |
If this min/max has a matching min/max operand with a constant, try to push the constant operand into this instruction.
This can enable more folds.
Definition at line 1427 of file InstCombineCalls.cpp.
References llvm::CallingConv::C, llvm::CallInst::Create(), llvm::dyn_cast(), llvm::Intrinsic::getOrInsertDeclaration(), II, llvm::PatternMatch::m_c_MaxOrMin(), llvm::PatternMatchHelpers::m_CombineAnd(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_MaxOrMin(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::Value::takeName(), X, and Y.
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
If this min/max has a constant operand and an operand that is a matching min/max with a constant operand, constant-fold the 2 constant operands.
Definition at line 1393 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), llvm::MinMaxIntrinsic::getPredicate(), II, llvm::isKnownNonNegative(), LHS, llvm::PatternMatch::m_ImmConstant(), and llvm::PatternMatch::match().
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
Definition at line 4489 of file InstCombineCalls.cpp.
References B(), llvm::MDString::get(), llvm::MetadataAsValue::get(), and llvm::Intrinsic::getOrInsertDeclaration().
Referenced by optimizeModularFormat().
|
static |
Definition at line 882 of file InstCombineCalls.cpp.
References llvm::CallBase::arg_size(), llvm::dyn_cast(), llvm::InstCombinerImpl::eraseInstFromFunction(), llvm::IntrinsicInst::getIntrinsicID(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), haveSameOperands(), and I.
Referenced by llvm::InstCombinerImpl::visitCallInst(), and llvm::InstCombinerImpl::visitVAEndInst().
|
static |
Return whether "(X ROp Y) LOp Z" is always equal to "(X LOp Z) ROp (Y LOp Z)".
Definition at line 1787 of file InstCombineCalls.cpp.
References llvm::Instruction::isCommutative(), and leftDistributesOverRight().
Referenced by foldIntrinsicUsingDistributiveLaws(), llvm::InstCombinerImpl::foldUsingDistributiveLaws(), and tryFactorization().
|
static |
Return true if two values Op0 and Op1 are known to have the same sign.
Definition at line 1220 of file InstCombineCalls.cpp.
References getKnownSign().
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
This function transforms launder.invariant.group and strip.invariant.group like: launder(launder(x)) -> launder(x) (the result is not the argument) launder(strip(x)) -> launder(x) strip(strip(x)) -> strip(x) (the result is not the argument) strip(launder(x)) -> strip(x) This is legal because it preserves the most recent information about the presence or absence of invariant.group.
Definition at line 451 of file InstCombineCalls.cpp.
References llvm::InstCombiner::Builder, llvm::cast(), llvm::IRBuilderBase::CreateAddrSpaceCast(), llvm::IRBuilderBase::CreateLaunderInvariantGroup(), llvm::IRBuilderBase::CreateStripInvariantGroup(), llvm::dyn_cast(), II, and llvm_unreachable.
Referenced by llvm::InstCombinerImpl::visitCallInst().
|
static |
Convert tbl/tbx intrinsics to shufflevector if the mask is constant, and at most two source operands are actually referenced.
Definition at line 747 of file InstCombineCalls.cpp.
References llvm::ArrayRef(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::cast(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::contains(), llvm::IRBuilderBase::CreateShuffleVector(), llvm::dyn_cast(), llvm::PoisonValue::get(), llvm::Constant::getNullValue(), llvm::Value::getType(), I, II, llvm::isa(), llvm::InstCombiner::replaceInstUsesWith(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::size(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::try_emplace().
Referenced by llvm::InstCombinerImpl::visitCallInst().
Definition at line 1693 of file InstCombineCalls.cpp.
References llvm::SmallBitVector::all(), llvm::cast(), llvm::Value::getType(), llvm::isa(), llvm::PatternMatch::m_Shuffle(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_VecReverse(), llvm::PatternMatch::match(), llvm::PoisonMaskElem, llvm::SmallBitVector::set(), and llvm::SmallBitVector::test().
Referenced by llvm::InstCombinerImpl::visitCallInst().
| STATISTIC | ( | NumSimplified | , |
| "Number of library calls simplified" | ) |
|
static |
Referenced by llvm::InstCombinerImpl::visitCallInst().