summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-05-06 05:50:07 +0000
committerChris Lattner <sabre@nondot.org>2010-05-06 05:50:07 +0000
commit68784efaf62af6cc4234ea01f378e859dd7bfbab (patch)
treefafaf448dbe23158f716c4782974cd4d24a61c53 /clang/lib
parent43660c5bc00e052d92c065645393d00b9ff3463d (diff)
downloadbcm5719-llvm-68784efaf62af6cc4234ea01f378e859dd7bfbab.tar.gz
bcm5719-llvm-68784efaf62af6cc4234ea01f378e859dd7bfbab.zip
optimize builtin_isnan/isinf to not do an extraneous extension from
float -> double (which happens because they are modelled as int(...) functions), and add a testcase for isinf. llvm-svn: 103167
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 7029711d446..e60dfd3452c 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -607,12 +607,25 @@ bool Sema::SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs) {
if (OrigArg->isTypeDependent())
return false;
- // This operation requires a floating-point number
+ // This operation requires a non-_Complex floating-point number.
if (!OrigArg->getType()->isRealFloatingType())
return Diag(OrigArg->getLocStart(),
diag::err_typecheck_call_invalid_unary_fp)
<< OrigArg->getType() << OrigArg->getSourceRange();
+ // If this is an implicit conversion from float -> double, remove it.
+ if (ImplicitCastExpr *Cast = dyn_cast<ImplicitCastExpr>(OrigArg)) {
+ Expr *CastArg = Cast->getSubExpr();
+ if (CastArg->getType()->isSpecificBuiltinType(BuiltinType::Float)) {
+ assert(Cast->getType()->isSpecificBuiltinType(BuiltinType::Double) &&
+ "promotion from float to double is the only expected cast here");
+ Cast->setSubExpr(0);
+ Cast->Destroy(Context);
+ TheCall->setArg(NumArgs-1, CastArg);
+ OrigArg = CastArg;
+ }
+ }
+
return false;
}
OpenPOWER on IntegriCloud