summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2019-06-06 19:02:18 +0000
committerCraig Topper <craig.topper@intel.com>2019-06-06 19:02:18 +0000
commit6cda33ba364208b866252e49a8b5367c28cd2825 (patch)
treec513b2cec8a61c2412e076637a222c2e83d753eb /llvm/lib
parent51f85b40bc6ccfce3d6f3c8d984ce6af2336116f (diff)
downloadbcm5719-llvm-6cda33ba364208b866252e49a8b5367c28cd2825.tar.gz
bcm5719-llvm-6cda33ba364208b866252e49a8b5367c28cd2825.zip
[InlineCost] Add support for unary fneg.
This adds support for unary fneg based on the implementation of BinaryOperator without the soft float FP cost. Previously we would just delegate to visitUnaryInstruction. I think the only real change is that we will pass the FastMath flags to SimplifyFNeg now. Differential Revision: https://reviews.llvm.org/D62699 llvm-svn: 362732
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index a332a439007..3cb56f8cccf 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -273,6 +273,7 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
bool visitCmpInst(CmpInst &I);
bool visitSub(BinaryOperator &I);
bool visitBinaryOperator(BinaryOperator &I);
+ bool visitFNeg(UnaryOperator &I);
bool visitLoad(LoadInst &I);
bool visitStore(StoreInst &I);
bool visitExtractValue(ExtractValueInst &I);
@@ -1106,6 +1107,28 @@ bool CallAnalyzer::visitBinaryOperator(BinaryOperator &I) {
return false;
}
+bool CallAnalyzer::visitFNeg(UnaryOperator &I) {
+ Value *Op = I.getOperand(0);
+ Constant *COp = dyn_cast<Constant>(Op);
+ if (!COp)
+ COp = SimplifiedValues.lookup(Op);
+
+ Value *SimpleV = SimplifyFNegInst(COp ? COp : Op,
+ cast<FPMathOperator>(I).getFastMathFlags(),
+ DL);
+
+ if (Constant *C = dyn_cast_or_null<Constant>(SimpleV))
+ SimplifiedValues[&I] = C;
+
+ if (SimpleV)
+ return true;
+
+ // Disable any SROA on arguments to arbitrary, unsimplified fneg.
+ disableSROA(Op);
+
+ return false;
+}
+
bool CallAnalyzer::visitLoad(LoadInst &I) {
Value *SROAArg;
DenseMap<Value *, int>::iterator CostIt;
OpenPOWER on IntegriCloud