diff options
| author | Chad Rosier <mcrosier@apple.com> | 2011-12-03 00:00:03 +0000 | 
|---|---|---|
| committer | Chad Rosier <mcrosier@apple.com> | 2011-12-03 00:00:03 +0000 | 
| commit | 0155a63513277d2acdd62a76aa8461bae7778232 (patch) | |
| tree | 39ba6138aeab4df70c67f008056b20fb81e1b136 /llvm/lib | |
| parent | 7f3884d58a1a90831a9946b7b8693cd4334611af (diff) | |
| download | bcm5719-llvm-0155a63513277d2acdd62a76aa8461bae7778232.tar.gz bcm5719-llvm-0155a63513277d2acdd62a76aa8461bae7778232.zip | |
Add support for constant folding the pow intrinsic.
rdar://10514247
llvm-svn: 145730
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 9 | 
1 files changed, 6 insertions, 3 deletions
| diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index c4ff616575a..d12476885e4 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -1053,6 +1053,7 @@ bool  llvm::canConstantFoldCallTo(const Function *F) {    switch (F->getIntrinsicID()) {    case Intrinsic::sqrt: +  case Intrinsic::pow:    case Intrinsic::powi:    case Intrinsic::bswap:    case Intrinsic::ctpop: @@ -1346,9 +1347,6 @@ llvm::ConstantFoldCall(Function *F, ArrayRef<Constant *> Operands,                        (double)Op1->getValueAPF().convertToFloat() :                        Op1->getValueAPF().convertToDouble();        if (ConstantFP *Op2 = dyn_cast<ConstantFP>(Operands[1])) { -        if (!TLI) -          return 0; -          if (Op2->getType() != Op1->getType())            return 0; @@ -1356,6 +1354,11 @@ llvm::ConstantFoldCall(Function *F, ArrayRef<Constant *> Operands,                        (double)Op2->getValueAPF().convertToFloat():                        Op2->getValueAPF().convertToDouble(); +        if (F->getIntrinsicID() == Intrinsic::pow) { +          return ConstantFoldBinaryFP(pow, Op1V, Op2V, Ty); +        } +        if (!TLI) +          return 0;          if (Name == "pow" && TLI->has(LibFunc::pow))            return ConstantFoldBinaryFP(pow, Op1V, Op2V, Ty);          if (Name == "fmod" && TLI->has(LibFunc::fmod)) | 

