================
@@ -5194,6 +5252,36 @@ selectPartitionType(Partition &P, const DataLayout &DL, 
AllocaInst &AI,
         isIntegerWideningViable(P, LargestIntTy, DL))
       return {LargestIntTy, true, nullptr};
 
+    // Try homogeneous struct to vector canonicalization, but only when
+    // the conversion would actually benefit from vectorization: either
+    // the partition has non-splittable typed uses, or the alloca is
+    // involved in phi/select patterns (enabling speculation).
+    //
+    // When all uses are splittable (memcpy/lifetime only) and there's no
+    // phi/select involvement, converting to vector just changes memcpy
+    // split types without enabling promotion, propagating vector types to
+    // other allocas and causing insertelement/extractelement overhead.
+    {
+      bool HasNonSplittable =
+          any_of(P, [](const Slice &S) { return !S.isSplittable(); });
+      bool ShouldConvert = HasNonSplittable;
+      if (!ShouldConvert) {
+        ShouldConvert = any_of(AI.users(), [&AI](const User *U) {
----------------
vtjnash wrote:

My understanding of this part of the pass is that you're only permitted to look 
at the slices in Partition P here, and not allowed to look directly at 
`AI.users()`

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

Reply via email to