2013-05-17 21:43:39 +00:00
|
|
|
//===- InstCombine.h - Main InstCombine pass definition ---------*- C++ -*-===//
|
2010-01-04 07:12:23 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_LIB_TRANSFORMS_INSTCOMBINE_INSTCOMBINE_H
|
|
|
|
#define LLVM_LIB_TRANSFORMS_INSTCOMBINE_INSTCOMBINE_H
|
2010-01-04 07:12:23 +00:00
|
|
|
|
|
|
|
#include "InstCombineWorklist.h"
|
2014-09-07 12:44:26 +00:00
|
|
|
#include "llvm/Analysis/AssumptionTracker.h"
|
2014-03-04 11:59:06 +00:00
|
|
|
#include "llvm/Analysis/TargetFolder.h"
|
2012-12-04 07:12:27 +00:00
|
|
|
#include "llvm/Analysis/ValueTracking.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/IRBuilder.h"
|
2014-03-06 03:23:41 +00:00
|
|
|
#include "llvm/IR/InstVisitor.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/IntrinsicInst.h"
|
|
|
|
#include "llvm/IR/Operator.h"
|
2014-09-07 12:44:26 +00:00
|
|
|
#include "llvm/IR/PatternMatch.h"
|
2010-01-04 07:12:23 +00:00
|
|
|
#include "llvm/Pass.h"
|
2012-10-13 16:45:24 +00:00
|
|
|
#include "llvm/Transforms/Utils/SimplifyLibCalls.h"
|
2010-01-04 07:12:23 +00:00
|
|
|
|
2014-04-22 02:55:47 +00:00
|
|
|
#define DEBUG_TYPE "instcombine"
|
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
namespace llvm {
|
2014-05-07 17:36:59 +00:00
|
|
|
class CallSite;
|
|
|
|
class DataLayout;
|
Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.)
This change, which allows @llvm.assume to be used from within computeKnownBits
(and other associated functions in ValueTracking), adds some (optional)
parameters to computeKnownBits and friends. These functions now (optionally)
take a "context" instruction pointer, an AssumptionTracker pointer, and also a
DomTree pointer, and most of the changes are just to pass this new information
when it is easily available from InstSimplify, InstCombine, etc.
As explained below, the significant conceptual change is that known properties
of a value might depend on the control-flow location of the use (because we
care that the @llvm.assume dominates the use because assumptions have
control-flow dependencies). This means that, when we ask if bits are known in a
value, we might get different answers for different uses.
The significant changes are all in ValueTracking. Two main changes: First, as
with the rest of the code, new parameters need to be passed around. To make
this easier, I grouped them into a structure, and I made internal static
versions of the relevant functions that take this structure as a parameter. The
new code does as you might expect, it looks for @llvm.assume calls that make
use of the value we're trying to learn something about (often indirectly),
attempts to pattern match that expression, and uses the result if successful.
By making use of the AssumptionTracker, the process of finding @llvm.assume
calls is not expensive.
Part of the structure being passed around inside ValueTracking is a set of
already-considered @llvm.assume calls. This is to prevent a query using, for
example, the assume(a == b), to recurse on itself. The context and DT params
are used to find applicable assumptions. An assumption needs to dominate the
context instruction, or come after it deterministically. In this latter case we
only handle the specific case where both the assumption and the context
instruction are in the same block, and we need to exclude assumptions from
being used to simplify their own ephemeral values (those which contribute only
to the assumption) because otherwise the assumption would prove its feeding
comparison trivial and would be removed.
This commit adds the plumbing and the logic for a simple masked-bit propagation
(just enough to write a regression test). Future commits add more patterns
(and, correspondingly, more regression tests).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217342 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 18:57:58 +00:00
|
|
|
class DominatorTree;
|
2014-05-07 17:36:59 +00:00
|
|
|
class TargetLibraryInfo;
|
|
|
|
class DbgDeclareInst;
|
|
|
|
class MemIntrinsic;
|
|
|
|
class MemSetInst;
|
2013-01-14 23:16:36 +00:00
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
/// SelectPatternFlavor - We can match a variety of different patterns for
|
|
|
|
/// select operations.
|
|
|
|
enum SelectPatternFlavor {
|
|
|
|
SPF_UNKNOWN = 0,
|
2014-05-07 17:36:59 +00:00
|
|
|
SPF_SMIN,
|
|
|
|
SPF_UMIN,
|
|
|
|
SPF_SMAX,
|
2014-06-06 06:54:45 +00:00
|
|
|
SPF_UMAX,
|
|
|
|
SPF_ABS,
|
|
|
|
SPF_NABS
|
2010-01-04 07:12:23 +00:00
|
|
|
};
|
2013-01-14 23:16:36 +00:00
|
|
|
|
2010-01-04 07:37:31 +00:00
|
|
|
/// getComplexity: Assign a complexity or rank value to LLVM Values...
|
|
|
|
/// 0 -> undef, 1 -> Const, 2 -> Other, 3 -> Arg, 3 -> Unary, 4 -> OtherInst
|
|
|
|
static inline unsigned getComplexity(Value *V) {
|
|
|
|
if (isa<Instruction>(V)) {
|
2014-05-07 17:36:59 +00:00
|
|
|
if (BinaryOperator::isNeg(V) || BinaryOperator::isFNeg(V) ||
|
2010-01-04 07:37:31 +00:00
|
|
|
BinaryOperator::isNot(V))
|
|
|
|
return 3;
|
|
|
|
return 4;
|
|
|
|
}
|
2014-05-07 17:36:59 +00:00
|
|
|
if (isa<Argument>(V))
|
|
|
|
return 3;
|
2010-01-04 07:37:31 +00:00
|
|
|
return isa<Constant>(V) ? (isa<UndefValue>(V) ? 0 : 1) : 2;
|
|
|
|
}
|
2010-01-04 07:12:23 +00:00
|
|
|
|
2014-01-19 16:56:10 +00:00
|
|
|
/// AddOne - Add one to a Constant
|
|
|
|
static inline Constant *AddOne(Constant *C) {
|
|
|
|
return ConstantExpr::getAdd(C, ConstantInt::get(C->getType(), 1));
|
|
|
|
}
|
|
|
|
/// SubOne - Subtract one from a Constant
|
|
|
|
static inline Constant *SubOne(Constant *C) {
|
|
|
|
return ConstantExpr::getSub(C, ConstantInt::get(C->getType(), 1));
|
|
|
|
}
|
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
/// InstCombineIRInserter - This is an IRBuilder insertion helper that works
|
|
|
|
/// just like the normal insertion helper, but also adds any new instructions
|
|
|
|
/// to the instcombine worklist.
|
2013-01-14 23:16:36 +00:00
|
|
|
class LLVM_LIBRARY_VISIBILITY InstCombineIRInserter
|
2010-01-04 07:12:23 +00:00
|
|
|
: public IRBuilderDefaultInserter<true> {
|
|
|
|
InstCombineWorklist &Worklist;
|
2014-09-07 12:44:26 +00:00
|
|
|
AssumptionTracker *AT;
|
2014-05-07 17:36:59 +00:00
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
public:
|
2014-09-07 12:44:26 +00:00
|
|
|
InstCombineIRInserter(InstCombineWorklist &WL, AssumptionTracker *AT)
|
|
|
|
: Worklist(WL), AT(AT) {}
|
2013-01-14 23:16:36 +00:00
|
|
|
|
2014-05-07 17:36:59 +00:00
|
|
|
void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB,
|
|
|
|
BasicBlock::iterator InsertPt) const {
|
2010-01-04 07:12:23 +00:00
|
|
|
IRBuilderDefaultInserter<true>::InsertHelper(I, Name, BB, InsertPt);
|
|
|
|
Worklist.Add(I);
|
2014-09-07 12:44:26 +00:00
|
|
|
|
|
|
|
using namespace llvm::PatternMatch;
|
|
|
|
if ((match(I, m_Intrinsic<Intrinsic::assume>(m_Value()))))
|
|
|
|
AT->registerAssumption(cast<CallInst>(I));
|
2010-01-04 07:12:23 +00:00
|
|
|
}
|
|
|
|
};
|
2013-01-14 23:16:36 +00:00
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
/// InstCombiner - The -instcombine pass.
|
2010-05-11 20:16:09 +00:00
|
|
|
class LLVM_LIBRARY_VISIBILITY InstCombiner
|
2014-05-07 17:36:59 +00:00
|
|
|
: public FunctionPass,
|
|
|
|
public InstVisitor<InstCombiner, Instruction *> {
|
2014-09-07 12:44:26 +00:00
|
|
|
AssumptionTracker *AT;
|
2014-02-24 23:12:18 +00:00
|
|
|
const DataLayout *DL;
|
2011-12-01 21:29:16 +00:00
|
|
|
TargetLibraryInfo *TLI;
|
2014-10-01 10:07:28 +00:00
|
|
|
DominatorTree *DT; // not required
|
2010-01-04 07:12:23 +00:00
|
|
|
bool MadeIRChange;
|
2012-10-13 16:45:24 +00:00
|
|
|
LibCallSimplifier *Simplifier;
|
2013-01-07 18:37:41 +00:00
|
|
|
bool MinimizeSize;
|
2014-05-07 17:36:59 +00:00
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
public:
|
|
|
|
/// Worklist - All of the instructions that need to be simplified.
|
|
|
|
InstCombineWorklist Worklist;
|
|
|
|
|
|
|
|
/// Builder - This is an IRBuilder that automatically inserts new
|
|
|
|
/// instructions into the worklist when they are created.
|
|
|
|
typedef IRBuilder<true, TargetFolder, InstCombineIRInserter> BuilderTy;
|
|
|
|
BuilderTy *Builder;
|
2013-01-14 23:16:36 +00:00
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
static char ID; // Pass identification, replacement for typeid
|
2014-10-01 10:07:28 +00:00
|
|
|
InstCombiner() : FunctionPass(ID), DL(nullptr), Builder(nullptr) {
|
2013-01-07 18:37:41 +00:00
|
|
|
MinimizeSize = false;
|
2010-10-19 17:21:58 +00:00
|
|
|
initializeInstCombinerPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
2010-01-04 07:12:23 +00:00
|
|
|
|
|
|
|
public:
|
2014-03-05 09:10:37 +00:00
|
|
|
bool runOnFunction(Function &F) override;
|
2013-01-14 23:16:36 +00:00
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
bool DoOneIteration(Function &F, unsigned ItNum);
|
|
|
|
|
2014-03-05 09:10:37 +00:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
2011-12-01 21:29:16 +00:00
|
|
|
|
2014-09-07 12:44:26 +00:00
|
|
|
AssumptionTracker *getAssumptionTracker() const { return AT; }
|
|
|
|
|
2014-02-24 23:12:18 +00:00
|
|
|
const DataLayout *getDataLayout() const { return DL; }
|
Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.)
This change, which allows @llvm.assume to be used from within computeKnownBits
(and other associated functions in ValueTracking), adds some (optional)
parameters to computeKnownBits and friends. These functions now (optionally)
take a "context" instruction pointer, an AssumptionTracker pointer, and also a
DomTree pointer, and most of the changes are just to pass this new information
when it is easily available from InstSimplify, InstCombine, etc.
As explained below, the significant conceptual change is that known properties
of a value might depend on the control-flow location of the use (because we
care that the @llvm.assume dominates the use because assumptions have
control-flow dependencies). This means that, when we ask if bits are known in a
value, we might get different answers for different uses.
The significant changes are all in ValueTracking. Two main changes: First, as
with the rest of the code, new parameters need to be passed around. To make
this easier, I grouped them into a structure, and I made internal static
versions of the relevant functions that take this structure as a parameter. The
new code does as you might expect, it looks for @llvm.assume calls that make
use of the value we're trying to learn something about (often indirectly),
attempts to pattern match that expression, and uses the result if successful.
By making use of the AssumptionTracker, the process of finding @llvm.assume
calls is not expensive.
Part of the structure being passed around inside ValueTracking is a set of
already-considered @llvm.assume calls. This is to prevent a query using, for
example, the assume(a == b), to recurse on itself. The context and DT params
are used to find applicable assumptions. An assumption needs to dominate the
context instruction, or come after it deterministically. In this latter case we
only handle the specific case where both the assumption and the context
instruction are in the same block, and we need to exclude assumptions from
being used to simplify their own ephemeral values (those which contribute only
to the assumption) because otherwise the assumption would prove its feeding
comparison trivial and would be removed.
This commit adds the plumbing and the logic for a simple masked-bit propagation
(just enough to write a regression test). Future commits add more patterns
(and, correspondingly, more regression tests).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217342 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 18:57:58 +00:00
|
|
|
|
|
|
|
DominatorTree *getDominatorTree() const { return DT; }
|
2010-01-04 07:12:23 +00:00
|
|
|
|
2011-12-02 01:26:24 +00:00
|
|
|
TargetLibraryInfo *getTargetLibraryInfo() const { return TLI; }
|
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
// Visitation implementation - Implement instruction combining for different
|
|
|
|
// instruction types. The semantics are as follows:
|
|
|
|
// Return Value:
|
|
|
|
// null - No change was made
|
|
|
|
// I - Change was made, I is still valid, I may be dead though
|
|
|
|
// otherwise - Change was made, replace I with returned instruction
|
|
|
|
//
|
|
|
|
Instruction *visitAdd(BinaryOperator &I);
|
|
|
|
Instruction *visitFAdd(BinaryOperator &I);
|
2011-07-18 04:54:35 +00:00
|
|
|
Value *OptimizePointerDifference(Value *LHS, Value *RHS, Type *Ty);
|
2010-01-04 07:12:23 +00:00
|
|
|
Instruction *visitSub(BinaryOperator &I);
|
|
|
|
Instruction *visitFSub(BinaryOperator &I);
|
|
|
|
Instruction *visitMul(BinaryOperator &I);
|
2014-01-19 13:36:27 +00:00
|
|
|
Value *foldFMulConst(Instruction *FMulOrDiv, Constant *C,
|
2013-01-07 21:39:23 +00:00
|
|
|
Instruction *InsertBefore);
|
2010-01-04 07:12:23 +00:00
|
|
|
Instruction *visitFMul(BinaryOperator &I);
|
|
|
|
Instruction *visitURem(BinaryOperator &I);
|
|
|
|
Instruction *visitSRem(BinaryOperator &I);
|
|
|
|
Instruction *visitFRem(BinaryOperator &I);
|
|
|
|
bool SimplifyDivRemOfSelect(BinaryOperator &I);
|
|
|
|
Instruction *commonRemTransforms(BinaryOperator &I);
|
|
|
|
Instruction *commonIRemTransforms(BinaryOperator &I);
|
|
|
|
Instruction *commonDivTransforms(BinaryOperator &I);
|
|
|
|
Instruction *commonIDivTransforms(BinaryOperator &I);
|
|
|
|
Instruction *visitUDiv(BinaryOperator &I);
|
|
|
|
Instruction *visitSDiv(BinaryOperator &I);
|
2011-01-29 17:50:27 +00:00
|
|
|
Instruction *visitFDiv(BinaryOperator &I);
|
2010-03-05 08:46:26 +00:00
|
|
|
Value *FoldAndOfICmps(ICmpInst *LHS, ICmpInst *RHS);
|
|
|
|
Value *FoldAndOfFCmps(FCmpInst *LHS, FCmpInst *RHS);
|
2010-01-04 07:12:23 +00:00
|
|
|
Instruction *visitAnd(BinaryOperator &I);
|
Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.)
This change, which allows @llvm.assume to be used from within computeKnownBits
(and other associated functions in ValueTracking), adds some (optional)
parameters to computeKnownBits and friends. These functions now (optionally)
take a "context" instruction pointer, an AssumptionTracker pointer, and also a
DomTree pointer, and most of the changes are just to pass this new information
when it is easily available from InstSimplify, InstCombine, etc.
As explained below, the significant conceptual change is that known properties
of a value might depend on the control-flow location of the use (because we
care that the @llvm.assume dominates the use because assumptions have
control-flow dependencies). This means that, when we ask if bits are known in a
value, we might get different answers for different uses.
The significant changes are all in ValueTracking. Two main changes: First, as
with the rest of the code, new parameters need to be passed around. To make
this easier, I grouped them into a structure, and I made internal static
versions of the relevant functions that take this structure as a parameter. The
new code does as you might expect, it looks for @llvm.assume calls that make
use of the value we're trying to learn something about (often indirectly),
attempts to pattern match that expression, and uses the result if successful.
By making use of the AssumptionTracker, the process of finding @llvm.assume
calls is not expensive.
Part of the structure being passed around inside ValueTracking is a set of
already-considered @llvm.assume calls. This is to prevent a query using, for
example, the assume(a == b), to recurse on itself. The context and DT params
are used to find applicable assumptions. An assumption needs to dominate the
context instruction, or come after it deterministically. In this latter case we
only handle the specific case where both the assumption and the context
instruction are in the same block, and we need to exclude assumptions from
being used to simplify their own ephemeral values (those which contribute only
to the assumption) because otherwise the assumption would prove its feeding
comparison trivial and would be removed.
This commit adds the plumbing and the logic for a simple masked-bit propagation
(just enough to write a regression test). Future commits add more patterns
(and, correspondingly, more regression tests).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217342 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 18:57:58 +00:00
|
|
|
Value *FoldOrOfICmps(ICmpInst *LHS, ICmpInst *RHS, Instruction *CxtI);
|
2010-03-05 08:46:26 +00:00
|
|
|
Value *FoldOrOfFCmps(FCmpInst *LHS, FCmpInst *RHS);
|
2014-05-07 17:36:59 +00:00
|
|
|
Instruction *FoldOrWithConstants(BinaryOperator &I, Value *Op, Value *A,
|
|
|
|
Value *B, Value *C);
|
2014-08-21 05:14:48 +00:00
|
|
|
Instruction *FoldXorWithConstants(BinaryOperator &I, Value *Op, Value *A,
|
|
|
|
Value *B, Value *C);
|
2014-05-07 17:36:59 +00:00
|
|
|
Instruction *visitOr(BinaryOperator &I);
|
2010-01-04 07:12:23 +00:00
|
|
|
Instruction *visitXor(BinaryOperator &I);
|
|
|
|
Instruction *visitShl(BinaryOperator &I);
|
|
|
|
Instruction *visitAShr(BinaryOperator &I);
|
|
|
|
Instruction *visitLShr(BinaryOperator &I);
|
|
|
|
Instruction *commonShiftTransforms(BinaryOperator &I);
|
|
|
|
Instruction *FoldFCmp_IntToFP_Cst(FCmpInst &I, Instruction *LHSI,
|
|
|
|
Constant *RHSC);
|
|
|
|
Instruction *FoldCmpLoadFromIndexedGlobal(GetElementPtrInst *GEP,
|
|
|
|
GlobalVariable *GV, CmpInst &ICI,
|
2014-04-28 04:05:08 +00:00
|
|
|
ConstantInt *AndCst = nullptr);
|
2010-01-04 07:12:23 +00:00
|
|
|
Instruction *visitFCmpInst(FCmpInst &I);
|
|
|
|
Instruction *visitICmpInst(ICmpInst &I);
|
|
|
|
Instruction *visitICmpInstWithCastAndCast(ICmpInst &ICI);
|
2014-05-07 17:36:59 +00:00
|
|
|
Instruction *visitICmpInstWithInstAndIntCst(ICmpInst &ICI, Instruction *LHS,
|
2010-01-04 07:12:23 +00:00
|
|
|
ConstantInt *RHS);
|
|
|
|
Instruction *FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI,
|
|
|
|
ConstantInt *DivRHS);
|
2011-02-13 07:43:07 +00:00
|
|
|
Instruction *FoldICmpShrCst(ICmpInst &ICI, BinaryOperator *DivI,
|
|
|
|
ConstantInt *DivRHS);
|
2014-07-22 19:19:36 +00:00
|
|
|
Instruction *FoldICmpCstShrCst(ICmpInst &I, Value *Op, Value *A,
|
|
|
|
ConstantInt *CI1, ConstantInt *CI2);
|
2013-09-20 22:12:42 +00:00
|
|
|
Instruction *FoldICmpAddOpCst(Instruction &ICI, Value *X, ConstantInt *CI,
|
|
|
|
ICmpInst::Predicate Pred);
|
2010-01-04 07:12:23 +00:00
|
|
|
Instruction *FoldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
|
|
|
|
ICmpInst::Predicate Cond, Instruction &I);
|
2014-04-14 21:50:37 +00:00
|
|
|
Instruction *FoldShiftByConstant(Value *Op0, Constant *Op1,
|
2010-01-04 07:12:23 +00:00
|
|
|
BinaryOperator &I);
|
|
|
|
Instruction *commonCastTransforms(CastInst &CI);
|
|
|
|
Instruction *commonPointerCastTransforms(CastInst &CI);
|
|
|
|
Instruction *visitTrunc(TruncInst &CI);
|
|
|
|
Instruction *visitZExt(ZExtInst &CI);
|
|
|
|
Instruction *visitSExt(SExtInst &CI);
|
|
|
|
Instruction *visitFPTrunc(FPTruncInst &CI);
|
|
|
|
Instruction *visitFPExt(CastInst &CI);
|
|
|
|
Instruction *visitFPToUI(FPToUIInst &FI);
|
|
|
|
Instruction *visitFPToSI(FPToSIInst &FI);
|
|
|
|
Instruction *visitUIToFP(CastInst &CI);
|
|
|
|
Instruction *visitSIToFP(CastInst &CI);
|
|
|
|
Instruction *visitPtrToInt(PtrToIntInst &CI);
|
|
|
|
Instruction *visitIntToPtr(IntToPtrInst &CI);
|
|
|
|
Instruction *visitBitCast(BitCastInst &CI);
|
2013-11-15 05:45:08 +00:00
|
|
|
Instruction *visitAddrSpaceCast(AddrSpaceCastInst &CI);
|
2014-05-07 17:36:59 +00:00
|
|
|
Instruction *FoldSelectOpOp(SelectInst &SI, Instruction *TI, Instruction *FI);
|
|
|
|
Instruction *FoldSelectIntoOp(SelectInst &SI, Value *, Value *);
|
2010-01-04 07:12:23 +00:00
|
|
|
Instruction *FoldSPFofSPF(Instruction *Inner, SelectPatternFlavor SPF1,
|
|
|
|
Value *A, Value *B, Instruction &Outer,
|
|
|
|
SelectPatternFlavor SPF2, Value *C);
|
|
|
|
Instruction *visitSelectInst(SelectInst &SI);
|
|
|
|
Instruction *visitSelectInstWithICmp(SelectInst &SI, ICmpInst *ICI);
|
|
|
|
Instruction *visitCallInst(CallInst &CI);
|
|
|
|
Instruction *visitInvokeInst(InvokeInst &II);
|
|
|
|
|
|
|
|
Instruction *SliceUpIllegalIntegerPHI(PHINode &PN);
|
|
|
|
Instruction *visitPHINode(PHINode &PN);
|
|
|
|
Instruction *visitGetElementPtrInst(GetElementPtrInst &GEP);
|
|
|
|
Instruction *visitAllocaInst(AllocaInst &AI);
|
2012-07-09 18:38:20 +00:00
|
|
|
Instruction *visitAllocSite(Instruction &FI);
|
2010-06-24 12:21:15 +00:00
|
|
|
Instruction *visitFree(CallInst &FI);
|
2010-01-04 07:12:23 +00:00
|
|
|
Instruction *visitLoadInst(LoadInst &LI);
|
|
|
|
Instruction *visitStoreInst(StoreInst &SI);
|
|
|
|
Instruction *visitBranchInst(BranchInst &BI);
|
|
|
|
Instruction *visitSwitchInst(SwitchInst &SI);
|
2014-09-07 21:28:34 +00:00
|
|
|
Instruction *visitReturnInst(ReturnInst &RI);
|
2014-05-07 14:30:18 +00:00
|
|
|
Instruction *visitInsertValueInst(InsertValueInst &IV);
|
2010-01-04 07:12:23 +00:00
|
|
|
Instruction *visitInsertElementInst(InsertElementInst &IE);
|
|
|
|
Instruction *visitExtractElementInst(ExtractElementInst &EI);
|
|
|
|
Instruction *visitShuffleVectorInst(ShuffleVectorInst &SVI);
|
|
|
|
Instruction *visitExtractValueInst(ExtractValueInst &EV);
|
2011-09-30 13:12:16 +00:00
|
|
|
Instruction *visitLandingPadInst(LandingPadInst &LI);
|
2010-01-04 07:12:23 +00:00
|
|
|
|
|
|
|
// visitInstruction - Specify what to return for unhandled instructions...
|
2014-04-28 04:05:08 +00:00
|
|
|
Instruction *visitInstruction(Instruction &I) { return nullptr; }
|
2010-01-04 07:12:23 +00:00
|
|
|
|
|
|
|
private:
|
2011-07-18 04:54:35 +00:00
|
|
|
bool ShouldChangeType(Type *From, Type *To) const;
|
2010-01-04 07:37:31 +00:00
|
|
|
Value *dyn_castNegVal(Value *V) const;
|
2014-05-07 17:36:59 +00:00
|
|
|
Value *dyn_castFNegVal(Value *V, bool NoSignedZero = false) const;
|
2013-08-19 22:17:40 +00:00
|
|
|
Type *FindElementAtOffset(Type *PtrTy, int64_t Offset,
|
2014-05-07 17:36:59 +00:00
|
|
|
SmallVectorImpl<Value *> &NewIndices);
|
2010-01-04 07:53:58 +00:00
|
|
|
Instruction *FoldOpIntoSelect(Instruction &Op, SelectInst *SI);
|
2013-01-14 23:16:36 +00:00
|
|
|
|
2010-02-11 06:26:33 +00:00
|
|
|
/// ShouldOptimizeCast - Return true if the cast from "V to Ty" actually
|
|
|
|
/// results in any code being generated and is interesting to optimize out. If
|
|
|
|
/// the cast can be eliminated by some other simple transformation, we prefer
|
|
|
|
/// to do the simplification first.
|
2014-05-07 17:36:59 +00:00
|
|
|
bool ShouldOptimizeCast(Instruction::CastOps opcode, const Value *V,
|
2011-07-18 04:54:35 +00:00
|
|
|
Type *Ty);
|
2010-01-04 07:37:31 +00:00
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
Instruction *visitCallSite(CallSite CS);
|
2014-02-21 00:06:31 +00:00
|
|
|
Instruction *tryOptimizeCall(CallInst *CI, const DataLayout *DL);
|
2010-01-04 07:12:23 +00:00
|
|
|
bool transformConstExprCastCall(CallSite CS);
|
2011-09-06 13:37:06 +00:00
|
|
|
Instruction *transformCallThroughTrampoline(CallSite CS,
|
|
|
|
IntrinsicInst *Tramp);
|
2010-01-04 07:12:23 +00:00
|
|
|
Instruction *transformZExtICmp(ICmpInst *ICI, Instruction &CI,
|
|
|
|
bool DoXform = true);
|
2011-04-01 20:09:03 +00:00
|
|
|
Instruction *transformSExtICmp(ICmpInst *ICI, Instruction &CI);
|
Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.)
This change, which allows @llvm.assume to be used from within computeKnownBits
(and other associated functions in ValueTracking), adds some (optional)
parameters to computeKnownBits and friends. These functions now (optionally)
take a "context" instruction pointer, an AssumptionTracker pointer, and also a
DomTree pointer, and most of the changes are just to pass this new information
when it is easily available from InstSimplify, InstCombine, etc.
As explained below, the significant conceptual change is that known properties
of a value might depend on the control-flow location of the use (because we
care that the @llvm.assume dominates the use because assumptions have
control-flow dependencies). This means that, when we ask if bits are known in a
value, we might get different answers for different uses.
The significant changes are all in ValueTracking. Two main changes: First, as
with the rest of the code, new parameters need to be passed around. To make
this easier, I grouped them into a structure, and I made internal static
versions of the relevant functions that take this structure as a parameter. The
new code does as you might expect, it looks for @llvm.assume calls that make
use of the value we're trying to learn something about (often indirectly),
attempts to pattern match that expression, and uses the result if successful.
By making use of the AssumptionTracker, the process of finding @llvm.assume
calls is not expensive.
Part of the structure being passed around inside ValueTracking is a set of
already-considered @llvm.assume calls. This is to prevent a query using, for
example, the assume(a == b), to recurse on itself. The context and DT params
are used to find applicable assumptions. An assumption needs to dominate the
context instruction, or come after it deterministically. In this latter case we
only handle the specific case where both the assumption and the context
instruction are in the same block, and we need to exclude assumptions from
being used to simplify their own ephemeral values (those which contribute only
to the assumption) because otherwise the assumption would prove its feeding
comparison trivial and would be removed.
This commit adds the plumbing and the logic for a simple masked-bit propagation
(just enough to write a regression test). Future commits add more patterns
(and, correspondingly, more regression tests).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217342 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 18:57:58 +00:00
|
|
|
bool WillNotOverflowSignedAdd(Value *LHS, Value *RHS, Instruction *CxtI);
|
|
|
|
bool WillNotOverflowUnsignedAdd(Value *LHS, Value *RHS, Instruction *CxtI);
|
|
|
|
bool WillNotOverflowSignedSub(Value *LHS, Value *RHS, Instruction *CxtI);
|
|
|
|
bool WillNotOverflowUnsignedSub(Value *LHS, Value *RHS, Instruction *CxtI);
|
2012-05-22 17:19:09 +00:00
|
|
|
Value *EmitGEPOffset(User *GEP);
|
2013-04-18 19:35:39 +00:00
|
|
|
Instruction *scalarizePHI(ExtractElementInst &EI, PHINode *PN);
|
2013-05-31 00:59:42 +00:00
|
|
|
Value *EvaluateInDifferentElementOrder(Value *V, ArrayRef<int> Mask);
|
2010-01-04 07:12:23 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// InsertNewInstBefore - insert an instruction New before instruction Old
|
|
|
|
// in the program. Add the new instruction to the worklist.
|
|
|
|
//
|
|
|
|
Instruction *InsertNewInstBefore(Instruction *New, Instruction &Old) {
|
2014-04-28 04:05:08 +00:00
|
|
|
assert(New && !New->getParent() &&
|
2010-01-04 07:12:23 +00:00
|
|
|
"New instruction already inserted into a basic block!");
|
|
|
|
BasicBlock *BB = Old.getParent();
|
2014-05-07 17:36:59 +00:00
|
|
|
BB->getInstList().insert(&Old, New); // Insert inst
|
2010-01-04 07:12:23 +00:00
|
|
|
Worklist.Add(New);
|
|
|
|
return New;
|
|
|
|
}
|
2011-05-19 01:20:42 +00:00
|
|
|
|
2013-01-14 23:16:36 +00:00
|
|
|
// InsertNewInstWith - same as InsertNewInstBefore, but also sets the
|
2011-05-19 01:20:42 +00:00
|
|
|
// debug loc.
|
|
|
|
//
|
|
|
|
Instruction *InsertNewInstWith(Instruction *New, Instruction &Old) {
|
|
|
|
New->setDebugLoc(Old.getDebugLoc());
|
|
|
|
return InsertNewInstBefore(New, Old);
|
|
|
|
}
|
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
// ReplaceInstUsesWith - This method is to be used when an instruction is
|
|
|
|
// found to be dead, replacable with another preexisting expression. Here
|
|
|
|
// we add all uses of I to the worklist, replace all uses of I with the new
|
|
|
|
// value, then return I, so that the inst combiner will know that I was
|
|
|
|
// modified.
|
|
|
|
//
|
|
|
|
Instruction *ReplaceInstUsesWith(Instruction &I, Value *V) {
|
2014-05-07 17:36:59 +00:00
|
|
|
Worklist.AddUsersToWorkList(I); // Add all modified instrs to worklist.
|
2013-01-14 23:16:36 +00:00
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
// If we are replacing the instruction with itself, this must be in a
|
|
|
|
// segment of unreachable code, so just clobber the instruction.
|
2013-01-14 23:16:36 +00:00
|
|
|
if (&I == V)
|
2010-01-04 07:12:23 +00:00
|
|
|
V = UndefValue::get(I.getType());
|
2011-03-27 23:32:31 +00:00
|
|
|
|
2013-09-05 19:48:28 +00:00
|
|
|
DEBUG(dbgs() << "IC: Replacing " << I << "\n"
|
2011-03-27 23:32:31 +00:00
|
|
|
" with " << *V << '\n');
|
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
I.replaceAllUsesWith(V);
|
|
|
|
return &I;
|
|
|
|
}
|
|
|
|
|
|
|
|
// EraseInstFromFunction - When dealing with an instruction that has side
|
|
|
|
// effects or produces a void value, we can't rely on DCE to delete the
|
|
|
|
// instruction. Instead, visit methods should return the value returned by
|
|
|
|
// this function.
|
|
|
|
Instruction *EraseInstFromFunction(Instruction &I) {
|
2013-09-05 19:48:28 +00:00
|
|
|
DEBUG(dbgs() << "IC: ERASE " << I << '\n');
|
2010-01-04 07:12:23 +00:00
|
|
|
|
|
|
|
assert(I.use_empty() && "Cannot erase instruction that is used!");
|
|
|
|
// Make sure that we reprocess all operands now that we reduced their
|
|
|
|
// use counts.
|
|
|
|
if (I.getNumOperands() < 8) {
|
|
|
|
for (User::op_iterator i = I.op_begin(), e = I.op_end(); i != e; ++i)
|
|
|
|
if (Instruction *Op = dyn_cast<Instruction>(*i))
|
|
|
|
Worklist.Add(Op);
|
|
|
|
}
|
|
|
|
Worklist.Remove(&I);
|
|
|
|
I.eraseFromParent();
|
|
|
|
MadeIRChange = true;
|
2014-05-07 17:36:59 +00:00
|
|
|
return nullptr; // Don't do anything with FI
|
2010-01-04 07:12:23 +00:00
|
|
|
}
|
2013-01-14 23:16:36 +00:00
|
|
|
|
2014-05-14 21:14:37 +00:00
|
|
|
void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne,
|
Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.)
This change, which allows @llvm.assume to be used from within computeKnownBits
(and other associated functions in ValueTracking), adds some (optional)
parameters to computeKnownBits and friends. These functions now (optionally)
take a "context" instruction pointer, an AssumptionTracker pointer, and also a
DomTree pointer, and most of the changes are just to pass this new information
when it is easily available from InstSimplify, InstCombine, etc.
As explained below, the significant conceptual change is that known properties
of a value might depend on the control-flow location of the use (because we
care that the @llvm.assume dominates the use because assumptions have
control-flow dependencies). This means that, when we ask if bits are known in a
value, we might get different answers for different uses.
The significant changes are all in ValueTracking. Two main changes: First, as
with the rest of the code, new parameters need to be passed around. To make
this easier, I grouped them into a structure, and I made internal static
versions of the relevant functions that take this structure as a parameter. The
new code does as you might expect, it looks for @llvm.assume calls that make
use of the value we're trying to learn something about (often indirectly),
attempts to pattern match that expression, and uses the result if successful.
By making use of the AssumptionTracker, the process of finding @llvm.assume
calls is not expensive.
Part of the structure being passed around inside ValueTracking is a set of
already-considered @llvm.assume calls. This is to prevent a query using, for
example, the assume(a == b), to recurse on itself. The context and DT params
are used to find applicable assumptions. An assumption needs to dominate the
context instruction, or come after it deterministically. In this latter case we
only handle the specific case where both the assumption and the context
instruction are in the same block, and we need to exclude assumptions from
being used to simplify their own ephemeral values (those which contribute only
to the assumption) because otherwise the assumption would prove its feeding
comparison trivial and would be removed.
This commit adds the plumbing and the logic for a simple masked-bit propagation
(just enough to write a regression test). Future commits add more patterns
(and, correspondingly, more regression tests).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217342 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 18:57:58 +00:00
|
|
|
unsigned Depth = 0, Instruction *CxtI = nullptr) const {
|
|
|
|
return llvm::computeKnownBits(V, KnownZero, KnownOne, DL, Depth,
|
|
|
|
AT, CxtI, DT);
|
2010-01-04 07:12:23 +00:00
|
|
|
}
|
2013-01-14 23:16:36 +00:00
|
|
|
|
|
|
|
bool MaskedValueIsZero(Value *V, const APInt &Mask,
|
Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.)
This change, which allows @llvm.assume to be used from within computeKnownBits
(and other associated functions in ValueTracking), adds some (optional)
parameters to computeKnownBits and friends. These functions now (optionally)
take a "context" instruction pointer, an AssumptionTracker pointer, and also a
DomTree pointer, and most of the changes are just to pass this new information
when it is easily available from InstSimplify, InstCombine, etc.
As explained below, the significant conceptual change is that known properties
of a value might depend on the control-flow location of the use (because we
care that the @llvm.assume dominates the use because assumptions have
control-flow dependencies). This means that, when we ask if bits are known in a
value, we might get different answers for different uses.
The significant changes are all in ValueTracking. Two main changes: First, as
with the rest of the code, new parameters need to be passed around. To make
this easier, I grouped them into a structure, and I made internal static
versions of the relevant functions that take this structure as a parameter. The
new code does as you might expect, it looks for @llvm.assume calls that make
use of the value we're trying to learn something about (often indirectly),
attempts to pattern match that expression, and uses the result if successful.
By making use of the AssumptionTracker, the process of finding @llvm.assume
calls is not expensive.
Part of the structure being passed around inside ValueTracking is a set of
already-considered @llvm.assume calls. This is to prevent a query using, for
example, the assume(a == b), to recurse on itself. The context and DT params
are used to find applicable assumptions. An assumption needs to dominate the
context instruction, or come after it deterministically. In this latter case we
only handle the specific case where both the assumption and the context
instruction are in the same block, and we need to exclude assumptions from
being used to simplify their own ephemeral values (those which contribute only
to the assumption) because otherwise the assumption would prove its feeding
comparison trivial and would be removed.
This commit adds the plumbing and the logic for a simple masked-bit propagation
(just enough to write a regression test). Future commits add more patterns
(and, correspondingly, more regression tests).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217342 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 18:57:58 +00:00
|
|
|
unsigned Depth = 0,
|
|
|
|
Instruction *CxtI = nullptr) const {
|
|
|
|
return llvm::MaskedValueIsZero(V, Mask, DL, Depth, AT, CxtI, DT);
|
2010-01-04 07:12:23 +00:00
|
|
|
}
|
Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.)
This change, which allows @llvm.assume to be used from within computeKnownBits
(and other associated functions in ValueTracking), adds some (optional)
parameters to computeKnownBits and friends. These functions now (optionally)
take a "context" instruction pointer, an AssumptionTracker pointer, and also a
DomTree pointer, and most of the changes are just to pass this new information
when it is easily available from InstSimplify, InstCombine, etc.
As explained below, the significant conceptual change is that known properties
of a value might depend on the control-flow location of the use (because we
care that the @llvm.assume dominates the use because assumptions have
control-flow dependencies). This means that, when we ask if bits are known in a
value, we might get different answers for different uses.
The significant changes are all in ValueTracking. Two main changes: First, as
with the rest of the code, new parameters need to be passed around. To make
this easier, I grouped them into a structure, and I made internal static
versions of the relevant functions that take this structure as a parameter. The
new code does as you might expect, it looks for @llvm.assume calls that make
use of the value we're trying to learn something about (often indirectly),
attempts to pattern match that expression, and uses the result if successful.
By making use of the AssumptionTracker, the process of finding @llvm.assume
calls is not expensive.
Part of the structure being passed around inside ValueTracking is a set of
already-considered @llvm.assume calls. This is to prevent a query using, for
example, the assume(a == b), to recurse on itself. The context and DT params
are used to find applicable assumptions. An assumption needs to dominate the
context instruction, or come after it deterministically. In this latter case we
only handle the specific case where both the assumption and the context
instruction are in the same block, and we need to exclude assumptions from
being used to simplify their own ephemeral values (those which contribute only
to the assumption) because otherwise the assumption would prove its feeding
comparison trivial and would be removed.
This commit adds the plumbing and the logic for a simple masked-bit propagation
(just enough to write a regression test). Future commits add more patterns
(and, correspondingly, more regression tests).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217342 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 18:57:58 +00:00
|
|
|
unsigned ComputeNumSignBits(Value *Op, unsigned Depth = 0,
|
|
|
|
Instruction *CxtI = nullptr) const {
|
|
|
|
return llvm::ComputeNumSignBits(Op, DL, Depth, AT, CxtI, DT);
|
2010-01-04 07:12:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2010-11-13 15:10:37 +00:00
|
|
|
/// SimplifyAssociativeOrCommutative - This performs a few simplifications for
|
|
|
|
/// operators which are associative or commutative.
|
|
|
|
bool SimplifyAssociativeOrCommutative(BinaryOperator &I);
|
2010-01-04 07:12:23 +00:00
|
|
|
|
2010-12-22 13:36:08 +00:00
|
|
|
/// SimplifyUsingDistributiveLaws - This tries to simplify binary operations
|
|
|
|
/// which some other binary operation distributes over either by factorizing
|
|
|
|
/// out common terms (eg "(A*B)+(A*C)" -> "A*(B+C)") or expanding out if this
|
|
|
|
/// results in simplifications (eg: "A & (B | C) -> (A&B) | (A&C)" if this is
|
|
|
|
/// a win). Returns the simplified value, or null if it didn't simplify.
|
|
|
|
Value *SimplifyUsingDistributiveLaws(BinaryOperator &I);
|
2010-11-23 14:23:47 +00:00
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
/// SimplifyDemandedUseBits - Attempts to replace V with a simpler value
|
|
|
|
/// based on the demanded bits.
|
2014-05-07 17:36:59 +00:00
|
|
|
Value *SimplifyDemandedUseBits(Value *V, APInt DemandedMask, APInt &KnownZero,
|
Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.)
This change, which allows @llvm.assume to be used from within computeKnownBits
(and other associated functions in ValueTracking), adds some (optional)
parameters to computeKnownBits and friends. These functions now (optionally)
take a "context" instruction pointer, an AssumptionTracker pointer, and also a
DomTree pointer, and most of the changes are just to pass this new information
when it is easily available from InstSimplify, InstCombine, etc.
As explained below, the significant conceptual change is that known properties
of a value might depend on the control-flow location of the use (because we
care that the @llvm.assume dominates the use because assumptions have
control-flow dependencies). This means that, when we ask if bits are known in a
value, we might get different answers for different uses.
The significant changes are all in ValueTracking. Two main changes: First, as
with the rest of the code, new parameters need to be passed around. To make
this easier, I grouped them into a structure, and I made internal static
versions of the relevant functions that take this structure as a parameter. The
new code does as you might expect, it looks for @llvm.assume calls that make
use of the value we're trying to learn something about (often indirectly),
attempts to pattern match that expression, and uses the result if successful.
By making use of the AssumptionTracker, the process of finding @llvm.assume
calls is not expensive.
Part of the structure being passed around inside ValueTracking is a set of
already-considered @llvm.assume calls. This is to prevent a query using, for
example, the assume(a == b), to recurse on itself. The context and DT params
are used to find applicable assumptions. An assumption needs to dominate the
context instruction, or come after it deterministically. In this latter case we
only handle the specific case where both the assumption and the context
instruction are in the same block, and we need to exclude assumptions from
being used to simplify their own ephemeral values (those which contribute only
to the assumption) because otherwise the assumption would prove its feeding
comparison trivial and would be removed.
This commit adds the plumbing and the logic for a simple masked-bit propagation
(just enough to write a regression test). Future commits add more patterns
(and, correspondingly, more regression tests).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217342 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 18:57:58 +00:00
|
|
|
APInt &KnownOne, unsigned Depth,
|
|
|
|
Instruction *CxtI = nullptr);
|
2014-05-07 17:36:59 +00:00
|
|
|
bool SimplifyDemandedBits(Use &U, APInt DemandedMask, APInt &KnownZero,
|
|
|
|
APInt &KnownOne, unsigned Depth = 0);
|
2012-12-04 00:04:54 +00:00
|
|
|
/// Helper routine of SimplifyDemandedUseBits. It tries to simplify demanded
|
|
|
|
/// bit for "r1 = shr x, c1; r2 = shl r1, c2" instruction sequence.
|
|
|
|
Value *SimplifyShrShlDemandedBits(Instruction *Lsr, Instruction *Sftl,
|
|
|
|
APInt DemandedMask, APInt &KnownZero,
|
|
|
|
APInt &KnownOne);
|
2013-01-14 23:16:36 +00:00
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
/// SimplifyDemandedInstructionBits - Inst is an integer instruction that
|
|
|
|
/// SimplifyDemandedBits knows about. See if the instruction has any
|
|
|
|
/// properties that allow us to simplify its operands.
|
|
|
|
bool SimplifyDemandedInstructionBits(Instruction &Inst);
|
2013-01-14 23:16:36 +00:00
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
Value *SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
|
2014-05-07 17:36:59 +00:00
|
|
|
APInt &UndefElts, unsigned Depth = 0);
|
2013-01-14 23:16:36 +00:00
|
|
|
|
2014-05-11 08:46:12 +00:00
|
|
|
Value *SimplifyVectorOp(BinaryOperator &Inst);
|
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
// FoldOpIntoPhi - Given a binary operator, cast instruction, or select
|
|
|
|
// which has a PHI node as operand #0, see if we can fold the instruction
|
|
|
|
// into the PHI (which is only possible if all operands to the PHI are
|
|
|
|
// constants).
|
|
|
|
//
|
2011-01-16 05:14:26 +00:00
|
|
|
Instruction *FoldOpIntoPhi(Instruction &I);
|
2010-01-04 07:12:23 +00:00
|
|
|
|
|
|
|
// FoldPHIArgOpIntoPHI - If all operands to a PHI node are the same "unary"
|
|
|
|
// operator and they all are only used by the PHI, PHI together their
|
|
|
|
// inputs, and do the operation once, to the result of the PHI.
|
|
|
|
Instruction *FoldPHIArgOpIntoPHI(PHINode &PN);
|
|
|
|
Instruction *FoldPHIArgBinOpIntoPHI(PHINode &PN);
|
|
|
|
Instruction *FoldPHIArgGEPIntoPHI(PHINode &PN);
|
|
|
|
Instruction *FoldPHIArgLoadIntoPHI(PHINode &PN);
|
|
|
|
|
|
|
|
Instruction *OptAndOp(Instruction *Op, ConstantInt *OpRHS,
|
|
|
|
ConstantInt *AndRHS, BinaryOperator &TheAnd);
|
2013-01-14 23:16:36 +00:00
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
Value *FoldLogicalPlusAnd(Value *LHS, Value *RHS, ConstantInt *Mask,
|
|
|
|
bool isSub, Instruction &I);
|
2014-05-07 17:36:59 +00:00
|
|
|
Value *InsertRangeTest(Value *V, Constant *Lo, Constant *Hi, bool isSigned,
|
|
|
|
bool Inside);
|
2010-01-04 07:12:23 +00:00
|
|
|
Instruction *PromoteCastOfAllocation(BitCastInst &CI, AllocaInst &AI);
|
|
|
|
Instruction *MatchBSwap(BinaryOperator &I);
|
|
|
|
bool SimplifyStoreAtEndOfBlock(StoreInst &SI);
|
|
|
|
Instruction *SimplifyMemTransfer(MemIntrinsic *MI);
|
|
|
|
Instruction *SimplifyMemSet(MemSetInst *MI);
|
|
|
|
|
2011-07-18 04:54:35 +00:00
|
|
|
Value *EvaluateInDifferentType(Value *V, Type *Ty, bool isSigned);
|
2012-10-23 08:28:26 +00:00
|
|
|
|
|
|
|
/// Descale - Return a value X such that Val = X * Scale, or null if none. If
|
|
|
|
/// the multiplication is known not to overflow then NoSignedWrap is set.
|
|
|
|
Value *Descale(Value *Val, APInt Scale, bool &NoSignedWrap);
|
2010-01-04 07:12:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm.
|
|
|
|
|
2014-04-22 02:55:47 +00:00
|
|
|
#undef DEBUG_TYPE
|
|
|
|
|
2010-01-04 07:12:23 +00:00
|
|
|
#endif
|