diff options
-rw-r--r-- | lib/Analysis/ConstantFolding.cpp | 20 | ||||
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 4 | ||||
-rw-r--r-- | lib/AsmParser/llvmAsmParser.y | 6 | ||||
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 10 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 13 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/ScheduleDAG.cpp | 3 | ||||
-rw-r--r-- | lib/ExecutionEngine/JIT/JIT.cpp | 24 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelLowering.cpp | 37 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 9 |
9 files changed, 60 insertions, 66 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 0e8435f..d58d78f 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -593,10 +593,9 @@ static Constant *ConstantFoldFP(double (*NativeFP)(double), double V, } if (Ty == Type::FloatTy) - return ConstantFP::get(Ty, APFloat((float)V)); - + return ConstantFP::get(APFloat((float)V)); if (Ty == Type::DoubleTy) - return ConstantFP::get(Ty, APFloat(V)); + return ConstantFP::get(APFloat(V)); assert(0 && "Can only constant fold float/double"); } @@ -611,9 +610,9 @@ static Constant *ConstantFoldBinaryFP(double (*NativeFP)(double, double), } if (Ty == Type::FloatTy) - return ConstantFP::get(Ty, APFloat((float)V)); + return ConstantFP::get(APFloat((float)V)); if (Ty == Type::DoubleTy) - return ConstantFP::get(Ty, APFloat(V)); + return ConstantFP::get(APFloat(V)); assert(0 && "Can only constant fold float/double"); } @@ -678,8 +677,7 @@ llvm::ConstantFoldCall(Function *F, if (V >= -0.0) return ConstantFoldFP(sqrt, V, Ty); else // Undefined - return ConstantFP::get(Ty, Ty==Type::FloatTy ? APFloat(0.0f) : - APFloat(0.0)); + return Constant::getNullValue(Ty); } break; case 's': @@ -734,11 +732,11 @@ llvm::ConstantFoldCall(Function *F, } } else if (ConstantInt *Op2C = dyn_cast<ConstantInt>(Operands[1])) { if (!strcmp(Str, "llvm.powi.f32")) { - return ConstantFP::get(Ty, APFloat((float)std::pow((float)Op1V, - (int)Op2C->getZExtValue()))); + return ConstantFP::get(APFloat((float)std::pow((float)Op1V, + (int)Op2C->getZExtValue()))); } else if (!strcmp(Str, "llvm.powi.f64")) { - return ConstantFP::get(Ty, APFloat((double)std::pow((double)Op1V, - (int)Op2C->getZExtValue()))); + return ConstantFP::get(APFloat((double)std::pow((double)Op1V, + (int)Op2C->getZExtValue()))); } } } diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 0508bb7..32e9e96 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -494,8 +494,8 @@ SCEVHandle ScalarEvolution::getIntegerSCEV(int Val, const Type *Ty) { if (Val == 0) C = Constant::getNullValue(Ty); else if (Ty->isFloatingPoint()) - C = ConstantFP::get(Ty, APFloat(Ty==Type::FloatTy ? APFloat::IEEEsingle : - APFloat::IEEEdouble, Val)); + C = ConstantFP::get(APFloat(Ty==Type::FloatTy ? APFloat::IEEEsingle : + APFloat::IEEEdouble, Val)); else C = ConstantInt::get(Ty, Val); return getUnknown(C); diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index beafcd2..a1abae3 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -408,12 +408,12 @@ static Value *getExistingVal(const Type *Ty, const ValID &D) { GenerateError("FP constant invalid for type"); return 0; } - // Lexer has no type info, so builds all float and double FP constants + // Lexer has no type info, so builds all float and double FP constants // as double. Fix this here. Long double does not need this. if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble && Ty==Type::FloatTy) D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); - return ConstantFP::get(Ty, *D.ConstPoolFP); + return ConstantFP::get(*D.ConstPoolFP); case ValID::ConstNullVal: // Is it a null value? if (!isa<PointerType>(Ty)) { @@ -1867,7 +1867,7 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr // as double. Fix this here. Long double is done right. if (&$2->getSemantics()==&APFloat::IEEEdouble && $1==Type::FloatTy) $2->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); - $$ = ConstantFP::get($1, *$2); + $$ = ConstantFP::get(*$2); delete $2; CHECK_FOR_ERROR }; diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 141d5e1..ec099a7 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -636,15 +636,15 @@ bool BitcodeReader::ParseConstants() { if (Record.empty()) return Error("Invalid FLOAT record"); if (CurTy == Type::FloatTy) - V = ConstantFP::get(CurTy, APFloat(APInt(32, (uint32_t)Record[0]))); + V = ConstantFP::get(APFloat(APInt(32, (uint32_t)Record[0]))); else if (CurTy == Type::DoubleTy) - V = ConstantFP::get(CurTy, APFloat(APInt(64, Record[0]))); + V = ConstantFP::get(APFloat(APInt(64, Record[0]))); else if (CurTy == Type::X86_FP80Ty) - V = ConstantFP::get(CurTy, APFloat(APInt(80, 2, &Record[0]))); + V = ConstantFP::get(APFloat(APInt(80, 2, &Record[0]))); else if (CurTy == Type::FP128Ty) - V = ConstantFP::get(CurTy, APFloat(APInt(128, 2, &Record[0]), true)); + V = ConstantFP::get(APFloat(APInt(128, 2, &Record[0]), true)); else if (CurTy == Type::PPC_FP128Ty) - V = ConstantFP::get(CurTy, APFloat(APInt(128, 2, &Record[0]))); + V = ConstantFP::get(APFloat(APInt(128, 2, &Record[0]))); else V = UndefValue::get(CurTy); break; diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 18d1d18..5f260ec 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -491,8 +491,7 @@ static SDOperand ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP, // an FP extending load is the same cost as a normal load (such as on the x87 // fp stack or PPC FP unit). MVT::ValueType VT = CFP->getValueType(0); - ConstantFP *LLVMC = ConstantFP::get(MVT::getTypeForValueType(VT), - CFP->getValueAPF()); + ConstantFP *LLVMC = ConstantFP::get(CFP->getValueAPF()); if (!UseCP) { if (VT!=MVT::f64 && VT!=MVT::f32) assert(0 && "Invalid type expansion"); @@ -4901,18 +4900,18 @@ SDOperand SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) { // If all elements are constants, create a load from the constant pool. if (isConstant) { MVT::ValueType VT = Node->getValueType(0); - const Type *OpNTy = - MVT::getTypeForValueType(Node->getOperand(0).getValueType()); std::vector<Constant*> CV; for (unsigned i = 0, e = NumElems; i != e; ++i) { if (ConstantFPSDNode *V = dyn_cast<ConstantFPSDNode>(Node->getOperand(i))) { - CV.push_back(ConstantFP::get(OpNTy, V->getValueAPF())); + CV.push_back(ConstantFP::get(V->getValueAPF())); } else if (ConstantSDNode *V = - dyn_cast<ConstantSDNode>(Node->getOperand(i))) { - CV.push_back(ConstantInt::get(OpNTy, V->getValue())); + dyn_cast<ConstantSDNode>(Node->getOperand(i))) { + CV.push_back(ConstantInt::get(V->getAPIntValue())); } else { assert(Node->getOperand(i).getOpcode() == ISD::UNDEF); + const Type *OpNTy = + MVT::getTypeForValueType(Node->getOperand(0).getValueType()); CV.push_back(UndefValue::get(OpNTy)); } } diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp index 3cdd727..b4958d6 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp @@ -601,8 +601,7 @@ void ScheduleDAG::AddOperand(MachineInstr *MI, SDOperand Op, } else if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op)) { MI->addOperand(MachineOperand::CreateImm(C->getValue())); } else if (ConstantFPSDNode *F = dyn_cast<ConstantFPSDNode>(Op)) { - const Type *FType = MVT::getTypeForValueType(Op.getValueType()); - ConstantFP *CFP = ConstantFP::get(FType, F->getValueAPF()); + ConstantFP *CFP = ConstantFP::get(F->getValueAPF()); MI->addOperand(MachineOperand::CreateFPImm(CFP)); } else if (RegisterSDNode *R = dyn_cast<RegisterSDNode>(Op)) { MI->addOperand(MachineOperand::CreateReg(R->getReg(), false)); diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 776129e..281869a 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -235,22 +235,26 @@ GenericValue JIT::runFunction(Function *F, const GenericValue &AV = ArgValues[i]; switch (ArgTy->getTypeID()) { default: assert(0 && "Unknown argument type for function call!"); - case Type::IntegerTyID: C = ConstantInt::get(AV.IntVal); break; - case Type::FloatTyID: C = ConstantFP ::get(ArgTy, APFloat(AV.FloatVal)); - break; - case Type::DoubleTyID: C = ConstantFP ::get(ArgTy, APFloat(AV.DoubleVal)); - break; + case Type::IntegerTyID: + C = ConstantInt::get(AV.IntVal); + break; + case Type::FloatTyID: + C = ConstantFP::get(APFloat(AV.FloatVal)); + break; + case Type::DoubleTyID: + C = ConstantFP::get(APFloat(AV.DoubleVal)); + break; case Type::PPC_FP128TyID: case Type::X86_FP80TyID: - case Type::FP128TyID: C = ConstantFP ::get(ArgTy, APFloat(AV.IntVal)); - break; + case Type::FP128TyID: + C = ConstantFP::get(APFloat(AV.IntVal)); + break; case Type::PointerTyID: void *ArgPtr = GVTOP(AV); - if (sizeof(void*) == 4) { + if (sizeof(void*) == 4) C = ConstantInt::get(Type::Int32Ty, (int)(intptr_t)ArgPtr); - } else { + else C = ConstantInt::get(Type::Int64Ty, (intptr_t)ArgPtr); - } C = ConstantExpr::getIntToPtr(C, ArgTy); // Cast the integer to pointer break; } diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 0e27c00..3a4dc23 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -4368,14 +4368,13 @@ SDOperand X86TargetLowering::LowerFABS(SDOperand Op, SelectionDAG &DAG) { MVT::ValueType EltVT = VT; if (MVT::isVector(VT)) EltVT = MVT::getVectorElementType(VT); - const Type *OpNTy = MVT::getTypeForValueType(EltVT); std::vector<Constant*> CV; if (EltVT == MVT::f64) { - Constant *C = ConstantFP::get(OpNTy, APFloat(APInt(64, ~(1ULL << 63)))); + Constant *C = ConstantFP::get(APFloat(APInt(64, ~(1ULL << 63)))); CV.push_back(C); CV.push_back(C); } else { - Constant *C = ConstantFP::get(OpNTy, APFloat(APInt(32, ~(1U << 31)))); + Constant *C = ConstantFP::get(APFloat(APInt(32, ~(1U << 31)))); CV.push_back(C); CV.push_back(C); CV.push_back(C); @@ -4397,14 +4396,13 @@ SDOperand X86TargetLowering::LowerFNEG(SDOperand Op, SelectionDAG &DAG) { EltVT = MVT::getVectorElementType(VT); EltNum = MVT::getVectorNumElements(VT); } - const Type *OpNTy = MVT::getTypeForValueType(EltVT); std::vector<Constant*> CV; if (EltVT == MVT::f64) { - Constant *C = ConstantFP::get(OpNTy, APFloat(APInt(64, 1ULL << 63))); + Constant *C = ConstantFP::get(APFloat(APInt(64, 1ULL << 63))); CV.push_back(C); CV.push_back(C); } else { - Constant *C = ConstantFP::get(OpNTy, APFloat(APInt(32, 1U << 31))); + Constant *C = ConstantFP::get(APFloat(APInt(32, 1U << 31))); CV.push_back(C); CV.push_back(C); CV.push_back(C); @@ -4430,19 +4428,16 @@ SDOperand X86TargetLowering::LowerFCOPYSIGN(SDOperand Op, SelectionDAG &DAG) { SDOperand Op1 = Op.getOperand(1); MVT::ValueType VT = Op.getValueType(); MVT::ValueType SrcVT = Op1.getValueType(); - const Type *SrcTy = MVT::getTypeForValueType(SrcVT); // If second operand is smaller, extend it first. if (MVT::getSizeInBits(SrcVT) < MVT::getSizeInBits(VT)) { Op1 = DAG.getNode(ISD::FP_EXTEND, VT, Op1); SrcVT = VT; - SrcTy = MVT::getTypeForValueType(SrcVT); } // And if it is bigger, shrink it first. if (MVT::getSizeInBits(SrcVT) > MVT::getSizeInBits(VT)) { Op1 = DAG.getNode(ISD::FP_ROUND, VT, Op1, DAG.getIntPtrConstant(1)); SrcVT = VT; - SrcTy = MVT::getTypeForValueType(SrcVT); } // At this point the operands and the result should have the same @@ -4451,13 +4446,13 @@ SDOperand X86TargetLowering::LowerFCOPYSIGN(SDOperand Op, SelectionDAG &DAG) { // First get the sign bit of second operand. std::vector<Constant*> CV; if (SrcVT == MVT::f64) { - CV.push_back(ConstantFP::get(SrcTy, APFloat(APInt(64, 1ULL << 63)))); - CV.push_back(ConstantFP::get(SrcTy, APFloat(APInt(64, 0)))); + CV.push_back(ConstantFP::get(APFloat(APInt(64, 1ULL << 63)))); + CV.push_back(ConstantFP::get(APFloat(APInt(64, 0)))); } else { - CV.push_back(ConstantFP::get(SrcTy, APFloat(APInt(32, 1U << 31)))); - CV.push_back(ConstantFP::get(SrcTy, APFloat(APInt(32, 0)))); - CV.push_back(ConstantFP::get(SrcTy, APFloat(APInt(32, 0)))); - CV.push_back(ConstantFP::get(SrcTy, APFloat(APInt(32, 0)))); + CV.push_back(ConstantFP::get(APFloat(APInt(32, 1U << 31)))); + CV.push_back(ConstantFP::get(APFloat(APInt(32, 0)))); + CV.push_back(ConstantFP::get(APFloat(APInt(32, 0)))); + CV.push_back(ConstantFP::get(APFloat(APInt(32, 0)))); } Constant *C = ConstantVector::get(CV); SDOperand CPIdx = DAG.getConstantPool(C, getPointerTy(), 4); @@ -4480,13 +4475,13 @@ SDOperand X86TargetLowering::LowerFCOPYSIGN(SDOperand Op, SelectionDAG &DAG) { // Clear first operand sign bit. CV.clear(); if (VT == MVT::f64) { - CV.push_back(ConstantFP::get(SrcTy, APFloat(APInt(64, ~(1ULL << 63))))); - CV.push_back(ConstantFP::get(SrcTy, APFloat(APInt(64, 0)))); + CV.push_back(ConstantFP::get(APFloat(APInt(64, ~(1ULL << 63))))); + CV.push_back(ConstantFP::get(APFloat(APInt(64, 0)))); } else { - CV.push_back(ConstantFP::get(SrcTy, APFloat(APInt(32, ~(1U << 31))))); - CV.push_back(ConstantFP::get(SrcTy, APFloat(APInt(32, 0)))); - CV.push_back(ConstantFP::get(SrcTy, APFloat(APInt(32, 0)))); - CV.push_back(ConstantFP::get(SrcTy, APFloat(APInt(32, 0)))); + CV.push_back(ConstantFP::get(APFloat(APInt(32, ~(1U << 31))))); + CV.push_back(ConstantFP::get(APFloat(APInt(32, 0)))); + CV.push_back(ConstantFP::get(APFloat(APInt(32, 0)))); + CV.push_back(ConstantFP::get(APFloat(APInt(32, 0)))); } C = ConstantVector::get(CV); CPIdx = DAG.getConstantPool(C, getPointerTy(), 4); diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 7b97473..d1e66ba 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -7560,11 +7560,10 @@ Instruction *InstCombiner::visitSExt(SExtInst &CI) { /// FitsInFPType - Return a Constant* for the specified FP constant if it fits /// in the specified FP type without changing its value. -static Constant *FitsInFPType(ConstantFP *CFP, const Type *FPTy, - const fltSemantics &Sem) { +static Constant *FitsInFPType(ConstantFP *CFP, const fltSemantics &Sem) { APFloat F = CFP->getValueAPF(); if (F.convert(Sem, APFloat::rmNearestTiesToEven) == APFloat::opOK) - return ConstantFP::get(FPTy, F); + return ConstantFP::get(F); return 0; } @@ -7582,11 +7581,11 @@ static Value *LookThroughFPExtensions(Value *V) { if (CFP->getType() == Type::PPC_FP128Ty) return V; // No constant folding of this. // See if the value can be truncated to float and then reextended. - if (Value *V = FitsInFPType(CFP, Type::FloatTy, APFloat::IEEEsingle)) + if (Value *V = FitsInFPType(CFP, APFloat::IEEEsingle)) return V; if (CFP->getType() == Type::DoubleTy) return V; // Won't shrink. - if (Value *V = FitsInFPType(CFP, Type::DoubleTy, APFloat::IEEEdouble)) + if (Value *V = FitsInFPType(CFP, APFloat::IEEEdouble)) return V; // Don't try to shrink to various long double types. } |