mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 13:11:39 +01:00
simplify this code a bunch.
llvm-svn: 83294
This commit is contained in:
parent
30e2de19c7
commit
8b72a24a35
@ -721,9 +721,9 @@ static Constant *ConstantFoldFP(double (*NativeFP)(double), double V,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ty == Type::getFloatTy(Context))
|
if (Ty->isFloatTy())
|
||||||
return ConstantFP::get(Context, APFloat((float)V));
|
return ConstantFP::get(Context, APFloat((float)V));
|
||||||
if (Ty == Type::getDoubleTy(Context))
|
if (Ty->isDoubleTy())
|
||||||
return ConstantFP::get(Context, APFloat(V));
|
return ConstantFP::get(Context, APFloat(V));
|
||||||
llvm_unreachable("Can only constant fold float/double");
|
llvm_unreachable("Can only constant fold float/double");
|
||||||
return 0; // dummy return to suppress warning
|
return 0; // dummy return to suppress warning
|
||||||
@ -740,9 +740,9 @@ static Constant *ConstantFoldBinaryFP(double (*NativeFP)(double, double),
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ty == Type::getFloatTy(Context))
|
if (Ty->isFloatTy())
|
||||||
return ConstantFP::get(Context, APFloat((float)V));
|
return ConstantFP::get(Context, APFloat((float)V));
|
||||||
if (Ty == Type::getDoubleTy(Context))
|
if (Ty->isDoubleTy())
|
||||||
return ConstantFP::get(Context, APFloat(V));
|
return ConstantFP::get(Context, APFloat(V));
|
||||||
llvm_unreachable("Can only constant fold float/double");
|
llvm_unreachable("Can only constant fold float/double");
|
||||||
return 0; // dummy return to suppress warning
|
return 0; // dummy return to suppress warning
|
||||||
@ -756,19 +756,17 @@ llvm::ConstantFoldCall(Function *F,
|
|||||||
if (!F->hasName()) return 0;
|
if (!F->hasName()) return 0;
|
||||||
LLVMContext &Context = F->getContext();
|
LLVMContext &Context = F->getContext();
|
||||||
StringRef Name = F->getName();
|
StringRef Name = F->getName();
|
||||||
|
|
||||||
const Type *Ty = F->getReturnType();
|
const Type *Ty = F->getReturnType();
|
||||||
if (NumOperands == 1) {
|
if (NumOperands == 1) {
|
||||||
if (ConstantFP *Op = dyn_cast<ConstantFP>(Operands[0])) {
|
if (ConstantFP *Op = dyn_cast<ConstantFP>(Operands[0])) {
|
||||||
if (Ty != Type::getFloatTy(F->getContext()) &&
|
if (!Ty->isFloatTy() && !Ty->isDoubleTy())
|
||||||
Ty != Type::getDoubleTy(Context))
|
|
||||||
return 0;
|
return 0;
|
||||||
/// Currently APFloat versions of these functions do not exist, so we use
|
/// Currently APFloat versions of these functions do not exist, so we use
|
||||||
/// the host native double versions. Float versions are not called
|
/// the host native double versions. Float versions are not called
|
||||||
/// directly but for all these it is true (float)(f((double)arg)) ==
|
/// directly but for all these it is true (float)(f((double)arg)) ==
|
||||||
/// f(arg). Long double not supported yet.
|
/// f(arg). Long double not supported yet.
|
||||||
double V = Ty == Type::getFloatTy(Context) ?
|
double V = Ty->isFloatTy() ? (double)Op->getValueAPF().convertToFloat() :
|
||||||
(double)Op->getValueAPF().convertToFloat():
|
|
||||||
Op->getValueAPF().convertToDouble();
|
Op->getValueAPF().convertToDouble();
|
||||||
switch (Name[0]) {
|
switch (Name[0]) {
|
||||||
case 'a':
|
case 'a':
|
||||||
@ -854,14 +852,16 @@ llvm::ConstantFoldCall(Function *F,
|
|||||||
|
|
||||||
if (NumOperands == 2) {
|
if (NumOperands == 2) {
|
||||||
if (ConstantFP *Op1 = dyn_cast<ConstantFP>(Operands[0])) {
|
if (ConstantFP *Op1 = dyn_cast<ConstantFP>(Operands[0])) {
|
||||||
if (Ty!=Type::getFloatTy(F->getContext()) &&
|
if (!Ty->isFloatTy() && !Ty->isDoubleTy())
|
||||||
Ty!=Type::getDoubleTy(Context))
|
|
||||||
return 0;
|
return 0;
|
||||||
double Op1V = Ty==Type::getFloatTy(F->getContext()) ?
|
double Op1V = Ty->isFloatTy() ?
|
||||||
(double)Op1->getValueAPF().convertToFloat():
|
(double)Op1->getValueAPF().convertToFloat() :
|
||||||
Op1->getValueAPF().convertToDouble();
|
Op1->getValueAPF().convertToDouble();
|
||||||
if (ConstantFP *Op2 = dyn_cast<ConstantFP>(Operands[1])) {
|
if (ConstantFP *Op2 = dyn_cast<ConstantFP>(Operands[1])) {
|
||||||
double Op2V = Ty==Type::getFloatTy(F->getContext()) ?
|
if (Op2->getType() != Op1->getType())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
double Op2V = Ty->isFloatTy() ?
|
||||||
(double)Op2->getValueAPF().convertToFloat():
|
(double)Op2->getValueAPF().convertToFloat():
|
||||||
Op2->getValueAPF().convertToDouble();
|
Op2->getValueAPF().convertToDouble();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user