mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Remove a bunch more now-unnecessary Context arguments.
llvm-svn: 78809
This commit is contained in:
parent
ccb751285b
commit
9a6b2f19e5
@ -244,23 +244,17 @@ public:
|
|||||||
/// CreateNeg, CreateNot - Create the NEG and NOT
|
/// CreateNeg, CreateNot - Create the NEG and NOT
|
||||||
/// instructions out of SUB and XOR instructions.
|
/// instructions out of SUB and XOR instructions.
|
||||||
///
|
///
|
||||||
static BinaryOperator *CreateNeg(LLVMContext &Context,
|
static BinaryOperator *CreateNeg(Value *Op, const Twine &Name = "",
|
||||||
Value *Op, const Twine &Name = "",
|
|
||||||
Instruction *InsertBefore = 0);
|
Instruction *InsertBefore = 0);
|
||||||
static BinaryOperator *CreateNeg(LLVMContext &Context,
|
static BinaryOperator *CreateNeg(Value *Op, const Twine &Name,
|
||||||
Value *Op, const Twine &Name,
|
|
||||||
BasicBlock *InsertAtEnd);
|
BasicBlock *InsertAtEnd);
|
||||||
static BinaryOperator *CreateFNeg(LLVMContext &Context,
|
static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name = "",
|
||||||
Value *Op, const Twine &Name = "",
|
|
||||||
Instruction *InsertBefore = 0);
|
Instruction *InsertBefore = 0);
|
||||||
static BinaryOperator *CreateFNeg(LLVMContext &Context,
|
static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name,
|
||||||
Value *Op, const Twine &Name,
|
|
||||||
BasicBlock *InsertAtEnd);
|
BasicBlock *InsertAtEnd);
|
||||||
static BinaryOperator *CreateNot(LLVMContext &Context,
|
static BinaryOperator *CreateNot(Value *Op, const Twine &Name = "",
|
||||||
Value *Op, const Twine &Name = "",
|
|
||||||
Instruction *InsertBefore = 0);
|
Instruction *InsertBefore = 0);
|
||||||
static BinaryOperator *CreateNot(LLVMContext &Context,
|
static BinaryOperator *CreateNot(Value *Op, const Twine &Name,
|
||||||
Value *Op, const Twine &Name,
|
|
||||||
BasicBlock *InsertAtEnd);
|
BasicBlock *InsertAtEnd);
|
||||||
|
|
||||||
/// isNeg, isFNeg, isNot - Check if the given Value is a
|
/// isNeg, isFNeg, isNot - Check if the given Value is a
|
||||||
|
@ -325,17 +325,17 @@ public:
|
|||||||
Value *CreateNeg(Value *V, const char *Name = "") {
|
Value *CreateNeg(Value *V, const char *Name = "") {
|
||||||
if (Constant *VC = dyn_cast<Constant>(V))
|
if (Constant *VC = dyn_cast<Constant>(V))
|
||||||
return Folder.CreateNeg(VC);
|
return Folder.CreateNeg(VC);
|
||||||
return Insert(BinaryOperator::CreateNeg(Context, V), Name);
|
return Insert(BinaryOperator::CreateNeg(V), Name);
|
||||||
}
|
}
|
||||||
Value *CreateFNeg(Value *V, const char *Name = "") {
|
Value *CreateFNeg(Value *V, const char *Name = "") {
|
||||||
if (Constant *VC = dyn_cast<Constant>(V))
|
if (Constant *VC = dyn_cast<Constant>(V))
|
||||||
return Folder.CreateFNeg(VC);
|
return Folder.CreateFNeg(VC);
|
||||||
return Insert(BinaryOperator::CreateFNeg(Context, V), Name);
|
return Insert(BinaryOperator::CreateFNeg(V), Name);
|
||||||
}
|
}
|
||||||
Value *CreateNot(Value *V, const char *Name = "") {
|
Value *CreateNot(Value *V, const char *Name = "") {
|
||||||
if (Constant *VC = dyn_cast<Constant>(V))
|
if (Constant *VC = dyn_cast<Constant>(V))
|
||||||
return Folder.CreateNot(VC);
|
return Folder.CreateNot(VC);
|
||||||
return Insert(BinaryOperator::CreateNot(Context, V), Name);
|
return Insert(BinaryOperator::CreateNot(V), Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
@ -31,20 +31,19 @@
|
|||||||
|
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/LLVMContext.h"
|
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
namespace PatternMatch {
|
namespace PatternMatch {
|
||||||
|
|
||||||
template<typename Val, typename Pattern>
|
template<typename Val, typename Pattern>
|
||||||
bool match(Val *V, const Pattern &P, LLVMContext &Context) {
|
bool match(Val *V, const Pattern &P) {
|
||||||
return const_cast<Pattern&>(P).match(V, Context);
|
return const_cast<Pattern&>(P).match(V);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Class>
|
template<typename Class>
|
||||||
struct leaf_ty {
|
struct leaf_ty {
|
||||||
template<typename ITy>
|
template<typename ITy>
|
||||||
bool match(ITy *V, LLVMContext&) { return isa<Class>(V); }
|
bool match(ITy *V) { return isa<Class>(V); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// m_Value() - Match an arbitrary value and ignore it.
|
/// m_Value() - Match an arbitrary value and ignore it.
|
||||||
@ -55,7 +54,7 @@ inline leaf_ty<ConstantInt> m_ConstantInt() { return leaf_ty<ConstantInt>(); }
|
|||||||
template<int64_t Val>
|
template<int64_t Val>
|
||||||
struct constantint_ty {
|
struct constantint_ty {
|
||||||
template<typename ITy>
|
template<typename ITy>
|
||||||
bool match(ITy *V, LLVMContext&) {
|
bool match(ITy *V) {
|
||||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
|
if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
|
||||||
const APInt &CIV = CI->getValue();
|
const APInt &CIV = CI->getValue();
|
||||||
if (Val >= 0)
|
if (Val >= 0)
|
||||||
@ -78,7 +77,7 @@ inline constantint_ty<Val> m_ConstantInt() {
|
|||||||
|
|
||||||
struct zero_ty {
|
struct zero_ty {
|
||||||
template<typename ITy>
|
template<typename ITy>
|
||||||
bool match(ITy *V, LLVMContext&) {
|
bool match(ITy *V) {
|
||||||
if (const Constant *C = dyn_cast<Constant>(V))
|
if (const Constant *C = dyn_cast<Constant>(V))
|
||||||
return C->isNullValue();
|
return C->isNullValue();
|
||||||
return false;
|
return false;
|
||||||
@ -95,7 +94,7 @@ struct bind_ty {
|
|||||||
bind_ty(Class *&V) : VR(V) {}
|
bind_ty(Class *&V) : VR(V) {}
|
||||||
|
|
||||||
template<typename ITy>
|
template<typename ITy>
|
||||||
bool match(ITy *V, LLVMContext&) {
|
bool match(ITy *V) {
|
||||||
if (Class *CV = dyn_cast<Class>(V)) {
|
if (Class *CV = dyn_cast<Class>(V)) {
|
||||||
VR = CV;
|
VR = CV;
|
||||||
return true;
|
return true;
|
||||||
@ -116,7 +115,7 @@ struct specificval_ty {
|
|||||||
specificval_ty(const Value *V) : Val(V) {}
|
specificval_ty(const Value *V) : Val(V) {}
|
||||||
|
|
||||||
template<typename ITy>
|
template<typename ITy>
|
||||||
bool match(ITy *V, LLVMContext&) {
|
bool match(ITy *V) {
|
||||||
return V == Val;
|
return V == Val;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -138,15 +137,15 @@ struct BinaryOp_match {
|
|||||||
BinaryOp_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {}
|
BinaryOp_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {}
|
||||||
|
|
||||||
template<typename OpTy>
|
template<typename OpTy>
|
||||||
bool match(OpTy *V, LLVMContext &Context) {
|
bool match(OpTy *V) {
|
||||||
if (V->getValueID() == Value::InstructionVal + Opcode) {
|
if (V->getValueID() == Value::InstructionVal + Opcode) {
|
||||||
ConcreteTy *I = cast<ConcreteTy>(V);
|
ConcreteTy *I = cast<ConcreteTy>(V);
|
||||||
return I->getOpcode() == Opcode && L.match(I->getOperand(0), Context) &&
|
return I->getOpcode() == Opcode && L.match(I->getOperand(0)) &&
|
||||||
R.match(I->getOperand(1), Context);
|
R.match(I->getOperand(1));
|
||||||
}
|
}
|
||||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
||||||
return CE->getOpcode() == Opcode && L.match(CE->getOperand(0), Context) &&
|
return CE->getOpcode() == Opcode && L.match(CE->getOperand(0)) &&
|
||||||
R.match(CE->getOperand(1), Context);
|
R.match(CE->getOperand(1));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -270,20 +269,20 @@ struct Shr_match {
|
|||||||
Shr_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {}
|
Shr_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {}
|
||||||
|
|
||||||
template<typename OpTy>
|
template<typename OpTy>
|
||||||
bool match(OpTy *V, LLVMContext &Context) {
|
bool match(OpTy *V) {
|
||||||
if (V->getValueID() == Value::InstructionVal + Instruction::LShr ||
|
if (V->getValueID() == Value::InstructionVal + Instruction::LShr ||
|
||||||
V->getValueID() == Value::InstructionVal + Instruction::AShr) {
|
V->getValueID() == Value::InstructionVal + Instruction::AShr) {
|
||||||
ConcreteTy *I = cast<ConcreteTy>(V);
|
ConcreteTy *I = cast<ConcreteTy>(V);
|
||||||
return (I->getOpcode() == Instruction::AShr ||
|
return (I->getOpcode() == Instruction::AShr ||
|
||||||
I->getOpcode() == Instruction::LShr) &&
|
I->getOpcode() == Instruction::LShr) &&
|
||||||
L.match(I->getOperand(0), Context) &&
|
L.match(I->getOperand(0)) &&
|
||||||
R.match(I->getOperand(1), Context);
|
R.match(I->getOperand(1));
|
||||||
}
|
}
|
||||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
||||||
return (CE->getOpcode() == Instruction::LShr ||
|
return (CE->getOpcode() == Instruction::LShr ||
|
||||||
CE->getOpcode() == Instruction::AShr) &&
|
CE->getOpcode() == Instruction::AShr) &&
|
||||||
L.match(CE->getOperand(0), Context) &&
|
L.match(CE->getOperand(0)) &&
|
||||||
R.match(CE->getOperand(1), Context);
|
R.match(CE->getOperand(1));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -310,10 +309,10 @@ struct BinaryOpClass_match {
|
|||||||
: Opcode(0), L(LHS), R(RHS) {}
|
: Opcode(0), L(LHS), R(RHS) {}
|
||||||
|
|
||||||
template<typename OpTy>
|
template<typename OpTy>
|
||||||
bool match(OpTy *V, LLVMContext &Context) {
|
bool match(OpTy *V) {
|
||||||
if (Class *I = dyn_cast<Class>(V))
|
if (Class *I = dyn_cast<Class>(V))
|
||||||
if (L.match(I->getOperand(0), Context) &&
|
if (L.match(I->getOperand(0)) &&
|
||||||
R.match(I->getOperand(1), Context)) {
|
R.match(I->getOperand(1))) {
|
||||||
if (Opcode)
|
if (Opcode)
|
||||||
*Opcode = I->getOpcode();
|
*Opcode = I->getOpcode();
|
||||||
return true;
|
return true;
|
||||||
@ -356,10 +355,10 @@ struct CmpClass_match {
|
|||||||
: Predicate(Pred), L(LHS), R(RHS) {}
|
: Predicate(Pred), L(LHS), R(RHS) {}
|
||||||
|
|
||||||
template<typename OpTy>
|
template<typename OpTy>
|
||||||
bool match(OpTy *V, LLVMContext &Context) {
|
bool match(OpTy *V) {
|
||||||
if (Class *I = dyn_cast<Class>(V))
|
if (Class *I = dyn_cast<Class>(V))
|
||||||
if (L.match(I->getOperand(0), Context) &&
|
if (L.match(I->getOperand(0)) &&
|
||||||
R.match(I->getOperand(1), Context)) {
|
R.match(I->getOperand(1))) {
|
||||||
Predicate = I->getPredicate();
|
Predicate = I->getPredicate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -396,11 +395,11 @@ struct SelectClass_match {
|
|||||||
: C(Cond), L(LHS), R(RHS) {}
|
: C(Cond), L(LHS), R(RHS) {}
|
||||||
|
|
||||||
template<typename OpTy>
|
template<typename OpTy>
|
||||||
bool match(OpTy *V, LLVMContext &Context) {
|
bool match(OpTy *V) {
|
||||||
if (SelectInst *I = dyn_cast<SelectInst>(V))
|
if (SelectInst *I = dyn_cast<SelectInst>(V))
|
||||||
return C.match(I->getOperand(0), Context) &&
|
return C.match(I->getOperand(0)) &&
|
||||||
L.match(I->getOperand(1), Context) &&
|
L.match(I->getOperand(1)) &&
|
||||||
R.match(I->getOperand(2), Context);
|
R.match(I->getOperand(2));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -433,9 +432,9 @@ struct CastClass_match {
|
|||||||
CastClass_match(const Op_t &OpMatch) : Op(OpMatch) {}
|
CastClass_match(const Op_t &OpMatch) : Op(OpMatch) {}
|
||||||
|
|
||||||
template<typename OpTy>
|
template<typename OpTy>
|
||||||
bool match(OpTy *V, LLVMContext &Context) {
|
bool match(OpTy *V) {
|
||||||
if (Class *I = dyn_cast<Class>(V))
|
if (Class *I = dyn_cast<Class>(V))
|
||||||
return Op.match(I->getOperand(0), Context);
|
return Op.match(I->getOperand(0));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -457,27 +456,27 @@ struct not_match {
|
|||||||
not_match(const LHS_t &LHS) : L(LHS) {}
|
not_match(const LHS_t &LHS) : L(LHS) {}
|
||||||
|
|
||||||
template<typename OpTy>
|
template<typename OpTy>
|
||||||
bool match(OpTy *V, LLVMContext &Context) {
|
bool match(OpTy *V) {
|
||||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||||
if (I->getOpcode() == Instruction::Xor)
|
if (I->getOpcode() == Instruction::Xor)
|
||||||
return matchIfNot(I->getOperand(0), I->getOperand(1), Context);
|
return matchIfNot(I->getOperand(0), I->getOperand(1));
|
||||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
||||||
if (CE->getOpcode() == Instruction::Xor)
|
if (CE->getOpcode() == Instruction::Xor)
|
||||||
return matchIfNot(CE->getOperand(0), CE->getOperand(1), Context);
|
return matchIfNot(CE->getOperand(0), CE->getOperand(1));
|
||||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
|
if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
|
||||||
return L.match(ConstantExpr::getNot(CI), Context);
|
return L.match(ConstantExpr::getNot(CI));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
bool matchIfNot(Value *LHS, Value *RHS, LLVMContext &Context) {
|
bool matchIfNot(Value *LHS, Value *RHS) {
|
||||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS))
|
if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS))
|
||||||
return CI->isAllOnesValue() && L.match(LHS, Context);
|
return CI->isAllOnesValue() && L.match(LHS);
|
||||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(LHS))
|
if (ConstantInt *CI = dyn_cast<ConstantInt>(LHS))
|
||||||
return CI->isAllOnesValue() && L.match(RHS, Context);
|
return CI->isAllOnesValue() && L.match(RHS);
|
||||||
if (ConstantVector *CV = dyn_cast<ConstantVector>(RHS))
|
if (ConstantVector *CV = dyn_cast<ConstantVector>(RHS))
|
||||||
return CV->isAllOnesValue() && L.match(LHS, Context);
|
return CV->isAllOnesValue() && L.match(LHS);
|
||||||
if (ConstantVector *CV = dyn_cast<ConstantVector>(LHS))
|
if (ConstantVector *CV = dyn_cast<ConstantVector>(LHS))
|
||||||
return CV->isAllOnesValue() && L.match(RHS, Context);
|
return CV->isAllOnesValue() && L.match(RHS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -493,21 +492,21 @@ struct neg_match {
|
|||||||
neg_match(const LHS_t &LHS) : L(LHS) {}
|
neg_match(const LHS_t &LHS) : L(LHS) {}
|
||||||
|
|
||||||
template<typename OpTy>
|
template<typename OpTy>
|
||||||
bool match(OpTy *V, LLVMContext &Context) {
|
bool match(OpTy *V) {
|
||||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||||
if (I->getOpcode() == Instruction::Sub)
|
if (I->getOpcode() == Instruction::Sub)
|
||||||
return matchIfNeg(I->getOperand(0), I->getOperand(1), Context);
|
return matchIfNeg(I->getOperand(0), I->getOperand(1));
|
||||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
||||||
if (CE->getOpcode() == Instruction::Sub)
|
if (CE->getOpcode() == Instruction::Sub)
|
||||||
return matchIfNeg(CE->getOperand(0), CE->getOperand(1), Context);
|
return matchIfNeg(CE->getOperand(0), CE->getOperand(1));
|
||||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
|
if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
|
||||||
return L.match(ConstantExpr::getNeg(CI), Context);
|
return L.match(ConstantExpr::getNeg(CI));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
bool matchIfNeg(Value *LHS, Value *RHS, LLVMContext &Context) {
|
bool matchIfNeg(Value *LHS, Value *RHS) {
|
||||||
return LHS == ConstantFP::getZeroValueForNegation(LHS->getType()) &&
|
return LHS == ConstantFP::getZeroValueForNegation(LHS->getType()) &&
|
||||||
L.match(RHS, Context);
|
L.match(RHS);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -522,21 +521,21 @@ struct fneg_match {
|
|||||||
fneg_match(const LHS_t &LHS) : L(LHS) {}
|
fneg_match(const LHS_t &LHS) : L(LHS) {}
|
||||||
|
|
||||||
template<typename OpTy>
|
template<typename OpTy>
|
||||||
bool match(OpTy *V, LLVMContext &Context) {
|
bool match(OpTy *V) {
|
||||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||||
if (I->getOpcode() == Instruction::FSub)
|
if (I->getOpcode() == Instruction::FSub)
|
||||||
return matchIfFNeg(I->getOperand(0), I->getOperand(1), Context);
|
return matchIfFNeg(I->getOperand(0), I->getOperand(1));
|
||||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
||||||
if (CE->getOpcode() == Instruction::FSub)
|
if (CE->getOpcode() == Instruction::FSub)
|
||||||
return matchIfFNeg(CE->getOperand(0), CE->getOperand(1), Context);
|
return matchIfFNeg(CE->getOperand(0), CE->getOperand(1));
|
||||||
if (ConstantFP *CF = dyn_cast<ConstantFP>(V))
|
if (ConstantFP *CF = dyn_cast<ConstantFP>(V))
|
||||||
return L.match(ConstantExpr::getFNeg(CF), Context);
|
return L.match(ConstantExpr::getFNeg(CF));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
bool matchIfFNeg(Value *LHS, Value *RHS, LLVMContext &Context) {
|
bool matchIfFNeg(Value *LHS, Value *RHS) {
|
||||||
return LHS == ConstantFP::getZeroValueForNegation(LHS->getType()) &&
|
return LHS == ConstantFP::getZeroValueForNegation(LHS->getType()) &&
|
||||||
L.match(RHS, Context);
|
L.match(RHS);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -557,10 +556,10 @@ struct brc_match {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename OpTy>
|
template<typename OpTy>
|
||||||
bool match(OpTy *V, LLVMContext &Context) {
|
bool match(OpTy *V) {
|
||||||
if (BranchInst *BI = dyn_cast<BranchInst>(V))
|
if (BranchInst *BI = dyn_cast<BranchInst>(V))
|
||||||
if (BI->isConditional()) {
|
if (BI->isConditional()) {
|
||||||
if (Cond.match(BI->getCondition(), Context)) {
|
if (Cond.match(BI->getCondition())) {
|
||||||
T = BI->getSuccessor(0);
|
T = BI->getSuccessor(0);
|
||||||
F = BI->getSuccessor(1);
|
F = BI->getSuccessor(1);
|
||||||
return true;
|
return true;
|
||||||
|
@ -891,7 +891,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
|
|||||||
case ICmpInst::ICMP_ULE:
|
case ICmpInst::ICMP_ULE:
|
||||||
case ICmpInst::ICMP_SLE:
|
case ICmpInst::ICMP_SLE:
|
||||||
case ICmpInst::ICMP_EQ:
|
case ICmpInst::ICMP_EQ:
|
||||||
LV = BinaryOperator::CreateNot(Context, LV, "notinit", CI);
|
LV = BinaryOperator::CreateNot(LV, "notinit", CI);
|
||||||
break;
|
break;
|
||||||
case ICmpInst::ICMP_NE:
|
case ICmpInst::ICMP_NE:
|
||||||
case ICmpInst::ICMP_UGE:
|
case ICmpInst::ICMP_UGE:
|
||||||
|
@ -1841,8 +1841,7 @@ namespace {
|
|||||||
// AddRHS - Implements: X + X --> X << 1
|
// AddRHS - Implements: X + X --> X << 1
|
||||||
struct AddRHS {
|
struct AddRHS {
|
||||||
Value *RHS;
|
Value *RHS;
|
||||||
LLVMContext *Context;
|
explicit AddRHS(Value *rhs) : RHS(rhs) {}
|
||||||
AddRHS(Value *rhs, LLVMContext *C) : RHS(rhs), Context(C) {}
|
|
||||||
bool shouldApply(Value *LHS) const { return LHS == RHS; }
|
bool shouldApply(Value *LHS) const { return LHS == RHS; }
|
||||||
Instruction *apply(BinaryOperator &Add) const {
|
Instruction *apply(BinaryOperator &Add) const {
|
||||||
return BinaryOperator::CreateShl(Add.getOperand(0),
|
return BinaryOperator::CreateShl(Add.getOperand(0),
|
||||||
@ -1854,11 +1853,10 @@ struct AddRHS {
|
|||||||
// iff C1&C2 == 0
|
// iff C1&C2 == 0
|
||||||
struct AddMaskingAnd {
|
struct AddMaskingAnd {
|
||||||
Constant *C2;
|
Constant *C2;
|
||||||
LLVMContext *Context;
|
explicit AddMaskingAnd(Constant *c) : C2(c) {}
|
||||||
AddMaskingAnd(Constant *c, LLVMContext *C) : C2(c), Context(C) {}
|
|
||||||
bool shouldApply(Value *LHS) const {
|
bool shouldApply(Value *LHS) const {
|
||||||
ConstantInt *C1;
|
ConstantInt *C1;
|
||||||
return match(LHS, m_And(m_Value(), m_ConstantInt(C1)), *Context) &&
|
return match(LHS, m_And(m_Value(), m_ConstantInt(C1))) &&
|
||||||
ConstantExpr::getAnd(C1, C2)->isNullValue();
|
ConstantExpr::getAnd(C1, C2)->isNullValue();
|
||||||
}
|
}
|
||||||
Instruction *apply(BinaryOperator &Add) const {
|
Instruction *apply(BinaryOperator &Add) const {
|
||||||
@ -2079,7 +2077,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
|||||||
ConstantInt *XorRHS = 0;
|
ConstantInt *XorRHS = 0;
|
||||||
Value *XorLHS = 0;
|
Value *XorLHS = 0;
|
||||||
if (isa<ConstantInt>(RHSC) &&
|
if (isa<ConstantInt>(RHSC) &&
|
||||||
match(LHS, m_Xor(m_Value(XorLHS), m_ConstantInt(XorRHS)), *Context)) {
|
match(LHS, m_Xor(m_Value(XorLHS), m_ConstantInt(XorRHS)))) {
|
||||||
uint32_t TySizeBits = I.getType()->getScalarSizeInBits();
|
uint32_t TySizeBits = I.getType()->getScalarSizeInBits();
|
||||||
const APInt& RHSVal = cast<ConstantInt>(RHSC)->getValue();
|
const APInt& RHSVal = cast<ConstantInt>(RHSC)->getValue();
|
||||||
|
|
||||||
@ -2128,7 +2126,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
|||||||
|
|
||||||
// X + X --> X << 1
|
// X + X --> X << 1
|
||||||
if (I.getType()->isInteger()) {
|
if (I.getType()->isInteger()) {
|
||||||
if (Instruction *Result = AssociativeOpt(I, AddRHS(RHS, Context)))
|
if (Instruction *Result = AssociativeOpt(I, AddRHS(RHS)))
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
if (Instruction *RHSI = dyn_cast<Instruction>(RHS)) {
|
if (Instruction *RHSI = dyn_cast<Instruction>(RHS)) {
|
||||||
@ -2150,7 +2148,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
|||||||
if (Value *RHSV = dyn_castNegVal(RHS)) {
|
if (Value *RHSV = dyn_castNegVal(RHS)) {
|
||||||
Instruction *NewAdd = BinaryOperator::CreateAdd(LHSV, RHSV, "sum");
|
Instruction *NewAdd = BinaryOperator::CreateAdd(LHSV, RHSV, "sum");
|
||||||
InsertNewInstBefore(NewAdd, I);
|
InsertNewInstBefore(NewAdd, I);
|
||||||
return BinaryOperator::CreateNeg(*Context, NewAdd);
|
return BinaryOperator::CreateNeg(NewAdd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2185,8 +2183,8 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
|||||||
|
|
||||||
|
|
||||||
// (A & C1)+(B & C2) --> (A & C1)|(B & C2) iff C1&C2 == 0
|
// (A & C1)+(B & C2) --> (A & C1)|(B & C2) iff C1&C2 == 0
|
||||||
if (match(RHS, m_And(m_Value(), m_ConstantInt(C2)), *Context))
|
if (match(RHS, m_And(m_Value(), m_ConstantInt(C2))))
|
||||||
if (Instruction *R = AssociativeOpt(I, AddMaskingAnd(C2, Context)))
|
if (Instruction *R = AssociativeOpt(I, AddMaskingAnd(C2)))
|
||||||
return R;
|
return R;
|
||||||
|
|
||||||
// A+B --> A|B iff A and B have no bits set in common.
|
// A+B --> A|B iff A and B have no bits set in common.
|
||||||
@ -2209,8 +2207,8 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
|||||||
// W*X + Y*Z --> W * (X+Z) iff W == Y
|
// W*X + Y*Z --> W * (X+Z) iff W == Y
|
||||||
if (I.getType()->isIntOrIntVector()) {
|
if (I.getType()->isIntOrIntVector()) {
|
||||||
Value *W, *X, *Y, *Z;
|
Value *W, *X, *Y, *Z;
|
||||||
if (match(LHS, m_Mul(m_Value(W), m_Value(X)), *Context) &&
|
if (match(LHS, m_Mul(m_Value(W), m_Value(X))) &&
|
||||||
match(RHS, m_Mul(m_Value(Y), m_Value(Z)), *Context)) {
|
match(RHS, m_Mul(m_Value(Y), m_Value(Z)))) {
|
||||||
if (W != Y) {
|
if (W != Y) {
|
||||||
if (W == Z) {
|
if (W == Z) {
|
||||||
std::swap(Y, Z);
|
std::swap(Y, Z);
|
||||||
@ -2232,12 +2230,12 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
|||||||
|
|
||||||
if (ConstantInt *CRHS = dyn_cast<ConstantInt>(RHS)) {
|
if (ConstantInt *CRHS = dyn_cast<ConstantInt>(RHS)) {
|
||||||
Value *X = 0;
|
Value *X = 0;
|
||||||
if (match(LHS, m_Not(m_Value(X)), *Context)) // ~X + C --> (C-1) - X
|
if (match(LHS, m_Not(m_Value(X)))) // ~X + C --> (C-1) - X
|
||||||
return BinaryOperator::CreateSub(SubOne(CRHS), X);
|
return BinaryOperator::CreateSub(SubOne(CRHS), X);
|
||||||
|
|
||||||
// (X & FF00) + xx00 -> (X+xx00) & FF00
|
// (X & FF00) + xx00 -> (X+xx00) & FF00
|
||||||
if (LHS->hasOneUse() &&
|
if (LHS->hasOneUse() &&
|
||||||
match(LHS, m_And(m_Value(X), m_ConstantInt(C2)), *Context)) {
|
match(LHS, m_And(m_Value(X), m_ConstantInt(C2)))) {
|
||||||
Constant *Anded = ConstantExpr::getAnd(CRHS, C2);
|
Constant *Anded = ConstantExpr::getAnd(CRHS, C2);
|
||||||
if (Anded == CRHS) {
|
if (Anded == CRHS) {
|
||||||
// See if all bits from the first bit set in the Add RHS up are included
|
// See if all bits from the first bit set in the Add RHS up are included
|
||||||
@ -2280,12 +2278,12 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
|||||||
|
|
||||||
// Can we fold the add into the argument of the select?
|
// Can we fold the add into the argument of the select?
|
||||||
// We check both true and false select arguments for a matching subtract.
|
// We check both true and false select arguments for a matching subtract.
|
||||||
if (match(FV, m_Zero(), *Context) &&
|
if (match(FV, m_Zero()) &&
|
||||||
match(TV, m_Sub(m_Value(N), m_Specific(A)), *Context))
|
match(TV, m_Sub(m_Value(N), m_Specific(A))))
|
||||||
// Fold the add into the true select value.
|
// Fold the add into the true select value.
|
||||||
return SelectInst::Create(SI->getCondition(), N, A);
|
return SelectInst::Create(SI->getCondition(), N, A);
|
||||||
if (match(TV, m_Zero(), *Context) &&
|
if (match(TV, m_Zero()) &&
|
||||||
match(FV, m_Sub(m_Value(N), m_Specific(A)), *Context))
|
match(FV, m_Sub(m_Value(N), m_Specific(A))))
|
||||||
// Fold the add into the false select value.
|
// Fold the add into the false select value.
|
||||||
return SelectInst::Create(SI->getCondition(), A, N);
|
return SelectInst::Create(SI->getCondition(), A, N);
|
||||||
}
|
}
|
||||||
@ -2425,11 +2423,11 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
|
|||||||
if (ConstantInt *C = dyn_cast<ConstantInt>(Op0)) {
|
if (ConstantInt *C = dyn_cast<ConstantInt>(Op0)) {
|
||||||
// Replace (-1 - A) with (~A)...
|
// Replace (-1 - A) with (~A)...
|
||||||
if (C->isAllOnesValue())
|
if (C->isAllOnesValue())
|
||||||
return BinaryOperator::CreateNot(*Context, Op1);
|
return BinaryOperator::CreateNot(Op1);
|
||||||
|
|
||||||
// C - ~X == X + (1+C)
|
// C - ~X == X + (1+C)
|
||||||
Value *X = 0;
|
Value *X = 0;
|
||||||
if (match(Op1, m_Not(m_Value(X)), *Context))
|
if (match(Op1, m_Not(m_Value(X))))
|
||||||
return BinaryOperator::CreateAdd(X, AddOne(C));
|
return BinaryOperator::CreateAdd(X, AddOne(C));
|
||||||
|
|
||||||
// -(X >>u 31) -> (X >>s 31)
|
// -(X >>u 31) -> (X >>s 31)
|
||||||
@ -2478,10 +2476,10 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
|
|||||||
if (BinaryOperator *Op1I = dyn_cast<BinaryOperator>(Op1)) {
|
if (BinaryOperator *Op1I = dyn_cast<BinaryOperator>(Op1)) {
|
||||||
if (Op1I->getOpcode() == Instruction::Add) {
|
if (Op1I->getOpcode() == Instruction::Add) {
|
||||||
if (Op1I->getOperand(0) == Op0) // X-(X+Y) == -Y
|
if (Op1I->getOperand(0) == Op0) // X-(X+Y) == -Y
|
||||||
return BinaryOperator::CreateNeg(*Context, Op1I->getOperand(1),
|
return BinaryOperator::CreateNeg(Op1I->getOperand(1),
|
||||||
I.getName());
|
I.getName());
|
||||||
else if (Op1I->getOperand(1) == Op0) // X-(Y+X) == -Y
|
else if (Op1I->getOperand(1) == Op0) // X-(Y+X) == -Y
|
||||||
return BinaryOperator::CreateNeg(*Context, Op1I->getOperand(0),
|
return BinaryOperator::CreateNeg(Op1I->getOperand(0),
|
||||||
I.getName());
|
I.getName());
|
||||||
else if (ConstantInt *CI1 = dyn_cast<ConstantInt>(I.getOperand(0))) {
|
else if (ConstantInt *CI1 = dyn_cast<ConstantInt>(I.getOperand(0))) {
|
||||||
if (ConstantInt *CI2 = dyn_cast<ConstantInt>(Op1I->getOperand(1)))
|
if (ConstantInt *CI2 = dyn_cast<ConstantInt>(Op1I->getOperand(1)))
|
||||||
@ -2512,8 +2510,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
|
|||||||
Value *OtherOp = Op1I->getOperand(Op1I->getOperand(0) == Op0);
|
Value *OtherOp = Op1I->getOperand(Op1I->getOperand(0) == Op0);
|
||||||
|
|
||||||
Value *NewNot =
|
Value *NewNot =
|
||||||
InsertNewInstBefore(BinaryOperator::CreateNot(*Context,
|
InsertNewInstBefore(BinaryOperator::CreateNot(OtherOp, "B.not"), I);
|
||||||
OtherOp, "B.not"), I);
|
|
||||||
return BinaryOperator::CreateAnd(Op0, NewNot);
|
return BinaryOperator::CreateAnd(Op0, NewNot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2544,7 +2541,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
|
|||||||
return ReplaceInstUsesWith(I, Op0I->getOperand(0));
|
return ReplaceInstUsesWith(I, Op0I->getOperand(0));
|
||||||
} else if (Op0I->getOpcode() == Instruction::Sub) {
|
} else if (Op0I->getOpcode() == Instruction::Sub) {
|
||||||
if (Op0I->getOperand(0) == Op1) // (X-Y)-X == -Y
|
if (Op0I->getOperand(0) == Op1) // (X-Y)-X == -Y
|
||||||
return BinaryOperator::CreateNeg(*Context, Op0I->getOperand(1),
|
return BinaryOperator::CreateNeg(Op0I->getOperand(1),
|
||||||
I.getName());
|
I.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2571,10 +2568,10 @@ Instruction *InstCombiner::visitFSub(BinaryOperator &I) {
|
|||||||
if (BinaryOperator *Op1I = dyn_cast<BinaryOperator>(Op1)) {
|
if (BinaryOperator *Op1I = dyn_cast<BinaryOperator>(Op1)) {
|
||||||
if (Op1I->getOpcode() == Instruction::FAdd) {
|
if (Op1I->getOpcode() == Instruction::FAdd) {
|
||||||
if (Op1I->getOperand(0) == Op0) // X-(X+Y) == -Y
|
if (Op1I->getOperand(0) == Op0) // X-(X+Y) == -Y
|
||||||
return BinaryOperator::CreateFNeg(*Context, Op1I->getOperand(1),
|
return BinaryOperator::CreateFNeg(Op1I->getOperand(1),
|
||||||
I.getName());
|
I.getName());
|
||||||
else if (Op1I->getOperand(1) == Op0) // X-(Y+X) == -Y
|
else if (Op1I->getOperand(1) == Op0) // X-(Y+X) == -Y
|
||||||
return BinaryOperator::CreateFNeg(*Context, Op1I->getOperand(0),
|
return BinaryOperator::CreateFNeg(Op1I->getOperand(0),
|
||||||
I.getName());
|
I.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2635,7 +2632,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
|
|||||||
if (CI->equalsInt(1)) // X * 1 == X
|
if (CI->equalsInt(1)) // X * 1 == X
|
||||||
return ReplaceInstUsesWith(I, Op0);
|
return ReplaceInstUsesWith(I, Op0);
|
||||||
if (CI->isAllOnesValue()) // X * -1 == 0 - X
|
if (CI->isAllOnesValue()) // X * -1 == 0 - X
|
||||||
return BinaryOperator::CreateNeg(*Context, Op0, I.getName());
|
return BinaryOperator::CreateNeg(Op0, I.getName());
|
||||||
|
|
||||||
const APInt& Val = cast<ConstantInt>(CI)->getValue();
|
const APInt& Val = cast<ConstantInt>(CI)->getValue();
|
||||||
if (Val.isPowerOf2()) { // Replace X*(2^C) with X << C
|
if (Val.isPowerOf2()) { // Replace X*(2^C) with X << C
|
||||||
@ -2648,7 +2645,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
|
|||||||
|
|
||||||
if (ConstantVector *Op1V = dyn_cast<ConstantVector>(Op1)) {
|
if (ConstantVector *Op1V = dyn_cast<ConstantVector>(Op1)) {
|
||||||
if (Op1V->isAllOnesValue()) // X * -1 == 0 - X
|
if (Op1V->isAllOnesValue()) // X * -1 == 0 - X
|
||||||
return BinaryOperator::CreateNeg(*Context, Op0, I.getName());
|
return BinaryOperator::CreateNeg(Op0, I.getName());
|
||||||
|
|
||||||
// As above, vector X*splat(1.0) -> X in all defined cases.
|
// As above, vector X*splat(1.0) -> X in all defined cases.
|
||||||
if (Constant *Splat = Op1V->getSplatValue()) {
|
if (Constant *Splat = Op1V->getSplatValue()) {
|
||||||
@ -3061,7 +3058,7 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) {
|
|||||||
if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) {
|
if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) {
|
||||||
// sdiv X, -1 == -X
|
// sdiv X, -1 == -X
|
||||||
if (RHS->isAllOnesValue())
|
if (RHS->isAllOnesValue())
|
||||||
return BinaryOperator::CreateNeg(*Context, Op0);
|
return BinaryOperator::CreateNeg(Op0);
|
||||||
|
|
||||||
// sdiv X, C --> ashr X, log2(C)
|
// sdiv X, C --> ashr X, log2(C)
|
||||||
if (cast<SDivOperator>(&I)->isExact() &&
|
if (cast<SDivOperator>(&I)->isExact() &&
|
||||||
@ -3083,7 +3080,7 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) {
|
|||||||
return BinaryOperator::CreateUDiv(Op0, Op1, I.getName());
|
return BinaryOperator::CreateUDiv(Op0, Op1, I.getName());
|
||||||
}
|
}
|
||||||
ConstantInt *ShiftedInt;
|
ConstantInt *ShiftedInt;
|
||||||
if (match(Op1, m_Shl(m_ConstantInt(ShiftedInt), m_Value()), *Context) &&
|
if (match(Op1, m_Shl(m_ConstantInt(ShiftedInt), m_Value())) &&
|
||||||
ShiftedInt->getValue().isPowerOf2()) {
|
ShiftedInt->getValue().isPowerOf2()) {
|
||||||
// X sdiv (1 << Y) -> X udiv (1 << Y) ( -> X u>> Y)
|
// X sdiv (1 << Y) -> X udiv (1 << Y) ( -> X u>> Y)
|
||||||
// Safe because the only negative value (1 << Y) can take on is
|
// Safe because the only negative value (1 << Y) can take on is
|
||||||
@ -3763,9 +3760,9 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
|
|||||||
|
|
||||||
// This only handles icmp of constants: (icmp1 A, C1) & (icmp2 B, C2).
|
// This only handles icmp of constants: (icmp1 A, C1) & (icmp2 B, C2).
|
||||||
if (!match(LHS, m_ICmp(LHSCC, m_Value(Val),
|
if (!match(LHS, m_ICmp(LHSCC, m_Value(Val),
|
||||||
m_ConstantInt(LHSCst)), *Context) ||
|
m_ConstantInt(LHSCst))) ||
|
||||||
!match(RHS, m_ICmp(RHSCC, m_Value(Val2),
|
!match(RHS, m_ICmp(RHSCC, m_Value(Val2),
|
||||||
m_ConstantInt(RHSCst)), *Context))
|
m_ConstantInt(RHSCst))))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// (icmp ult A, C) & (icmp ult B, C) --> (icmp ult (A|B), C)
|
// (icmp ult A, C) & (icmp ult B, C) --> (icmp ult (A|B), C)
|
||||||
@ -4091,7 +4088,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
|
|||||||
ConstantInt *A = dyn_cast<ConstantInt>(Op0LHS);
|
ConstantInt *A = dyn_cast<ConstantInt>(Op0LHS);
|
||||||
if (!(A && A->isZero()) && // avoid infinite recursion.
|
if (!(A && A->isZero()) && // avoid infinite recursion.
|
||||||
MaskedValueIsZero(Op0LHS, Mask)) {
|
MaskedValueIsZero(Op0LHS, Mask)) {
|
||||||
Instruction *NewNeg = BinaryOperator::CreateNeg(*Context, Op0RHS);
|
Instruction *NewNeg = BinaryOperator::CreateNeg(Op0RHS);
|
||||||
InsertNewInstBefore(NewNeg, I);
|
InsertNewInstBefore(NewNeg, I);
|
||||||
return BinaryOperator::CreateAnd(NewNeg, AndRHS);
|
return BinaryOperator::CreateAnd(NewNeg, AndRHS);
|
||||||
}
|
}
|
||||||
@ -4169,35 +4166,35 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
|
|||||||
Instruction *Or = BinaryOperator::CreateOr(Op0NotVal, Op1NotVal,
|
Instruction *Or = BinaryOperator::CreateOr(Op0NotVal, Op1NotVal,
|
||||||
I.getName()+".demorgan");
|
I.getName()+".demorgan");
|
||||||
InsertNewInstBefore(Or, I);
|
InsertNewInstBefore(Or, I);
|
||||||
return BinaryOperator::CreateNot(*Context, Or);
|
return BinaryOperator::CreateNot(Or);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Value *A = 0, *B = 0, *C = 0, *D = 0;
|
Value *A = 0, *B = 0, *C = 0, *D = 0;
|
||||||
if (match(Op0, m_Or(m_Value(A), m_Value(B)), *Context)) {
|
if (match(Op0, m_Or(m_Value(A), m_Value(B)))) {
|
||||||
if (A == Op1 || B == Op1) // (A | ?) & A --> A
|
if (A == Op1 || B == Op1) // (A | ?) & A --> A
|
||||||
return ReplaceInstUsesWith(I, Op1);
|
return ReplaceInstUsesWith(I, Op1);
|
||||||
|
|
||||||
// (A|B) & ~(A&B) -> A^B
|
// (A|B) & ~(A&B) -> A^B
|
||||||
if (match(Op1, m_Not(m_And(m_Value(C), m_Value(D))), *Context)) {
|
if (match(Op1, m_Not(m_And(m_Value(C), m_Value(D))))) {
|
||||||
if ((A == C && B == D) || (A == D && B == C))
|
if ((A == C && B == D) || (A == D && B == C))
|
||||||
return BinaryOperator::CreateXor(A, B);
|
return BinaryOperator::CreateXor(A, B);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Op1, m_Or(m_Value(A), m_Value(B)), *Context)) {
|
if (match(Op1, m_Or(m_Value(A), m_Value(B)))) {
|
||||||
if (A == Op0 || B == Op0) // A & (A | ?) --> A
|
if (A == Op0 || B == Op0) // A & (A | ?) --> A
|
||||||
return ReplaceInstUsesWith(I, Op0);
|
return ReplaceInstUsesWith(I, Op0);
|
||||||
|
|
||||||
// ~(A&B) & (A|B) -> A^B
|
// ~(A&B) & (A|B) -> A^B
|
||||||
if (match(Op0, m_Not(m_And(m_Value(C), m_Value(D))), *Context)) {
|
if (match(Op0, m_Not(m_And(m_Value(C), m_Value(D))))) {
|
||||||
if ((A == C && B == D) || (A == D && B == C))
|
if ((A == C && B == D) || (A == D && B == C))
|
||||||
return BinaryOperator::CreateXor(A, B);
|
return BinaryOperator::CreateXor(A, B);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Op0->hasOneUse() &&
|
if (Op0->hasOneUse() &&
|
||||||
match(Op0, m_Xor(m_Value(A), m_Value(B)), *Context)) {
|
match(Op0, m_Xor(m_Value(A), m_Value(B)))) {
|
||||||
if (A == Op1) { // (A^B)&A -> A&(A^B)
|
if (A == Op1) { // (A^B)&A -> A&(A^B)
|
||||||
I.swapOperands(); // Simplify below
|
I.swapOperands(); // Simplify below
|
||||||
std::swap(Op0, Op1);
|
std::swap(Op0, Op1);
|
||||||
@ -4209,24 +4206,24 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Op1->hasOneUse() &&
|
if (Op1->hasOneUse() &&
|
||||||
match(Op1, m_Xor(m_Value(A), m_Value(B)), *Context)) {
|
match(Op1, m_Xor(m_Value(A), m_Value(B)))) {
|
||||||
if (B == Op0) { // B&(A^B) -> B&(B^A)
|
if (B == Op0) { // B&(A^B) -> B&(B^A)
|
||||||
cast<BinaryOperator>(Op1)->swapOperands();
|
cast<BinaryOperator>(Op1)->swapOperands();
|
||||||
std::swap(A, B);
|
std::swap(A, B);
|
||||||
}
|
}
|
||||||
if (A == Op0) { // A&(A^B) -> A & ~B
|
if (A == Op0) { // A&(A^B) -> A & ~B
|
||||||
Instruction *NotB = BinaryOperator::CreateNot(*Context, B, "tmp");
|
Instruction *NotB = BinaryOperator::CreateNot(B, "tmp");
|
||||||
InsertNewInstBefore(NotB, I);
|
InsertNewInstBefore(NotB, I);
|
||||||
return BinaryOperator::CreateAnd(A, NotB);
|
return BinaryOperator::CreateAnd(A, NotB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// (A&((~A)|B)) -> A&B
|
// (A&((~A)|B)) -> A&B
|
||||||
if (match(Op0, m_Or(m_Not(m_Specific(Op1)), m_Value(A)), *Context) ||
|
if (match(Op0, m_Or(m_Not(m_Specific(Op1)), m_Value(A))) ||
|
||||||
match(Op0, m_Or(m_Value(A), m_Not(m_Specific(Op1))), *Context))
|
match(Op0, m_Or(m_Value(A), m_Not(m_Specific(Op1)))))
|
||||||
return BinaryOperator::CreateAnd(A, Op1);
|
return BinaryOperator::CreateAnd(A, Op1);
|
||||||
if (match(Op1, m_Or(m_Not(m_Specific(Op0)), m_Value(A)), *Context) ||
|
if (match(Op1, m_Or(m_Not(m_Specific(Op0)), m_Value(A))) ||
|
||||||
match(Op1, m_Or(m_Value(A), m_Not(m_Specific(Op0))), *Context))
|
match(Op1, m_Or(m_Value(A), m_Not(m_Specific(Op0)))))
|
||||||
return BinaryOperator::CreateAnd(A, Op0);
|
return BinaryOperator::CreateAnd(A, Op0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4453,18 +4450,18 @@ static Instruction *MatchSelectFromAndOr(Value *A, Value *B,
|
|||||||
LLVMContext *Context) {
|
LLVMContext *Context) {
|
||||||
// If A is not a select of -1/0, this cannot match.
|
// If A is not a select of -1/0, this cannot match.
|
||||||
Value *Cond = 0;
|
Value *Cond = 0;
|
||||||
if (!match(A, m_SelectCst<-1, 0>(m_Value(Cond)), *Context))
|
if (!match(A, m_SelectCst<-1, 0>(m_Value(Cond))))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// ((cond?-1:0)&C) | (B&(cond?0:-1)) -> cond ? C : B.
|
// ((cond?-1:0)&C) | (B&(cond?0:-1)) -> cond ? C : B.
|
||||||
if (match(D, m_SelectCst<0, -1>(m_Specific(Cond)), *Context))
|
if (match(D, m_SelectCst<0, -1>(m_Specific(Cond))))
|
||||||
return SelectInst::Create(Cond, C, B);
|
return SelectInst::Create(Cond, C, B);
|
||||||
if (match(D, m_Not(m_SelectCst<-1, 0>(m_Specific(Cond))), *Context))
|
if (match(D, m_Not(m_SelectCst<-1, 0>(m_Specific(Cond)))))
|
||||||
return SelectInst::Create(Cond, C, B);
|
return SelectInst::Create(Cond, C, B);
|
||||||
// ((cond?-1:0)&C) | ((cond?0:-1)&D) -> cond ? C : D.
|
// ((cond?-1:0)&C) | ((cond?0:-1)&D) -> cond ? C : D.
|
||||||
if (match(B, m_SelectCst<0, -1>(m_Specific(Cond)), *Context))
|
if (match(B, m_SelectCst<0, -1>(m_Specific(Cond))))
|
||||||
return SelectInst::Create(Cond, C, D);
|
return SelectInst::Create(Cond, C, D);
|
||||||
if (match(B, m_Not(m_SelectCst<-1, 0>(m_Specific(Cond))), *Context))
|
if (match(B, m_Not(m_SelectCst<-1, 0>(m_Specific(Cond)))))
|
||||||
return SelectInst::Create(Cond, C, D);
|
return SelectInst::Create(Cond, C, D);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -4478,9 +4475,9 @@ Instruction *InstCombiner::FoldOrOfICmps(Instruction &I,
|
|||||||
|
|
||||||
// This only handles icmp of constants: (icmp1 A, C1) | (icmp2 B, C2).
|
// This only handles icmp of constants: (icmp1 A, C1) | (icmp2 B, C2).
|
||||||
if (!match(LHS, m_ICmp(LHSCC, m_Value(Val),
|
if (!match(LHS, m_ICmp(LHSCC, m_Value(Val),
|
||||||
m_ConstantInt(LHSCst)), *Context) ||
|
m_ConstantInt(LHSCst))) ||
|
||||||
!match(RHS, m_ICmp(RHSCC, m_Value(Val2),
|
!match(RHS, m_ICmp(RHSCC, m_Value(Val2),
|
||||||
m_ConstantInt(RHSCst)), *Context))
|
m_ConstantInt(RHSCst))))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// From here on, we only handle:
|
// From here on, we only handle:
|
||||||
@ -4717,7 +4714,7 @@ Instruction *InstCombiner::FoldOrWithConstants(BinaryOperator &I, Value *Op,
|
|||||||
|
|
||||||
Value *V1 = 0;
|
Value *V1 = 0;
|
||||||
ConstantInt *CI2 = 0;
|
ConstantInt *CI2 = 0;
|
||||||
if (!match(Op, m_And(m_Value(V1), m_ConstantInt(CI2)), *Context)) return 0;
|
if (!match(Op, m_And(m_Value(V1), m_ConstantInt(CI2)))) return 0;
|
||||||
|
|
||||||
APInt Xor = CI1->getValue() ^ CI2->getValue();
|
APInt Xor = CI1->getValue() ^ CI2->getValue();
|
||||||
if (!Xor.isAllOnesValue()) return 0;
|
if (!Xor.isAllOnesValue()) return 0;
|
||||||
@ -4759,7 +4756,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
|
|||||||
if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) {
|
if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) {
|
||||||
ConstantInt *C1 = 0; Value *X = 0;
|
ConstantInt *C1 = 0; Value *X = 0;
|
||||||
// (X & C1) | C2 --> (X | C2) & (C1|C2)
|
// (X & C1) | C2 --> (X | C2) & (C1|C2)
|
||||||
if (match(Op0, m_And(m_Value(X), m_ConstantInt(C1)), *Context) &&
|
if (match(Op0, m_And(m_Value(X), m_ConstantInt(C1))) &&
|
||||||
isOnlyUse(Op0)) {
|
isOnlyUse(Op0)) {
|
||||||
Instruction *Or = BinaryOperator::CreateOr(X, RHS);
|
Instruction *Or = BinaryOperator::CreateOr(X, RHS);
|
||||||
InsertNewInstBefore(Or, I);
|
InsertNewInstBefore(Or, I);
|
||||||
@ -4769,7 +4766,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// (X ^ C1) | C2 --> (X | C2) ^ (C1&~C2)
|
// (X ^ C1) | C2 --> (X | C2) ^ (C1&~C2)
|
||||||
if (match(Op0, m_Xor(m_Value(X), m_ConstantInt(C1)), *Context) &&
|
if (match(Op0, m_Xor(m_Value(X), m_ConstantInt(C1))) &&
|
||||||
isOnlyUse(Op0)) {
|
isOnlyUse(Op0)) {
|
||||||
Instruction *Or = BinaryOperator::CreateOr(X, RHS);
|
Instruction *Or = BinaryOperator::CreateOr(X, RHS);
|
||||||
InsertNewInstBefore(Or, I);
|
InsertNewInstBefore(Or, I);
|
||||||
@ -4790,26 +4787,26 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
|
|||||||
Value *A = 0, *B = 0;
|
Value *A = 0, *B = 0;
|
||||||
ConstantInt *C1 = 0, *C2 = 0;
|
ConstantInt *C1 = 0, *C2 = 0;
|
||||||
|
|
||||||
if (match(Op0, m_And(m_Value(A), m_Value(B)), *Context))
|
if (match(Op0, m_And(m_Value(A), m_Value(B))))
|
||||||
if (A == Op1 || B == Op1) // (A & ?) | A --> A
|
if (A == Op1 || B == Op1) // (A & ?) | A --> A
|
||||||
return ReplaceInstUsesWith(I, Op1);
|
return ReplaceInstUsesWith(I, Op1);
|
||||||
if (match(Op1, m_And(m_Value(A), m_Value(B)), *Context))
|
if (match(Op1, m_And(m_Value(A), m_Value(B))))
|
||||||
if (A == Op0 || B == Op0) // A | (A & ?) --> A
|
if (A == Op0 || B == Op0) // A | (A & ?) --> A
|
||||||
return ReplaceInstUsesWith(I, Op0);
|
return ReplaceInstUsesWith(I, Op0);
|
||||||
|
|
||||||
// (A | B) | C and A | (B | C) -> bswap if possible.
|
// (A | B) | C and A | (B | C) -> bswap if possible.
|
||||||
// (A >> B) | (C << D) and (A << B) | (B >> C) -> bswap if possible.
|
// (A >> B) | (C << D) and (A << B) | (B >> C) -> bswap if possible.
|
||||||
if (match(Op0, m_Or(m_Value(), m_Value()), *Context) ||
|
if (match(Op0, m_Or(m_Value(), m_Value())) ||
|
||||||
match(Op1, m_Or(m_Value(), m_Value()), *Context) ||
|
match(Op1, m_Or(m_Value(), m_Value())) ||
|
||||||
(match(Op0, m_Shift(m_Value(), m_Value()), *Context) &&
|
(match(Op0, m_Shift(m_Value(), m_Value())) &&
|
||||||
match(Op1, m_Shift(m_Value(), m_Value()), *Context))) {
|
match(Op1, m_Shift(m_Value(), m_Value())))) {
|
||||||
if (Instruction *BSwap = MatchBSwap(I))
|
if (Instruction *BSwap = MatchBSwap(I))
|
||||||
return BSwap;
|
return BSwap;
|
||||||
}
|
}
|
||||||
|
|
||||||
// (X^C)|Y -> (X|Y)^C iff Y&C == 0
|
// (X^C)|Y -> (X|Y)^C iff Y&C == 0
|
||||||
if (Op0->hasOneUse() &&
|
if (Op0->hasOneUse() &&
|
||||||
match(Op0, m_Xor(m_Value(A), m_ConstantInt(C1)), *Context) &&
|
match(Op0, m_Xor(m_Value(A), m_ConstantInt(C1))) &&
|
||||||
MaskedValueIsZero(Op1, C1->getValue())) {
|
MaskedValueIsZero(Op1, C1->getValue())) {
|
||||||
Instruction *NOr = BinaryOperator::CreateOr(A, Op1);
|
Instruction *NOr = BinaryOperator::CreateOr(A, Op1);
|
||||||
InsertNewInstBefore(NOr, I);
|
InsertNewInstBefore(NOr, I);
|
||||||
@ -4819,7 +4816,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
|
|||||||
|
|
||||||
// Y|(X^C) -> (X|Y)^C iff Y&C == 0
|
// Y|(X^C) -> (X|Y)^C iff Y&C == 0
|
||||||
if (Op1->hasOneUse() &&
|
if (Op1->hasOneUse() &&
|
||||||
match(Op1, m_Xor(m_Value(A), m_ConstantInt(C1)), *Context) &&
|
match(Op1, m_Xor(m_Value(A), m_ConstantInt(C1))) &&
|
||||||
MaskedValueIsZero(Op0, C1->getValue())) {
|
MaskedValueIsZero(Op0, C1->getValue())) {
|
||||||
Instruction *NOr = BinaryOperator::CreateOr(A, Op0);
|
Instruction *NOr = BinaryOperator::CreateOr(A, Op0);
|
||||||
InsertNewInstBefore(NOr, I);
|
InsertNewInstBefore(NOr, I);
|
||||||
@ -4829,8 +4826,8 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
|
|||||||
|
|
||||||
// (A & C)|(B & D)
|
// (A & C)|(B & D)
|
||||||
Value *C = 0, *D = 0;
|
Value *C = 0, *D = 0;
|
||||||
if (match(Op0, m_And(m_Value(A), m_Value(C)), *Context) &&
|
if (match(Op0, m_And(m_Value(A), m_Value(C))) &&
|
||||||
match(Op1, m_And(m_Value(B), m_Value(D)), *Context)) {
|
match(Op1, m_And(m_Value(B), m_Value(D)))) {
|
||||||
Value *V1 = 0, *V2 = 0, *V3 = 0;
|
Value *V1 = 0, *V2 = 0, *V3 = 0;
|
||||||
C1 = dyn_cast<ConstantInt>(C);
|
C1 = dyn_cast<ConstantInt>(C);
|
||||||
C2 = dyn_cast<ConstantInt>(D);
|
C2 = dyn_cast<ConstantInt>(D);
|
||||||
@ -4840,7 +4837,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
|
|||||||
// replace with V+N.
|
// replace with V+N.
|
||||||
if (C1->getValue() == ~C2->getValue()) {
|
if (C1->getValue() == ~C2->getValue()) {
|
||||||
if ((C2->getValue() & (C2->getValue()+1)) == 0 && // C2 == 0+1+
|
if ((C2->getValue() & (C2->getValue()+1)) == 0 && // C2 == 0+1+
|
||||||
match(A, m_Add(m_Value(V1), m_Value(V2)), *Context)) {
|
match(A, m_Add(m_Value(V1), m_Value(V2)))) {
|
||||||
// Add commutes, try both ways.
|
// Add commutes, try both ways.
|
||||||
if (V1 == B && MaskedValueIsZero(V2, C2->getValue()))
|
if (V1 == B && MaskedValueIsZero(V2, C2->getValue()))
|
||||||
return ReplaceInstUsesWith(I, A);
|
return ReplaceInstUsesWith(I, A);
|
||||||
@ -4849,7 +4846,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
|
|||||||
}
|
}
|
||||||
// Or commutes, try both ways.
|
// Or commutes, try both ways.
|
||||||
if ((C1->getValue() & (C1->getValue()+1)) == 0 &&
|
if ((C1->getValue() & (C1->getValue()+1)) == 0 &&
|
||||||
match(B, m_Add(m_Value(V1), m_Value(V2)), *Context)) {
|
match(B, m_Add(m_Value(V1), m_Value(V2)))) {
|
||||||
// Add commutes, try both ways.
|
// Add commutes, try both ways.
|
||||||
if (V1 == A && MaskedValueIsZero(V2, C1->getValue()))
|
if (V1 == A && MaskedValueIsZero(V2, C1->getValue()))
|
||||||
return ReplaceInstUsesWith(I, B);
|
return ReplaceInstUsesWith(I, B);
|
||||||
@ -4890,20 +4887,20 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
|
|||||||
return Match;
|
return Match;
|
||||||
|
|
||||||
// ((A&~B)|(~A&B)) -> A^B
|
// ((A&~B)|(~A&B)) -> A^B
|
||||||
if ((match(C, m_Not(m_Specific(D)), *Context) &&
|
if ((match(C, m_Not(m_Specific(D))) &&
|
||||||
match(B, m_Not(m_Specific(A)), *Context)))
|
match(B, m_Not(m_Specific(A)))))
|
||||||
return BinaryOperator::CreateXor(A, D);
|
return BinaryOperator::CreateXor(A, D);
|
||||||
// ((~B&A)|(~A&B)) -> A^B
|
// ((~B&A)|(~A&B)) -> A^B
|
||||||
if ((match(A, m_Not(m_Specific(D)), *Context) &&
|
if ((match(A, m_Not(m_Specific(D))) &&
|
||||||
match(B, m_Not(m_Specific(C)), *Context)))
|
match(B, m_Not(m_Specific(C)))))
|
||||||
return BinaryOperator::CreateXor(C, D);
|
return BinaryOperator::CreateXor(C, D);
|
||||||
// ((A&~B)|(B&~A)) -> A^B
|
// ((A&~B)|(B&~A)) -> A^B
|
||||||
if ((match(C, m_Not(m_Specific(B)), *Context) &&
|
if ((match(C, m_Not(m_Specific(B))) &&
|
||||||
match(D, m_Not(m_Specific(A)), *Context)))
|
match(D, m_Not(m_Specific(A)))))
|
||||||
return BinaryOperator::CreateXor(A, B);
|
return BinaryOperator::CreateXor(A, B);
|
||||||
// ((~B&A)|(B&~A)) -> A^B
|
// ((~B&A)|(B&~A)) -> A^B
|
||||||
if ((match(A, m_Not(m_Specific(B)), *Context) &&
|
if ((match(A, m_Not(m_Specific(B))) &&
|
||||||
match(D, m_Not(m_Specific(C)), *Context)))
|
match(D, m_Not(m_Specific(C)))))
|
||||||
return BinaryOperator::CreateXor(C, B);
|
return BinaryOperator::CreateXor(C, B);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4923,26 +4920,26 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ((A|B)&1)|(B&-2) -> (A&1) | B
|
// ((A|B)&1)|(B&-2) -> (A&1) | B
|
||||||
if (match(Op0, m_And(m_Or(m_Value(A), m_Value(B)), m_Value(C)), *Context) ||
|
if (match(Op0, m_And(m_Or(m_Value(A), m_Value(B)), m_Value(C))) ||
|
||||||
match(Op0, m_And(m_Value(C), m_Or(m_Value(A), m_Value(B))), *Context)) {
|
match(Op0, m_And(m_Value(C), m_Or(m_Value(A), m_Value(B))))) {
|
||||||
Instruction *Ret = FoldOrWithConstants(I, Op1, A, B, C);
|
Instruction *Ret = FoldOrWithConstants(I, Op1, A, B, C);
|
||||||
if (Ret) return Ret;
|
if (Ret) return Ret;
|
||||||
}
|
}
|
||||||
// (B&-2)|((A|B)&1) -> (A&1) | B
|
// (B&-2)|((A|B)&1) -> (A&1) | B
|
||||||
if (match(Op1, m_And(m_Or(m_Value(A), m_Value(B)), m_Value(C)), *Context) ||
|
if (match(Op1, m_And(m_Or(m_Value(A), m_Value(B)), m_Value(C))) ||
|
||||||
match(Op1, m_And(m_Value(C), m_Or(m_Value(A), m_Value(B))), *Context)) {
|
match(Op1, m_And(m_Value(C), m_Or(m_Value(A), m_Value(B))))) {
|
||||||
Instruction *Ret = FoldOrWithConstants(I, Op0, A, B, C);
|
Instruction *Ret = FoldOrWithConstants(I, Op0, A, B, C);
|
||||||
if (Ret) return Ret;
|
if (Ret) return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Op0, m_Not(m_Value(A)), *Context)) { // ~A | Op1
|
if (match(Op0, m_Not(m_Value(A)))) { // ~A | Op1
|
||||||
if (A == Op1) // ~A | A == -1
|
if (A == Op1) // ~A | A == -1
|
||||||
return ReplaceInstUsesWith(I, Constant::getAllOnesValue(I.getType()));
|
return ReplaceInstUsesWith(I, Constant::getAllOnesValue(I.getType()));
|
||||||
} else {
|
} else {
|
||||||
A = 0;
|
A = 0;
|
||||||
}
|
}
|
||||||
// Note, A is still live here!
|
// Note, A is still live here!
|
||||||
if (match(Op1, m_Not(m_Value(B)), *Context)) { // Op0 | ~B
|
if (match(Op1, m_Not(m_Value(B)))) { // Op0 | ~B
|
||||||
if (Op0 == B)
|
if (Op0 == B)
|
||||||
return ReplaceInstUsesWith(I, Constant::getAllOnesValue(I.getType()));
|
return ReplaceInstUsesWith(I, Constant::getAllOnesValue(I.getType()));
|
||||||
|
|
||||||
@ -4950,7 +4947,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
|
|||||||
if (A && isOnlyUse(Op0) && isOnlyUse(Op1)) {
|
if (A && isOnlyUse(Op0) && isOnlyUse(Op1)) {
|
||||||
Value *And = InsertNewInstBefore(BinaryOperator::CreateAnd(A, B,
|
Value *And = InsertNewInstBefore(BinaryOperator::CreateAnd(A, B,
|
||||||
I.getName()+".demorgan"), I);
|
I.getName()+".demorgan"), I);
|
||||||
return BinaryOperator::CreateNot(*Context, And);
|
return BinaryOperator::CreateNot(And);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5050,7 +5047,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||||||
if (dyn_castNotVal(Op0I->getOperand(1))) Op0I->swapOperands();
|
if (dyn_castNotVal(Op0I->getOperand(1))) Op0I->swapOperands();
|
||||||
if (Value *Op0NotVal = dyn_castNotVal(Op0I->getOperand(0))) {
|
if (Value *Op0NotVal = dyn_castNotVal(Op0I->getOperand(0))) {
|
||||||
Instruction *NotY =
|
Instruction *NotY =
|
||||||
BinaryOperator::CreateNot(*Context, Op0I->getOperand(1),
|
BinaryOperator::CreateNot(Op0I->getOperand(1),
|
||||||
Op0I->getOperand(1)->getName()+".not");
|
Op0I->getOperand(1)->getName()+".not");
|
||||||
InsertNewInstBefore(NotY, I);
|
InsertNewInstBefore(NotY, I);
|
||||||
if (Op0I->getOpcode() == Instruction::And)
|
if (Op0I->getOpcode() == Instruction::And)
|
||||||
@ -5161,7 +5158,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||||||
BinaryOperator *Op1I = dyn_cast<BinaryOperator>(Op1);
|
BinaryOperator *Op1I = dyn_cast<BinaryOperator>(Op1);
|
||||||
if (Op1I) {
|
if (Op1I) {
|
||||||
Value *A, *B;
|
Value *A, *B;
|
||||||
if (match(Op1I, m_Or(m_Value(A), m_Value(B)), *Context)) {
|
if (match(Op1I, m_Or(m_Value(A), m_Value(B)))) {
|
||||||
if (A == Op0) { // B^(B|A) == (A|B)^B
|
if (A == Op0) { // B^(B|A) == (A|B)^B
|
||||||
Op1I->swapOperands();
|
Op1I->swapOperands();
|
||||||
I.swapOperands();
|
I.swapOperands();
|
||||||
@ -5170,11 +5167,11 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||||||
I.swapOperands(); // Simplified below.
|
I.swapOperands(); // Simplified below.
|
||||||
std::swap(Op0, Op1);
|
std::swap(Op0, Op1);
|
||||||
}
|
}
|
||||||
} else if (match(Op1I, m_Xor(m_Specific(Op0), m_Value(B)), *Context)) {
|
} else if (match(Op1I, m_Xor(m_Specific(Op0), m_Value(B)))) {
|
||||||
return ReplaceInstUsesWith(I, B); // A^(A^B) == B
|
return ReplaceInstUsesWith(I, B); // A^(A^B) == B
|
||||||
} else if (match(Op1I, m_Xor(m_Value(A), m_Specific(Op0)), *Context)) {
|
} else if (match(Op1I, m_Xor(m_Value(A), m_Specific(Op0)))) {
|
||||||
return ReplaceInstUsesWith(I, A); // A^(B^A) == B
|
return ReplaceInstUsesWith(I, A); // A^(B^A) == B
|
||||||
} else if (match(Op1I, m_And(m_Value(A), m_Value(B)), *Context) &&
|
} else if (match(Op1I, m_And(m_Value(A), m_Value(B))) &&
|
||||||
Op1I->hasOneUse()){
|
Op1I->hasOneUse()){
|
||||||
if (A == Op0) { // A^(A&B) -> A^(B&A)
|
if (A == Op0) { // A^(A&B) -> A^(B&A)
|
||||||
Op1I->swapOperands();
|
Op1I->swapOperands();
|
||||||
@ -5190,28 +5187,27 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||||||
BinaryOperator *Op0I = dyn_cast<BinaryOperator>(Op0);
|
BinaryOperator *Op0I = dyn_cast<BinaryOperator>(Op0);
|
||||||
if (Op0I) {
|
if (Op0I) {
|
||||||
Value *A, *B;
|
Value *A, *B;
|
||||||
if (match(Op0I, m_Or(m_Value(A), m_Value(B)), *Context) &&
|
if (match(Op0I, m_Or(m_Value(A), m_Value(B))) &&
|
||||||
Op0I->hasOneUse()) {
|
Op0I->hasOneUse()) {
|
||||||
if (A == Op1) // (B|A)^B == (A|B)^B
|
if (A == Op1) // (B|A)^B == (A|B)^B
|
||||||
std::swap(A, B);
|
std::swap(A, B);
|
||||||
if (B == Op1) { // (A|B)^B == A & ~B
|
if (B == Op1) { // (A|B)^B == A & ~B
|
||||||
Instruction *NotB =
|
Instruction *NotB =
|
||||||
InsertNewInstBefore(BinaryOperator::CreateNot(*Context,
|
InsertNewInstBefore(BinaryOperator::CreateNot(Op1, "tmp"), I);
|
||||||
Op1, "tmp"), I);
|
|
||||||
return BinaryOperator::CreateAnd(A, NotB);
|
return BinaryOperator::CreateAnd(A, NotB);
|
||||||
}
|
}
|
||||||
} else if (match(Op0I, m_Xor(m_Specific(Op1), m_Value(B)), *Context)) {
|
} else if (match(Op0I, m_Xor(m_Specific(Op1), m_Value(B)))) {
|
||||||
return ReplaceInstUsesWith(I, B); // (A^B)^A == B
|
return ReplaceInstUsesWith(I, B); // (A^B)^A == B
|
||||||
} else if (match(Op0I, m_Xor(m_Value(A), m_Specific(Op1)), *Context)) {
|
} else if (match(Op0I, m_Xor(m_Value(A), m_Specific(Op1)))) {
|
||||||
return ReplaceInstUsesWith(I, A); // (B^A)^A == B
|
return ReplaceInstUsesWith(I, A); // (B^A)^A == B
|
||||||
} else if (match(Op0I, m_And(m_Value(A), m_Value(B)), *Context) &&
|
} else if (match(Op0I, m_And(m_Value(A), m_Value(B))) &&
|
||||||
Op0I->hasOneUse()){
|
Op0I->hasOneUse()){
|
||||||
if (A == Op1) // (A&B)^A -> (B&A)^A
|
if (A == Op1) // (A&B)^A -> (B&A)^A
|
||||||
std::swap(A, B);
|
std::swap(A, B);
|
||||||
if (B == Op1 && // (B&A)^A == ~B & A
|
if (B == Op1 && // (B&A)^A == ~B & A
|
||||||
!isa<ConstantInt>(Op1)) { // Canonical form is (B&C)^C
|
!isa<ConstantInt>(Op1)) { // Canonical form is (B&C)^C
|
||||||
Instruction *N =
|
Instruction *N =
|
||||||
InsertNewInstBefore(BinaryOperator::CreateNot(*Context, A, "tmp"), I);
|
InsertNewInstBefore(BinaryOperator::CreateNot(A, "tmp"), I);
|
||||||
return BinaryOperator::CreateAnd(N, Op1);
|
return BinaryOperator::CreateAnd(N, Op1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5233,22 +5229,22 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||||||
if (Op0I && Op1I) {
|
if (Op0I && Op1I) {
|
||||||
Value *A, *B, *C, *D;
|
Value *A, *B, *C, *D;
|
||||||
// (A & B)^(A | B) -> A ^ B
|
// (A & B)^(A | B) -> A ^ B
|
||||||
if (match(Op0I, m_And(m_Value(A), m_Value(B)), *Context) &&
|
if (match(Op0I, m_And(m_Value(A), m_Value(B))) &&
|
||||||
match(Op1I, m_Or(m_Value(C), m_Value(D)), *Context)) {
|
match(Op1I, m_Or(m_Value(C), m_Value(D)))) {
|
||||||
if ((A == C && B == D) || (A == D && B == C))
|
if ((A == C && B == D) || (A == D && B == C))
|
||||||
return BinaryOperator::CreateXor(A, B);
|
return BinaryOperator::CreateXor(A, B);
|
||||||
}
|
}
|
||||||
// (A | B)^(A & B) -> A ^ B
|
// (A | B)^(A & B) -> A ^ B
|
||||||
if (match(Op0I, m_Or(m_Value(A), m_Value(B)), *Context) &&
|
if (match(Op0I, m_Or(m_Value(A), m_Value(B))) &&
|
||||||
match(Op1I, m_And(m_Value(C), m_Value(D)), *Context)) {
|
match(Op1I, m_And(m_Value(C), m_Value(D)))) {
|
||||||
if ((A == C && B == D) || (A == D && B == C))
|
if ((A == C && B == D) || (A == D && B == C))
|
||||||
return BinaryOperator::CreateXor(A, B);
|
return BinaryOperator::CreateXor(A, B);
|
||||||
}
|
}
|
||||||
|
|
||||||
// (A & B)^(C & D)
|
// (A & B)^(C & D)
|
||||||
if ((Op0I->hasOneUse() || Op1I->hasOneUse()) &&
|
if ((Op0I->hasOneUse() || Op1I->hasOneUse()) &&
|
||||||
match(Op0I, m_And(m_Value(A), m_Value(B)), *Context) &&
|
match(Op0I, m_And(m_Value(A), m_Value(B))) &&
|
||||||
match(Op1I, m_And(m_Value(C), m_Value(D)), *Context)) {
|
match(Op1I, m_And(m_Value(C), m_Value(D)))) {
|
||||||
// (X & Y)^(X & Y) -> (Y^Z) & X
|
// (X & Y)^(X & Y) -> (Y^Z) & X
|
||||||
Value *X = 0, *Y = 0, *Z = 0;
|
Value *X = 0, *Y = 0, *Z = 0;
|
||||||
if (A == C)
|
if (A == C)
|
||||||
@ -6002,7 +5998,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
case ICmpInst::ICMP_EQ: { // icmp eq i1 A, B -> ~(A^B)
|
case ICmpInst::ICMP_EQ: { // icmp eq i1 A, B -> ~(A^B)
|
||||||
Instruction *Xor = BinaryOperator::CreateXor(Op0, Op1, I.getName()+"tmp");
|
Instruction *Xor = BinaryOperator::CreateXor(Op0, Op1, I.getName()+"tmp");
|
||||||
InsertNewInstBefore(Xor, I);
|
InsertNewInstBefore(Xor, I);
|
||||||
return BinaryOperator::CreateNot(*Context, Xor);
|
return BinaryOperator::CreateNot(Xor);
|
||||||
}
|
}
|
||||||
case ICmpInst::ICMP_NE: // icmp eq i1 A, B -> A^B
|
case ICmpInst::ICMP_NE: // icmp eq i1 A, B -> A^B
|
||||||
return BinaryOperator::CreateXor(Op0, Op1);
|
return BinaryOperator::CreateXor(Op0, Op1);
|
||||||
@ -6011,8 +6007,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
std::swap(Op0, Op1); // Change icmp ugt -> icmp ult
|
std::swap(Op0, Op1); // Change icmp ugt -> icmp ult
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
case ICmpInst::ICMP_ULT:{ // icmp ult i1 A, B -> ~A & B
|
case ICmpInst::ICMP_ULT:{ // icmp ult i1 A, B -> ~A & B
|
||||||
Instruction *Not = BinaryOperator::CreateNot(*Context,
|
Instruction *Not = BinaryOperator::CreateNot(Op0, I.getName()+"tmp");
|
||||||
Op0, I.getName()+"tmp");
|
|
||||||
InsertNewInstBefore(Not, I);
|
InsertNewInstBefore(Not, I);
|
||||||
return BinaryOperator::CreateAnd(Not, Op1);
|
return BinaryOperator::CreateAnd(Not, Op1);
|
||||||
}
|
}
|
||||||
@ -6020,8 +6015,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
std::swap(Op0, Op1); // Change icmp sgt -> icmp slt
|
std::swap(Op0, Op1); // Change icmp sgt -> icmp slt
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
case ICmpInst::ICMP_SLT: { // icmp slt i1 A, B -> A & ~B
|
case ICmpInst::ICMP_SLT: { // icmp slt i1 A, B -> A & ~B
|
||||||
Instruction *Not = BinaryOperator::CreateNot(*Context,
|
Instruction *Not = BinaryOperator::CreateNot(Op1, I.getName()+"tmp");
|
||||||
Op1, I.getName()+"tmp");
|
|
||||||
InsertNewInstBefore(Not, I);
|
InsertNewInstBefore(Not, I);
|
||||||
return BinaryOperator::CreateAnd(Not, Op0);
|
return BinaryOperator::CreateAnd(Not, Op0);
|
||||||
}
|
}
|
||||||
@ -6029,8 +6023,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
std::swap(Op0, Op1); // Change icmp uge -> icmp ule
|
std::swap(Op0, Op1); // Change icmp uge -> icmp ule
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
case ICmpInst::ICMP_ULE: { // icmp ule i1 A, B -> ~A | B
|
case ICmpInst::ICMP_ULE: { // icmp ule i1 A, B -> ~A | B
|
||||||
Instruction *Not = BinaryOperator::CreateNot(*Context,
|
Instruction *Not = BinaryOperator::CreateNot(Op0, I.getName()+"tmp");
|
||||||
Op0, I.getName()+"tmp");
|
|
||||||
InsertNewInstBefore(Not, I);
|
InsertNewInstBefore(Not, I);
|
||||||
return BinaryOperator::CreateOr(Not, Op1);
|
return BinaryOperator::CreateOr(Not, Op1);
|
||||||
}
|
}
|
||||||
@ -6038,8 +6031,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
std::swap(Op0, Op1); // Change icmp sge -> icmp sle
|
std::swap(Op0, Op1); // Change icmp sge -> icmp sle
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
case ICmpInst::ICMP_SLE: { // icmp sle i1 A, B -> A | ~B
|
case ICmpInst::ICMP_SLE: { // icmp sle i1 A, B -> A | ~B
|
||||||
Instruction *Not = BinaryOperator::CreateNot(*Context,
|
Instruction *Not = BinaryOperator::CreateNot(Op1, I.getName()+"tmp");
|
||||||
Op1, I.getName()+"tmp");
|
|
||||||
InsertNewInstBefore(Not, I);
|
InsertNewInstBefore(Not, I);
|
||||||
return BinaryOperator::CreateOr(Not, Op0);
|
return BinaryOperator::CreateOr(Not, Op0);
|
||||||
}
|
}
|
||||||
@ -6060,7 +6052,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
|
|
||||||
// (icmp ne/eq (sub A B) 0) -> (icmp ne/eq A, B)
|
// (icmp ne/eq (sub A B) 0) -> (icmp ne/eq A, B)
|
||||||
if (I.isEquality() && CI->isNullValue() &&
|
if (I.isEquality() && CI->isNullValue() &&
|
||||||
match(Op0, m_Sub(m_Value(A), m_Value(B)), *Context)) {
|
match(Op0, m_Sub(m_Value(A), m_Value(B)))) {
|
||||||
// (icmp cond A B) if cond is equality
|
// (icmp cond A B) if cond is equality
|
||||||
return new ICmpInst(*Context, I.getPredicate(), A, B);
|
return new ICmpInst(*Context, I.getPredicate(), A, B);
|
||||||
}
|
}
|
||||||
@ -6458,8 +6450,8 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
|
|
||||||
// ~x < ~y --> y < x
|
// ~x < ~y --> y < x
|
||||||
{ Value *A, *B;
|
{ Value *A, *B;
|
||||||
if (match(Op0, m_Not(m_Value(A)), *Context) &&
|
if (match(Op0, m_Not(m_Value(A))) &&
|
||||||
match(Op1, m_Not(m_Value(B)), *Context))
|
match(Op1, m_Not(m_Value(B))))
|
||||||
return new ICmpInst(*Context, I.getPredicate(), B, A);
|
return new ICmpInst(*Context, I.getPredicate(), B, A);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6467,22 +6459,22 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
Value *A, *B, *C, *D;
|
Value *A, *B, *C, *D;
|
||||||
|
|
||||||
// -x == -y --> x == y
|
// -x == -y --> x == y
|
||||||
if (match(Op0, m_Neg(m_Value(A)), *Context) &&
|
if (match(Op0, m_Neg(m_Value(A))) &&
|
||||||
match(Op1, m_Neg(m_Value(B)), *Context))
|
match(Op1, m_Neg(m_Value(B))))
|
||||||
return new ICmpInst(*Context, I.getPredicate(), A, B);
|
return new ICmpInst(*Context, I.getPredicate(), A, B);
|
||||||
|
|
||||||
if (match(Op0, m_Xor(m_Value(A), m_Value(B)), *Context)) {
|
if (match(Op0, m_Xor(m_Value(A), m_Value(B)))) {
|
||||||
if (A == Op1 || B == Op1) { // (A^B) == A -> B == 0
|
if (A == Op1 || B == Op1) { // (A^B) == A -> B == 0
|
||||||
Value *OtherVal = A == Op1 ? B : A;
|
Value *OtherVal = A == Op1 ? B : A;
|
||||||
return new ICmpInst(*Context, I.getPredicate(), OtherVal,
|
return new ICmpInst(*Context, I.getPredicate(), OtherVal,
|
||||||
Constant::getNullValue(A->getType()));
|
Constant::getNullValue(A->getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Op1, m_Xor(m_Value(C), m_Value(D)), *Context)) {
|
if (match(Op1, m_Xor(m_Value(C), m_Value(D)))) {
|
||||||
// A^c1 == C^c2 --> A == C^(c1^c2)
|
// A^c1 == C^c2 --> A == C^(c1^c2)
|
||||||
ConstantInt *C1, *C2;
|
ConstantInt *C1, *C2;
|
||||||
if (match(B, m_ConstantInt(C1), *Context) &&
|
if (match(B, m_ConstantInt(C1)) &&
|
||||||
match(D, m_ConstantInt(C2), *Context) && Op1->hasOneUse()) {
|
match(D, m_ConstantInt(C2)) && Op1->hasOneUse()) {
|
||||||
Constant *NC =
|
Constant *NC =
|
||||||
ConstantInt::get(*Context, C1->getValue() ^ C2->getValue());
|
ConstantInt::get(*Context, C1->getValue() ^ C2->getValue());
|
||||||
Instruction *Xor = BinaryOperator::CreateXor(C, NC, "tmp");
|
Instruction *Xor = BinaryOperator::CreateXor(C, NC, "tmp");
|
||||||
@ -6498,7 +6490,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Op1, m_Xor(m_Value(A), m_Value(B)), *Context) &&
|
if (match(Op1, m_Xor(m_Value(A), m_Value(B))) &&
|
||||||
(A == Op0 || B == Op0)) {
|
(A == Op0 || B == Op0)) {
|
||||||
// A == (A^B) -> B == 0
|
// A == (A^B) -> B == 0
|
||||||
Value *OtherVal = A == Op0 ? B : A;
|
Value *OtherVal = A == Op0 ? B : A;
|
||||||
@ -6507,19 +6499,19 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// (A-B) == A -> B == 0
|
// (A-B) == A -> B == 0
|
||||||
if (match(Op0, m_Sub(m_Specific(Op1), m_Value(B)), *Context))
|
if (match(Op0, m_Sub(m_Specific(Op1), m_Value(B))))
|
||||||
return new ICmpInst(*Context, I.getPredicate(), B,
|
return new ICmpInst(*Context, I.getPredicate(), B,
|
||||||
Constant::getNullValue(B->getType()));
|
Constant::getNullValue(B->getType()));
|
||||||
|
|
||||||
// A == (A-B) -> B == 0
|
// A == (A-B) -> B == 0
|
||||||
if (match(Op1, m_Sub(m_Specific(Op0), m_Value(B)), *Context))
|
if (match(Op1, m_Sub(m_Specific(Op0), m_Value(B))))
|
||||||
return new ICmpInst(*Context, I.getPredicate(), B,
|
return new ICmpInst(*Context, I.getPredicate(), B,
|
||||||
Constant::getNullValue(B->getType()));
|
Constant::getNullValue(B->getType()));
|
||||||
|
|
||||||
// (X&Z) == (Y&Z) -> (X^Y) & Z == 0
|
// (X&Z) == (Y&Z) -> (X^Y) & Z == 0
|
||||||
if (Op0->hasOneUse() && Op1->hasOneUse() &&
|
if (Op0->hasOneUse() && Op1->hasOneUse() &&
|
||||||
match(Op0, m_And(m_Value(A), m_Value(B)), *Context) &&
|
match(Op0, m_And(m_Value(A), m_Value(B))) &&
|
||||||
match(Op1, m_And(m_Value(C), m_Value(D)), *Context)) {
|
match(Op1, m_And(m_Value(C), m_Value(D)))) {
|
||||||
Value *X = 0, *Y = 0, *Z = 0;
|
Value *X = 0, *Y = 0, *Z = 0;
|
||||||
|
|
||||||
if (A == C) {
|
if (A == C) {
|
||||||
@ -7101,7 +7093,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
|||||||
else if (Value *NegVal = dyn_castNegVal(BOp0))
|
else if (Value *NegVal = dyn_castNegVal(BOp0))
|
||||||
return new ICmpInst(*Context, ICI.getPredicate(), NegVal, BOp1);
|
return new ICmpInst(*Context, ICI.getPredicate(), NegVal, BOp1);
|
||||||
else if (BO->hasOneUse()) {
|
else if (BO->hasOneUse()) {
|
||||||
Instruction *Neg = BinaryOperator::CreateNeg(*Context, BOp1);
|
Instruction *Neg = BinaryOperator::CreateNeg(BOp1);
|
||||||
InsertNewInstBefore(Neg, ICI);
|
InsertNewInstBefore(Neg, ICI);
|
||||||
Neg->takeName(BO);
|
Neg->takeName(BO);
|
||||||
return new ICmpInst(*Context, ICI.getPredicate(), BOp0, Neg);
|
return new ICmpInst(*Context, ICI.getPredicate(), BOp0, Neg);
|
||||||
@ -7316,7 +7308,7 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
|
|||||||
"ICmp should be folded!");
|
"ICmp should be folded!");
|
||||||
if (Constant *CI = dyn_cast<Constant>(Result))
|
if (Constant *CI = dyn_cast<Constant>(Result))
|
||||||
return ReplaceInstUsesWith(ICI, ConstantExpr::getNot(CI));
|
return ReplaceInstUsesWith(ICI, ConstantExpr::getNot(CI));
|
||||||
return BinaryOperator::CreateNot(*Context, Result);
|
return BinaryOperator::CreateNot(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction *InstCombiner::visitShl(BinaryOperator &I) {
|
Instruction *InstCombiner::visitShl(BinaryOperator &I) {
|
||||||
@ -7485,7 +7477,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||||||
// Turn (Y + (X >> C)) << C -> (X + (Y << C)) & (~0 << C)
|
// Turn (Y + (X >> C)) << C -> (X + (Y << C)) & (~0 << C)
|
||||||
if (isLeftShift && Op0BO->getOperand(1)->hasOneUse() &&
|
if (isLeftShift && Op0BO->getOperand(1)->hasOneUse() &&
|
||||||
match(Op0BO->getOperand(1), m_Shr(m_Value(V1),
|
match(Op0BO->getOperand(1), m_Shr(m_Value(V1),
|
||||||
m_Specific(Op1)), *Context)){
|
m_Specific(Op1)))){
|
||||||
Instruction *YS = BinaryOperator::CreateShl(
|
Instruction *YS = BinaryOperator::CreateShl(
|
||||||
Op0BO->getOperand(0), Op1,
|
Op0BO->getOperand(0), Op1,
|
||||||
Op0BO->getName());
|
Op0BO->getName());
|
||||||
@ -7504,7 +7496,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||||||
if (isLeftShift && Op0BOOp1->hasOneUse() &&
|
if (isLeftShift && Op0BOOp1->hasOneUse() &&
|
||||||
match(Op0BOOp1,
|
match(Op0BOOp1,
|
||||||
m_And(m_Shr(m_Value(V1), m_Specific(Op1)),
|
m_And(m_Shr(m_Value(V1), m_Specific(Op1)),
|
||||||
m_ConstantInt(CC)), *Context) &&
|
m_ConstantInt(CC))) &&
|
||||||
cast<BinaryOperator>(Op0BOOp1)->getOperand(0)->hasOneUse()) {
|
cast<BinaryOperator>(Op0BOOp1)->getOperand(0)->hasOneUse()) {
|
||||||
Instruction *YS = BinaryOperator::CreateShl(
|
Instruction *YS = BinaryOperator::CreateShl(
|
||||||
Op0BO->getOperand(0), Op1,
|
Op0BO->getOperand(0), Op1,
|
||||||
@ -7525,7 +7517,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||||||
// Turn ((X >> C) + Y) << C -> (X + (Y << C)) & (~0 << C)
|
// Turn ((X >> C) + Y) << C -> (X + (Y << C)) & (~0 << C)
|
||||||
if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() &&
|
if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() &&
|
||||||
match(Op0BO->getOperand(0), m_Shr(m_Value(V1),
|
match(Op0BO->getOperand(0), m_Shr(m_Value(V1),
|
||||||
m_Specific(Op1)), *Context)){
|
m_Specific(Op1)))) {
|
||||||
Instruction *YS = BinaryOperator::CreateShl(
|
Instruction *YS = BinaryOperator::CreateShl(
|
||||||
Op0BO->getOperand(1), Op1,
|
Op0BO->getOperand(1), Op1,
|
||||||
Op0BO->getName());
|
Op0BO->getName());
|
||||||
@ -7543,7 +7535,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||||||
if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() &&
|
if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() &&
|
||||||
match(Op0BO->getOperand(0),
|
match(Op0BO->getOperand(0),
|
||||||
m_And(m_Shr(m_Value(V1), m_Value(V2)),
|
m_And(m_Shr(m_Value(V1), m_Value(V2)),
|
||||||
m_ConstantInt(CC)), *Context) && V2 == Op1 &&
|
m_ConstantInt(CC))) && V2 == Op1 &&
|
||||||
cast<BinaryOperator>(Op0BO->getOperand(0))
|
cast<BinaryOperator>(Op0BO->getOperand(0))
|
||||||
->getOperand(0)->hasOneUse()) {
|
->getOperand(0)->hasOneUse()) {
|
||||||
Instruction *YS = BinaryOperator::CreateShl(
|
Instruction *YS = BinaryOperator::CreateShl(
|
||||||
@ -8487,7 +8479,7 @@ Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
|
|||||||
ConstantInt *ShAmtV = 0;
|
ConstantInt *ShAmtV = 0;
|
||||||
Value *ShiftOp = 0;
|
Value *ShiftOp = 0;
|
||||||
if (Src->hasOneUse() &&
|
if (Src->hasOneUse() &&
|
||||||
match(Src, m_LShr(m_Value(ShiftOp), m_ConstantInt(ShAmtV)), *Context)) {
|
match(Src, m_LShr(m_Value(ShiftOp), m_ConstantInt(ShAmtV)))) {
|
||||||
uint32_t ShAmt = ShAmtV->getLimitedValue(SrcBitWidth);
|
uint32_t ShAmt = ShAmtV->getLimitedValue(SrcBitWidth);
|
||||||
|
|
||||||
// Get a mask for the bits shifting in.
|
// Get a mask for the bits shifting in.
|
||||||
@ -8747,7 +8739,7 @@ Instruction *InstCombiner::visitSExt(SExtInst &CI) {
|
|||||||
Value *A = 0;
|
Value *A = 0;
|
||||||
ConstantInt *BA = 0, *CA = 0;
|
ConstantInt *BA = 0, *CA = 0;
|
||||||
if (match(Src, m_AShr(m_Shl(m_Value(A), m_ConstantInt(BA)),
|
if (match(Src, m_AShr(m_Shl(m_Value(A), m_ConstantInt(BA)),
|
||||||
m_ConstantInt(CA)), *Context) &&
|
m_ConstantInt(CA))) &&
|
||||||
BA == CA && isa<TruncInst>(A)) {
|
BA == CA && isa<TruncInst>(A)) {
|
||||||
Value *I = cast<TruncInst>(A)->getOperand(0);
|
Value *I = cast<TruncInst>(A)->getOperand(0);
|
||||||
if (I->getType() == CI.getType()) {
|
if (I->getType() == CI.getType()) {
|
||||||
@ -9307,11 +9299,11 @@ Instruction *InstCombiner::visitSelectInstWithICmp(SelectInst &SI,
|
|||||||
// (x <s 0) ? -1 : 0 -> ashr x, 31 -> all ones if signed
|
// (x <s 0) ? -1 : 0 -> ashr x, 31 -> all ones if signed
|
||||||
// (x >s -1) ? -1 : 0 -> ashr x, 31 -> all ones if not signed
|
// (x >s -1) ? -1 : 0 -> ashr x, 31 -> all ones if not signed
|
||||||
CmpInst::Predicate Pred = CmpInst::BAD_ICMP_PREDICATE;
|
CmpInst::Predicate Pred = CmpInst::BAD_ICMP_PREDICATE;
|
||||||
if (match(TrueVal, m_ConstantInt<-1>(), *Context) &&
|
if (match(TrueVal, m_ConstantInt<-1>()) &&
|
||||||
match(FalseVal, m_ConstantInt<0>(), *Context))
|
match(FalseVal, m_ConstantInt<0>()))
|
||||||
Pred = ICI->getPredicate();
|
Pred = ICI->getPredicate();
|
||||||
else if (match(TrueVal, m_ConstantInt<0>(), *Context) &&
|
else if (match(TrueVal, m_ConstantInt<0>()) &&
|
||||||
match(FalseVal, m_ConstantInt<-1>(), *Context))
|
match(FalseVal, m_ConstantInt<-1>()))
|
||||||
Pred = CmpInst::getInversePredicate(ICI->getPredicate());
|
Pred = CmpInst::getInversePredicate(ICI->getPredicate());
|
||||||
|
|
||||||
if (Pred != CmpInst::BAD_ICMP_PREDICATE) {
|
if (Pred != CmpInst::BAD_ICMP_PREDICATE) {
|
||||||
@ -9335,7 +9327,7 @@ Instruction *InstCombiner::visitSelectInstWithICmp(SelectInst &SI,
|
|||||||
true/*SExt*/, "tmp", ICI);
|
true/*SExt*/, "tmp", ICI);
|
||||||
|
|
||||||
if (Pred == ICmpInst::ICMP_SGT)
|
if (Pred == ICmpInst::ICMP_SGT)
|
||||||
In = InsertNewInstBefore(BinaryOperator::CreateNot(*Context, In,
|
In = InsertNewInstBefore(BinaryOperator::CreateNot(In,
|
||||||
In->getName()+".not"), *ICI);
|
In->getName()+".not"), *ICI);
|
||||||
|
|
||||||
return ReplaceInstUsesWith(SI, In);
|
return ReplaceInstUsesWith(SI, In);
|
||||||
@ -9400,7 +9392,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
|
|||||||
} else {
|
} else {
|
||||||
// Change: A = select B, false, C --> A = and !B, C
|
// Change: A = select B, false, C --> A = and !B, C
|
||||||
Value *NotCond =
|
Value *NotCond =
|
||||||
InsertNewInstBefore(BinaryOperator::CreateNot(*Context, CondVal,
|
InsertNewInstBefore(BinaryOperator::CreateNot(CondVal,
|
||||||
"not."+CondVal->getName()), SI);
|
"not."+CondVal->getName()), SI);
|
||||||
return BinaryOperator::CreateAnd(NotCond, FalseVal);
|
return BinaryOperator::CreateAnd(NotCond, FalseVal);
|
||||||
}
|
}
|
||||||
@ -9411,7 +9403,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
|
|||||||
} else {
|
} else {
|
||||||
// Change: A = select B, C, true --> A = or !B, C
|
// Change: A = select B, C, true --> A = or !B, C
|
||||||
Value *NotCond =
|
Value *NotCond =
|
||||||
InsertNewInstBefore(BinaryOperator::CreateNot(*Context, CondVal,
|
InsertNewInstBefore(BinaryOperator::CreateNot(CondVal,
|
||||||
"not."+CondVal->getName()), SI);
|
"not."+CondVal->getName()), SI);
|
||||||
return BinaryOperator::CreateOr(NotCond, TrueVal);
|
return BinaryOperator::CreateOr(NotCond, TrueVal);
|
||||||
}
|
}
|
||||||
@ -9434,7 +9426,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
|
|||||||
} else if (TrueValC->isZero() && FalseValC->getValue() == 1) {
|
} else if (TrueValC->isZero() && FalseValC->getValue() == 1) {
|
||||||
// select C, 0, 1 -> zext !C to int
|
// select C, 0, 1 -> zext !C to int
|
||||||
Value *NotCond =
|
Value *NotCond =
|
||||||
InsertNewInstBefore(BinaryOperator::CreateNot(*Context, CondVal,
|
InsertNewInstBefore(BinaryOperator::CreateNot(CondVal,
|
||||||
"not."+CondVal->getName()), SI);
|
"not."+CondVal->getName()), SI);
|
||||||
return CastInst::Create(Instruction::ZExt, NotCond, SI.getType());
|
return CastInst::Create(Instruction::ZExt, NotCond, SI.getType());
|
||||||
}
|
}
|
||||||
@ -9553,7 +9545,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
|
|||||||
NegVal = ConstantExpr::getNeg(C);
|
NegVal = ConstantExpr::getNeg(C);
|
||||||
} else {
|
} else {
|
||||||
NegVal = InsertNewInstBefore(
|
NegVal = InsertNewInstBefore(
|
||||||
BinaryOperator::CreateNeg(*Context, SubOp->getOperand(1),
|
BinaryOperator::CreateNeg(SubOp->getOperand(1),
|
||||||
"tmp"), SI);
|
"tmp"), SI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12109,7 +12101,7 @@ Instruction *InstCombiner::visitBranchInst(BranchInst &BI) {
|
|||||||
Value *X = 0;
|
Value *X = 0;
|
||||||
BasicBlock *TrueDest;
|
BasicBlock *TrueDest;
|
||||||
BasicBlock *FalseDest;
|
BasicBlock *FalseDest;
|
||||||
if (match(&BI, m_Br(m_Not(m_Value(X)), TrueDest, FalseDest), *Context) &&
|
if (match(&BI, m_Br(m_Not(m_Value(X)), TrueDest, FalseDest)) &&
|
||||||
!isa<Constant>(X)) {
|
!isa<Constant>(X)) {
|
||||||
// Swap Destinations and condition...
|
// Swap Destinations and condition...
|
||||||
BI.setCondition(X);
|
BI.setCondition(X);
|
||||||
@ -12121,7 +12113,7 @@ Instruction *InstCombiner::visitBranchInst(BranchInst &BI) {
|
|||||||
// Cannonicalize fcmp_one -> fcmp_oeq
|
// Cannonicalize fcmp_one -> fcmp_oeq
|
||||||
FCmpInst::Predicate FPred; Value *Y;
|
FCmpInst::Predicate FPred; Value *Y;
|
||||||
if (match(&BI, m_Br(m_FCmp(FPred, m_Value(X), m_Value(Y)),
|
if (match(&BI, m_Br(m_FCmp(FPred, m_Value(X), m_Value(Y)),
|
||||||
TrueDest, FalseDest), *Context))
|
TrueDest, FalseDest)))
|
||||||
if ((FPred == FCmpInst::FCMP_ONE || FPred == FCmpInst::FCMP_OLE ||
|
if ((FPred == FCmpInst::FCMP_ONE || FPred == FCmpInst::FCMP_OLE ||
|
||||||
FPred == FCmpInst::FCMP_OGE) && BI.getCondition()->hasOneUse()) {
|
FPred == FCmpInst::FCMP_OGE) && BI.getCondition()->hasOneUse()) {
|
||||||
FCmpInst *I = cast<FCmpInst>(BI.getCondition());
|
FCmpInst *I = cast<FCmpInst>(BI.getCondition());
|
||||||
@ -12141,7 +12133,7 @@ Instruction *InstCombiner::visitBranchInst(BranchInst &BI) {
|
|||||||
// Cannonicalize icmp_ne -> icmp_eq
|
// Cannonicalize icmp_ne -> icmp_eq
|
||||||
ICmpInst::Predicate IPred;
|
ICmpInst::Predicate IPred;
|
||||||
if (match(&BI, m_Br(m_ICmp(IPred, m_Value(X), m_Value(Y)),
|
if (match(&BI, m_Br(m_ICmp(IPred, m_Value(X), m_Value(Y)),
|
||||||
TrueDest, FalseDest), *Context))
|
TrueDest, FalseDest)))
|
||||||
if ((IPred == ICmpInst::ICMP_NE || IPred == ICmpInst::ICMP_ULE ||
|
if ((IPred == ICmpInst::ICMP_NE || IPred == ICmpInst::ICMP_ULE ||
|
||||||
IPred == ICmpInst::ICMP_SLE || IPred == ICmpInst::ICMP_UGE ||
|
IPred == ICmpInst::ICMP_SLE || IPred == ICmpInst::ICMP_UGE ||
|
||||||
IPred == ICmpInst::ICMP_SGE) && BI.getCondition()->hasOneUse()) {
|
IPred == ICmpInst::ICMP_SGE) && BI.getCondition()->hasOneUse()) {
|
||||||
|
@ -403,7 +403,7 @@ static Value *NegateValue(LLVMContext &Context, Value *V, Instruction *BI) {
|
|||||||
// Insert a 'neg' instruction that subtracts the value from zero to get the
|
// Insert a 'neg' instruction that subtracts the value from zero to get the
|
||||||
// negation.
|
// negation.
|
||||||
//
|
//
|
||||||
return BinaryOperator::CreateNeg(Context, V, V->getName() + ".neg", BI);
|
return BinaryOperator::CreateNeg(V, V->getName() + ".neg", BI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ShouldBreakUpSubtract - Return true if we should break up this subtract of
|
/// ShouldBreakUpSubtract - Return true if we should break up this subtract of
|
||||||
|
@ -97,8 +97,7 @@ bool AddressingModeMatcher::MatchScaledValue(Value *ScaleReg, int64_t Scale,
|
|||||||
// X*Scale + C*Scale to addr mode.
|
// X*Scale + C*Scale to addr mode.
|
||||||
ConstantInt *CI = 0; Value *AddLHS = 0;
|
ConstantInt *CI = 0; Value *AddLHS = 0;
|
||||||
if (isa<Instruction>(ScaleReg) && // not a constant expr.
|
if (isa<Instruction>(ScaleReg) && // not a constant expr.
|
||||||
match(ScaleReg, m_Add(m_Value(AddLHS), m_ConstantInt(CI)),
|
match(ScaleReg, m_Add(m_Value(AddLHS), m_ConstantInt(CI)))) {
|
||||||
MemoryInst->getContext())) {
|
|
||||||
TestAddrMode.ScaledReg = AddLHS;
|
TestAddrMode.ScaledReg = AddLHS;
|
||||||
TestAddrMode.BaseOffs += CI->getSExtValue()*TestAddrMode.Scale;
|
TestAddrMode.BaseOffs += CI->getSExtValue()*TestAddrMode.Scale;
|
||||||
|
|
||||||
|
@ -1558,8 +1558,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI) {
|
|||||||
// If we need to invert the condition in the pred block to match, do so now.
|
// If we need to invert the condition in the pred block to match, do so now.
|
||||||
if (InvertPredCond) {
|
if (InvertPredCond) {
|
||||||
Value *NewCond =
|
Value *NewCond =
|
||||||
BinaryOperator::CreateNot(BI->getParent()->getContext(),
|
BinaryOperator::CreateNot(PBI->getCondition(),
|
||||||
PBI->getCondition(),
|
|
||||||
PBI->getCondition()->getName()+".not", PBI);
|
PBI->getCondition()->getName()+".not", PBI);
|
||||||
PBI->setCondition(NewCond);
|
PBI->setCondition(NewCond);
|
||||||
BasicBlock *OldTrue = PBI->getSuccessor(0);
|
BasicBlock *OldTrue = PBI->getSuccessor(0);
|
||||||
@ -1598,8 +1597,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI) {
|
|||||||
static bool SimplifyCondBranchToCondBranch(BranchInst *PBI, BranchInst *BI) {
|
static bool SimplifyCondBranchToCondBranch(BranchInst *PBI, BranchInst *BI) {
|
||||||
assert(PBI->isConditional() && BI->isConditional());
|
assert(PBI->isConditional() && BI->isConditional());
|
||||||
BasicBlock *BB = BI->getParent();
|
BasicBlock *BB = BI->getParent();
|
||||||
LLVMContext &Context = BB->getContext();
|
|
||||||
|
|
||||||
// If this block ends with a branch instruction, and if there is a
|
// If this block ends with a branch instruction, and if there is a
|
||||||
// predecessor that ends on a branch of the same condition, make
|
// predecessor that ends on a branch of the same condition, make
|
||||||
// this conditional branch redundant.
|
// this conditional branch redundant.
|
||||||
@ -1715,12 +1713,12 @@ static bool SimplifyCondBranchToCondBranch(BranchInst *PBI, BranchInst *BI) {
|
|||||||
// Make sure we get to CommonDest on True&True directions.
|
// Make sure we get to CommonDest on True&True directions.
|
||||||
Value *PBICond = PBI->getCondition();
|
Value *PBICond = PBI->getCondition();
|
||||||
if (PBIOp)
|
if (PBIOp)
|
||||||
PBICond = BinaryOperator::CreateNot(Context, PBICond,
|
PBICond = BinaryOperator::CreateNot(PBICond,
|
||||||
PBICond->getName()+".not",
|
PBICond->getName()+".not",
|
||||||
PBI);
|
PBI);
|
||||||
Value *BICond = BI->getCondition();
|
Value *BICond = BI->getCondition();
|
||||||
if (BIOp)
|
if (BIOp)
|
||||||
BICond = BinaryOperator::CreateNot(Context, BICond,
|
BICond = BinaryOperator::CreateNot(BICond,
|
||||||
BICond->getName()+".not",
|
BICond->getName()+".not",
|
||||||
PBI);
|
PBI);
|
||||||
// Merge the conditions.
|
// Merge the conditions.
|
||||||
|
@ -1572,8 +1572,7 @@ BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,
|
|||||||
return Res;
|
return Res;
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
|
BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const Twine &Name,
|
||||||
Value *Op, const Twine &Name,
|
|
||||||
Instruction *InsertBefore) {
|
Instruction *InsertBefore) {
|
||||||
Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
|
Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
|
||||||
return new BinaryOperator(Instruction::Sub,
|
return new BinaryOperator(Instruction::Sub,
|
||||||
@ -1581,8 +1580,7 @@ BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
|
|||||||
Op->getType(), Name, InsertBefore);
|
Op->getType(), Name, InsertBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
|
BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const Twine &Name,
|
||||||
Value *Op, const Twine &Name,
|
|
||||||
BasicBlock *InsertAtEnd) {
|
BasicBlock *InsertAtEnd) {
|
||||||
Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
|
Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
|
||||||
return new BinaryOperator(Instruction::Sub,
|
return new BinaryOperator(Instruction::Sub,
|
||||||
@ -1590,8 +1588,7 @@ BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
|
|||||||
Op->getType(), Name, InsertAtEnd);
|
Op->getType(), Name, InsertAtEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
|
BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const Twine &Name,
|
||||||
Value *Op, const Twine &Name,
|
|
||||||
Instruction *InsertBefore) {
|
Instruction *InsertBefore) {
|
||||||
Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
|
Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
|
||||||
return new BinaryOperator(Instruction::FSub,
|
return new BinaryOperator(Instruction::FSub,
|
||||||
@ -1599,8 +1596,7 @@ BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
|
|||||||
Op->getType(), Name, InsertBefore);
|
Op->getType(), Name, InsertBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
|
BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const Twine &Name,
|
||||||
Value *Op, const Twine &Name,
|
|
||||||
BasicBlock *InsertAtEnd) {
|
BasicBlock *InsertAtEnd) {
|
||||||
Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
|
Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
|
||||||
return new BinaryOperator(Instruction::FSub,
|
return new BinaryOperator(Instruction::FSub,
|
||||||
@ -1608,8 +1604,7 @@ BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
|
|||||||
Op->getType(), Name, InsertAtEnd);
|
Op->getType(), Name, InsertAtEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
|
BinaryOperator *BinaryOperator::CreateNot(Value *Op, const Twine &Name,
|
||||||
Value *Op, const Twine &Name,
|
|
||||||
Instruction *InsertBefore) {
|
Instruction *InsertBefore) {
|
||||||
Constant *C;
|
Constant *C;
|
||||||
if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
|
if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
|
||||||
@ -1624,8 +1619,7 @@ BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
|
|||||||
Op->getType(), Name, InsertBefore);
|
Op->getType(), Name, InsertBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
|
BinaryOperator *BinaryOperator::CreateNot(Value *Op, const Twine &Name,
|
||||||
Value *Op, const Twine &Name,
|
|
||||||
BasicBlock *InsertAtEnd) {
|
BasicBlock *InsertAtEnd) {
|
||||||
Constant *AllOnes;
|
Constant *AllOnes;
|
||||||
if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
|
if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
|
||||||
|
Loading…
Reference in New Issue
Block a user