summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2017-12-27 01:30:12 +0000
committerPhilip Reames <listmail@philipreames.com>2017-12-27 01:30:12 +0000
commitcd13a663813f74a2d464387ad75072ec5b696644 (patch)
tree5c725d816d3072a1ab5dadf64ea9fb3c9662b6b7 /llvm/lib
parent5000ba69d740c765a537c0a8d2e7990ff4f4f47c (diff)
downloadbcm5719-llvm-cd13a663813f74a2d464387ad75072ec5b696644.tar.gz
bcm5719-llvm-cd13a663813f74a2d464387ad75072ec5b696644.zip
[instcombine] add powi(x, 2) -> x * x
llvm-svn: 321468
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 4dfb22abb6e..5e0778d9ae2 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1934,6 +1934,10 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
if (Power->isMinusOne())
return BinaryOperator::CreateFDiv(ConstantFP::get(CI.getType(), 1.0),
II->getArgOperand(0));
+ // powi(x, 2) -> x*x
+ if (Power->equalsInt(2))
+ return BinaryOperator::CreateFMul(II->getArgOperand(0),
+ II->getArgOperand(0));
}
break;
OpenPOWER on IntegriCloud