[MLIR] Drop assert for NYI in VectorAnalysis

This CLs adds proper error emission, removes NYI assertions and documents
assumptions that are required in the relevant functions.

PiperOrigin-RevId: 224377143
diff --git a/lib/Analysis/VectorAnalysis.cpp b/lib/Analysis/VectorAnalysis.cpp
index ebddaff..7bbe2d6 100644
--- a/lib/Analysis/VectorAnalysis.cpp
+++ b/lib/Analysis/VectorAnalysis.cpp
@@ -79,7 +79,7 @@
 Optional<SmallVector<unsigned, 4>> mlir::shapeRatio(VectorType superVectorType,
                                                     VectorType subVectorType) {
   assert(superVectorType.getElementType() == subVectorType.getElementType() &&
-         "NYI: vector types must be of the same elemental type");
+         "vector types must be of the same elemental type");
   return shapeRatio(superVectorType.getShape(), subVectorType.getShape());
 }
 
@@ -197,9 +197,10 @@
     superVectorType = write->getVectorType();
     mustDivide = true;
   } else if (opStmt.getNumResults() == 0) {
-    assert(opStmt.isa<ReturnOp>() &&
-           "NYI: assuming only return statements can have 0 results at this "
-           "point");
+    if (!opStmt.isa<ReturnOp>()) {
+      opStmt.emitError("NYI: assuming only return statements can have 0 "
+                       " results at this point");
+    }
     return false;
   } else if (opStmt.getNumResults() == 1) {
     if (auto v = opStmt.getResult(0)->getType().dyn_cast<VectorType>()) {
@@ -211,7 +212,7 @@
   } else {
     // Not a vector_transfer and has more than 1 result, fail hard for now to
     // wake us up when something changes.
-    assert(false && "NYI: statement has more than 1 result");
+    opStmt.emitError("NYI: statement has more than 1 result");
     return false;
   }
 
@@ -220,7 +221,7 @@
 
   // Sanity check.
   assert((ratio.hasValue() || !mustDivide) &&
-         "NYI: vector_transfer instruction in which super-vector size is not an"
+         "vector_transfer instruction in which super-vector size is not an"
          " integer multiple of sub-vector size");
 
   // This catches cases that are not strictly necessary to have multiplicity but