================
@@ -565,13 +580,31 @@ mlir::Value CIRGenFunction::emitLoadOfScalar(Address 
addr, bool isVolatile,
       return nullptr;
     }
 
-    const auto vecTy = cast<cir::VectorType>(eltTy);
+    // Handles vectors of sizes that are likely to be expanded to a larger size
+    // to optimize performance.
+    auto vecTy = cast<cir::VectorType>(eltTy);
+    cir::VectorType newVecTy =
+        cgm.getTargetCIRGenInfo().getABIInfo().getOptimalVectorMemoryType(
+            vecTy, getLangOpts());
+
+    if (vecTy != newVecTy) {
+      Address cast = addr.withElementType(builder, newVecTy);
+      mlir::Value value = builder.createLoad(cgm.getLoc(loc), cast, 
isVolatile);
+
+      unsigned oldNumElements = vecTy.getSize();
----------------
andykaylor wrote:

Can you assert that `newVecTy->getSize() > oldNumElements`?

https://github.com/llvm/llvm-project/pull/161232
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to