From ade3dc8f753d1f09ee08360a70d5d163bb57daf5 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 6 Jun 2019 19:21:23 +0000 Subject: [PATCH] [CFLGraph] Add support for unary fneg instruction. Differential Revision: https://reviews.llvm.org/D62791 llvm-svn: 362737 --- lib/Analysis/CFLGraph.h | 10 ++++++++++ .../CFLAliasAnalysis/Steensgaard/must-and-partial.ll | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Analysis/CFLGraph.h b/lib/Analysis/CFLGraph.h index cd7c2df8041..21842ed3648 100644 --- a/lib/Analysis/CFLGraph.h +++ b/lib/Analysis/CFLGraph.h @@ -291,6 +291,11 @@ template class CFLGraphBuilder { addAssignEdge(Op2, &Inst); } + void visitUnaryOperator(UnaryOperator &Inst) { + auto *Src = Inst.getOperand(0); + addAssignEdge(Src, &Inst); + } + void visitAtomicCmpXchgInst(AtomicCmpXchgInst &Inst) { auto *Ptr = Inst.getPointerOperand(); auto *Val = Inst.getNewValOperand(); @@ -579,6 +584,11 @@ template class CFLGraphBuilder { break; } + case Instruction::FNeg: { + addAssignEdge(CE->getOperand(0), CE); + break; + } + default: llvm_unreachable("Unknown instruction type encountered!"); } diff --git a/test/Analysis/CFLAliasAnalysis/Steensgaard/must-and-partial.ll b/test/Analysis/CFLAliasAnalysis/Steensgaard/must-and-partial.ll index cc03870b794..b1f96220662 100644 --- a/test/Analysis/CFLAliasAnalysis/Steensgaard/must-and-partial.ll +++ b/test/Analysis/CFLAliasAnalysis/Steensgaard/must-and-partial.ll @@ -49,6 +49,7 @@ define void @testr2(double* nocapture readonly %A, double* nocapture readonly %I %1 = load double, double* %arrayidx22 %arrayidx25 = getelementptr inbounds double, double* %A, i64 2 %2 = load double, double* %arrayidx25 - %mul26 = fmul double %1, %2 + %3 = fneg double %1 + %mul26 = fmul double %3, %2 ret void }