[llvm] [LLVM][InstCombine] Preserve vector types when shrinking FP constants. (PR #163598)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 15 12:53:11 PDT 2025


================
@@ -1720,10 +1730,10 @@ static Type *getMinimumFPType(Value *V, bool PreferBFloat) {
 
   // Try to shrink scalable and fixed splat vectors.
   if (auto *FPC = dyn_cast<Constant>(V))
-    if (isa<VectorType>(V->getType()))
+    if (auto *VTy = dyn_cast<VectorType>(V->getType()))
       if (auto *Splat = dyn_cast_or_null<ConstantFP>(FPC->getSplatValue()))
         if (Type *T = shrinkFPConstant(Splat, PreferBFloat))
-          return T;
+          return VectorType::get(T, VTy);
----------------
nikic wrote:

This looks right to me, but I don't really get how this worked previously. E.g. v4f32_fadd has a vector splat, why did that work?

https://github.com/llvm/llvm-project/pull/163598


More information about the llvm-commits mailing list