diff options
author | Chris Lattner <sabre@nondot.org> | 2007-01-15 06:27:37 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-01-15 06:27:37 +0000 |
commit | b5282dcf4745be59046f440980a1c0f0a50c9c09 (patch) | |
tree | 7ebabdb42ffe5c874173121e533c9d5e0e017433 /lib/Analysis/ConstantFolding.cpp | |
parent | 7ace299bdca4c5397eb7962dc5360e693ba77e5d (diff) | |
download | external_llvm-b5282dcf4745be59046f440980a1c0f0a50c9c09.zip external_llvm-b5282dcf4745be59046f440980a1c0f0a50c9c09.tar.gz external_llvm-b5282dcf4745be59046f440980a1c0f0a50c9c09.tar.bz2 |
Constant fold llvm.powi.*. This speeds up tramp3d--v4 by 9.5%
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33229 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | lib/Analysis/ConstantFolding.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index b4c4137..46f9c57 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -40,6 +40,8 @@ llvm::canConstantFoldCallTo(Function *F) { case Intrinsic::bswap_i16: case Intrinsic::bswap_i32: case Intrinsic::bswap_i64: + case Intrinsic::powi_f32: + case Intrinsic::powi_f64: // FIXME: these should be constant folded as well //case Intrinsic::ctpop_i8: //case Intrinsic::ctpop_i16: @@ -186,8 +188,17 @@ llvm::ConstantFoldCall(Function *F, const std::vector<Constant*> &Operands) { double V = fmod(Op1V, Op2V); if (errno == 0) return ConstantFP::get(Ty, V); - } else if (Name == "atan2") + } else if (Name == "atan2") { return ConstantFP::get(Ty, atan2(Op1V,Op2V)); + } + } else if (ConstantInt *Op2C = dyn_cast<ConstantInt>(Operands[1])) { + if (Name == "llvm.powi.f32") { + return ConstantFP::get(Ty, std::pow((float)Op1V, + (int)Op2C->getZExtValue())); + } else if (Name == "llvm.powi.f64") { + return ConstantFP::get(Ty, std::pow((double)Op1V, + (int)Op2C->getZExtValue())); + } } } } |