[PATCH] D62791: [CFLGraph] Add support for unary fneg instruction.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 6 10:07:56 PDT 2019


craig.topper updated this revision to Diff 203396.
craig.topper added a comment.

Stuck an fneg into an existing test that already had an fmul. This executes the visitUnaryOperator function. The constant expr path is still untested. But I think all the binary ops are untested there as well.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62791/new/

https://reviews.llvm.org/D62791

Files:
  llvm/lib/Analysis/CFLGraph.h
  llvm/test/Analysis/CFLAliasAnalysis/Steensgaard/must-and-partial.ll


Index: llvm/test/Analysis/CFLAliasAnalysis/Steensgaard/must-and-partial.ll
===================================================================
--- llvm/test/Analysis/CFLAliasAnalysis/Steensgaard/must-and-partial.ll
+++ llvm/test/Analysis/CFLAliasAnalysis/Steensgaard/must-and-partial.ll
@@ -49,6 +49,7 @@
   %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
 }
Index: llvm/lib/Analysis/CFLGraph.h
===================================================================
--- llvm/lib/Analysis/CFLGraph.h
+++ llvm/lib/Analysis/CFLGraph.h
@@ -291,6 +291,11 @@
       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 @@
         break;
       }
 
+      case Instruction::FNeg: {
+        addAssignEdge(CE->getOperand(0), CE);
+        break;
+      }
+
       default:
         llvm_unreachable("Unknown instruction type encountered!");
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62791.203396.patch
Type: text/x-patch
Size: 1318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190606/d4b8c3e8/attachment.bin>


More information about the llvm-commits mailing list