[llvm-commits] [llvm] r92760 - in /llvm/trunk/lib: Analysis/ ExecutionEngine/JIT/ Target/X86/ Transforms/InstCombine/ Transforms/Scalar/ Transforms/Utils/ VMCore/
Benjamin Kramer
benny.kra at googlemail.com
Tue Jan 5 12:07:08 PST 2010
Author: d0k
Date: Tue Jan 5 14:07:06 2010
New Revision: 92760
URL: http://llvm.org/viewvc/llvm-project?rev=92760&view=rev
Log:
Convert a ton of simple integer type equality tests to the new predicate.
Modified:
llvm/trunk/lib/Analysis/DebugInfo.cpp
llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
llvm/trunk/lib/Target/X86/X86FastISel.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/trunk/lib/VMCore/AsmWriter.cpp
llvm/trunk/lib/VMCore/ConstantFold.cpp
llvm/trunk/lib/VMCore/Constants.cpp
llvm/trunk/lib/VMCore/Instructions.cpp
llvm/trunk/lib/VMCore/Type.cpp
Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Jan 5 14:07:06 2010
@@ -1062,8 +1062,7 @@
DIVariable D,
Instruction *InsertBefore) {
assert(V && "no value passed to dbg.value");
- assert(Offset->getType() == Type::getInt64Ty(V->getContext()) &&
- "offset must be i64");
+ assert(Offset->getType()->isInteger(64) && "offset must be i64");
if (!ValueFn)
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
@@ -1078,8 +1077,7 @@
DIVariable D,
BasicBlock *InsertAtEnd) {
assert(V && "no value passed to dbg.value");
- assert(Offset->getType() == Type::getInt64Ty(V->getContext()) &&
- "offset must be i64");
+ assert(Offset->getType()->isInteger(64) && "offset must be i64");
if (!ValueFn)
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Tue Jan 5 14:07:06 2010
@@ -414,7 +414,7 @@
if (RetTy == Type::getInt32Ty(F->getContext()) || RetTy->isVoidTy()) {
switch (ArgValues.size()) {
case 3:
- if (FTy->getParamType(0) == Type::getInt32Ty(F->getContext()) &&
+ if (FTy->getParamType(0)->isInteger(32) &&
isa<PointerType>(FTy->getParamType(1)) &&
isa<PointerType>(FTy->getParamType(2))) {
int (*PF)(int, char **, const char **) =
@@ -429,7 +429,7 @@
}
break;
case 2:
- if (FTy->getParamType(0) == Type::getInt32Ty(F->getContext()) &&
+ if (FTy->getParamType(0)->isInteger(32) &&
isa<PointerType>(FTy->getParamType(1))) {
int (*PF)(int, char **) = (int(*)(int, char **))(intptr_t)FPtr;
@@ -442,7 +442,7 @@
break;
case 1:
if (FTy->getNumParams() == 1 &&
- FTy->getParamType(0) == Type::getInt32Ty(F->getContext())) {
+ FTy->getParamType(0)->isInteger(32)) {
GenericValue rv;
int (*PF)(int) = (int(*)(int))(intptr_t)FPtr;
rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue()));
Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Tue Jan 5 14:07:06 2010
@@ -786,8 +786,8 @@
bool X86FastISel::X86SelectZExt(Instruction *I) {
// Handle zero-extension from i1 to i8, which is common.
- if (I->getType() == Type::getInt8Ty(I->getContext()) &&
- I->getOperand(0)->getType() == Type::getInt1Ty(I->getContext())) {
+ if (I->getType()->isInteger(8) &&
+ I->getOperand(0)->getType()->isInteger(1)) {
unsigned ResultReg = getRegForValue(I->getOperand(0));
if (ResultReg == 0) return false;
// Set the high bits to zero.
@@ -948,7 +948,7 @@
bool X86FastISel::X86SelectShift(Instruction *I) {
unsigned CReg = 0, OpReg = 0, OpImm = 0;
const TargetRegisterClass *RC = NULL;
- if (I->getType() == Type::getInt8Ty(I->getContext())) {
+ if (I->getType()->isInteger(8)) {
CReg = X86::CL;
RC = &X86::GR8RegClass;
switch (I->getOpcode()) {
@@ -957,7 +957,7 @@
case Instruction::Shl: OpReg = X86::SHL8rCL; OpImm = X86::SHL8ri; break;
default: return false;
}
- } else if (I->getType() == Type::getInt16Ty(I->getContext())) {
+ } else if (I->getType()->isInteger(16)) {
CReg = X86::CX;
RC = &X86::GR16RegClass;
switch (I->getOpcode()) {
@@ -966,7 +966,7 @@
case Instruction::Shl: OpReg = X86::SHL16rCL; OpImm = X86::SHL16ri; break;
default: return false;
}
- } else if (I->getType() == Type::getInt32Ty(I->getContext())) {
+ } else if (I->getType()->isInteger(32)) {
CReg = X86::ECX;
RC = &X86::GR32RegClass;
switch (I->getOpcode()) {
@@ -975,7 +975,7 @@
case Instruction::Shl: OpReg = X86::SHL32rCL; OpImm = X86::SHL32ri; break;
default: return false;
}
- } else if (I->getType() == Type::getInt64Ty(I->getContext())) {
+ } else if (I->getType()->isInteger(64)) {
CReg = X86::RCX;
RC = &X86::GR64RegClass;
switch (I->getOpcode()) {
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Jan 5 14:07:06 2010
@@ -9515,7 +9515,7 @@
return LowerToBSwap(CI);
}
// rorw $$8, ${0:w} --> llvm.bswap.i16
- if (CI->getType() == Type::getInt16Ty(CI->getContext()) &&
+ if (CI->getType()->isInteger(16) &&
AsmPieces.size() == 3 &&
AsmPieces[0] == "rorw" &&
AsmPieces[1] == "$$8," &&
@@ -9525,7 +9525,7 @@
}
break;
case 3:
- if (CI->getType() == Type::getInt64Ty(CI->getContext()) &&
+ if (CI->getType()->isInteger(64) &&
Constraints.size() >= 2 &&
Constraints[0].Codes.size() == 1 && Constraints[0].Codes[0] == "A" &&
Constraints[1].Codes.size() == 1 && Constraints[1].Codes[0] == "0") {
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp Tue Jan 5 14:07:06 2010
@@ -158,7 +158,7 @@
}
}
- if (I.getType() == Type::getInt1Ty(I.getContext()))
+ if (I.getType()->isInteger(1))
return BinaryOperator::CreateXor(LHS, RHS);
if (I.getType()->isInteger()) {
@@ -573,7 +573,7 @@
return ReplaceInstUsesWith(I, Op0); // undef - X -> undef
if (isa<UndefValue>(Op1))
return ReplaceInstUsesWith(I, Op1); // X - undef -> undef
- if (I.getType() == Type::getInt1Ty(I.getContext()))
+ if (I.getType()->isInteger(1))
return BinaryOperator::CreateXor(Op0, Op1);
if (ConstantInt *C = dyn_cast<ConstantInt>(Op0)) {
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Tue Jan 5 14:07:06 2010
@@ -23,8 +23,7 @@
///
static Value *DecomposeSimpleLinearExpr(Value *Val, unsigned &Scale,
int &Offset) {
- assert(Val->getType() == Type::getInt32Ty(Val->getContext()) &&
- "Unexpected allocation size type!");
+ assert(Val->getType()->isInteger(32) && "Unexpected allocation size type!");
if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) {
Offset = CI->getZExtValue();
Scale = 0;
@@ -935,7 +934,7 @@
Value *Src = CI.getOperand(0);
// Canonicalize sign-extend from i1 to a select.
- if (Src->getType() == Type::getInt1Ty(CI.getContext()))
+ if (Src->getType()->isInteger(1))
return SelectInst::Create(Src,
Constant::getAllOnesValue(CI.getType()),
Constant::getNullValue(CI.getType()));
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Tue Jan 5 14:07:06 2010
@@ -157,7 +157,7 @@
}
/// i1 mul -> i1 and.
- if (I.getType() == Type::getInt1Ty(I.getContext()))
+ if (I.getType()->isInteger(1))
return BinaryOperator::CreateAnd(Op0, Op1);
// X*(1 << Y) --> X << Y
@@ -386,7 +386,7 @@
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
// It can't be division by zero, hence it must be division by one.
- if (I.getType() == Type::getInt1Ty(I.getContext()))
+ if (I.getType()->isInteger(1))
return ReplaceInstUsesWith(I, Op0);
if (ConstantVector *Op1V = dyn_cast<ConstantVector>(Op1)) {
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp Tue Jan 5 14:07:06 2010
@@ -479,7 +479,7 @@
return ReplaceInstUsesWith(SI, FalseVal);
}
- if (SI.getType() == Type::getInt1Ty(SI.getContext())) {
+ if (SI.getType()->isInteger(1)) {
if (ConstantInt *C = dyn_cast<ConstantInt>(TrueVal)) {
if (C->getZExtValue()) {
// Change: A = select B, true, C --> A = or B, C
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Tue Jan 5 14:07:06 2010
@@ -226,7 +226,7 @@
if (isa<Constant>(TV) || isa<Constant>(FV)) {
// Bool selects with constant operands can be folded to logical ops.
- if (SI->getType() == Type::getInt1Ty(SI->getContext())) return 0;
+ if (SI->getType()->isInteger(1)) return 0;
Value *SelectTrueVal = FoldOperationIntoSelectOperand(Op, TV, this);
Value *SelectFalseVal = FoldOperationIntoSelectOperand(Op, FV, this);
Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Jan 5 14:07:06 2010
@@ -867,7 +867,7 @@
// If we know that LIC == Val, or that LIC == NotVal, just replace uses of LIC
// in the loop with the appropriate one directly.
if (IsEqual || (isa<ConstantInt>(Val) &&
- Val->getType() == Type::getInt1Ty(Val->getContext()))) {
+ Val->getType()->isInteger(1))) {
Value *Replacement;
if (IsEqual)
Replacement = Val;
@@ -993,10 +993,10 @@
case Instruction::And:
if (isa<ConstantInt>(I->getOperand(0)) &&
// constant -> RHS
- I->getOperand(0)->getType() == Type::getInt1Ty(I->getContext()))
+ I->getOperand(0)->getType()->isInteger(1))
cast<BinaryOperator>(I)->swapOperands();
if (ConstantInt *CB = dyn_cast<ConstantInt>(I->getOperand(1)))
- if (CB->getType() == Type::getInt1Ty(I->getContext())) {
+ if (CB->getType()->isInteger(1)) {
if (CB->isOne()) // X & 1 -> X
ReplaceUsesOfWith(I, I->getOperand(0), Worklist, L, LPM);
else // X & 0 -> 0
@@ -1007,10 +1007,10 @@
case Instruction::Or:
if (isa<ConstantInt>(I->getOperand(0)) &&
// constant -> RHS
- I->getOperand(0)->getType() == Type::getInt1Ty(I->getContext()))
+ I->getOperand(0)->getType()->isInteger(1))
cast<BinaryOperator>(I)->swapOperands();
if (ConstantInt *CB = dyn_cast<ConstantInt>(I->getOperand(1)))
- if (CB->getType() == Type::getInt1Ty(I->getContext())) {
+ if (CB->getType()->isInteger(1)) {
if (CB->isOne()) // X | 1 -> 1
ReplaceUsesOfWith(I, I->getOperand(1), Worklist, L, LPM);
else // X | 0 -> X
Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Tue Jan 5 14:07:06 2010
@@ -42,7 +42,7 @@
LLVMContext &Context = V->getContext();
// All byte-wide stores are splatable, even of arbitrary variables.
- if (V->getType() == Type::getInt8Ty(Context)) return V;
+ if (V->getType()->isInteger(8)) return V;
// Constant float and double values can be handled as integer values if the
// corresponding integer value is "byteable". An important case is 0.0.
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Tue Jan 5 14:07:06 2010
@@ -1011,7 +1011,7 @@
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
ConstantInt *CB;
if ((CB = dyn_cast<ConstantInt>(PN->getIncomingValue(i))) &&
- CB->getType() == Type::getInt1Ty(BB->getContext())) {
+ CB->getType()->isInteger(1)) {
// Okay, we now know that all edges from PredBB should be revectored to
// branch to RealDest.
BasicBlock *PredBB = PN->getIncomingBlock(i);
Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Jan 5 14:07:06 2010
@@ -833,7 +833,7 @@
static void WriteConstantInt(raw_ostream &Out, const Constant *CV,
TypePrinting &TypePrinter, SlotTracker *Machine) {
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
- if (CI->getType() == Type::getInt1Ty(CV->getContext())) {
+ if (CI->getType()->isInteger(1)) {
Out << (CI->getZExtValue() ? "true" : "false");
return;
}
Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/trunk/lib/VMCore/ConstantFold.cpp Tue Jan 5 14:07:06 2010
@@ -1162,7 +1162,7 @@
}
// i1 can be simplified in many cases.
- if (C1->getType() == Type::getInt1Ty(Context)) {
+ if (C1->getType()->isInteger(1)) {
switch (Opcode) {
case Instruction::Add:
case Instruction::Sub:
@@ -1587,7 +1587,7 @@
}
// If the comparison is a comparison between two i1's, simplify it.
- if (C1->getType() == Type::getInt1Ty(Context)) {
+ if (C1->getType()->isInteger(1)) {
switch(pred) {
case ICmpInst::ICMP_EQ:
if (isa<ConstantInt>(C2))
Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Tue Jan 5 14:07:06 2010
@@ -1689,7 +1689,7 @@
Constant *ConstantExpr::getExtractElement(Constant *Val, Constant *Idx) {
assert(isa<VectorType>(Val->getType()) &&
"Tried to create extractelement operation on non-vector type!");
- assert(Idx->getType() == Type::getInt32Ty(Val->getContext()) &&
+ assert(Idx->getType()->isInteger(32) &&
"Extractelement index must be i32 type!");
return getExtractElementTy(cast<VectorType>(Val->getType())->getElementType(),
Val, Idx);
@@ -1716,7 +1716,7 @@
"Tried to create insertelement operation on non-vector type!");
assert(Elt->getType() == cast<VectorType>(Val->getType())->getElementType()
&& "Insertelement types must match!");
- assert(Idx->getType() == Type::getInt32Ty(Val->getContext()) &&
+ assert(Idx->getType()->isInteger(32) &&
"Insertelement index must be i32 type!");
return getInsertElementTy(Val->getType(), Val, Elt, Idx);
}
Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Tue Jan 5 14:07:06 2010
@@ -787,7 +787,7 @@
void BranchInst::AssertOK() {
if (isConditional())
- assert(getCondition()->getType() == Type::getInt1Ty(getContext()) &&
+ assert(getCondition()->getType()->isInteger(1) &&
"May only branch on boolean predicates!");
}
@@ -892,7 +892,7 @@
else {
assert(!isa<BasicBlock>(Amt) &&
"Passed basic block into allocation size parameter! Use other ctor");
- assert(Amt->getType() == Type::getInt32Ty(Context) &&
+ assert(Amt->getType()->isInteger(32) &&
"Allocation array size is not a 32-bit integer!");
}
return Amt;
Modified: llvm/trunk/lib/VMCore/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=92760&r1=92759&r2=92760&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Type.cpp (original)
+++ llvm/trunk/lib/VMCore/Type.cpp Tue Jan 5 14:07:06 2010
@@ -285,7 +285,7 @@
bool StructType::indexValid(const Value *V) const {
// Structure indexes require 32-bit integer constants.
- if (V->getType() == Type::getInt32Ty(V->getContext()))
+ if (V->getType()->isInteger(32))
if (const ConstantInt *CU = dyn_cast<ConstantInt>(V))
return indexValid(CU->getZExtValue());
return false;
More information about the llvm-commits
mailing list