[llvm] [SLP]Vectorize reductions with fptrunc/fpext round-trip links (PR #215571)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 12:53:58 PDT 2026


================
@@ -754,4 +754,20 @@ bool isOnceUsedSeed(const Instruction *I) {
       I);
 }
 
+Instruction *lookThroughCastRoundTrip(Value *V, bool MustBeElidable) {
+  auto *Wide = dyn_cast<FPExtInst>(V);
+  if (!Wide || !Wide->hasOneUse())
+    return nullptr;
+  auto *Narrow = dyn_cast<FPTruncInst>(Wide->getOperand(0));
+  if (!Narrow || !Narrow->hasOneUse())
+    return nullptr;
+  Value *Src = Narrow->getOperand(0);
+  if (!isa<Instruction>(Src) || Src->getType() != Wide->getType())
+    return nullptr;
+  if (MustBeElidable && !(Wide->hasAllowContract() && Wide->hasNoNaNs() &&
+                          Wide->hasNoInfs() && Narrow->hasAllowContract()))
+    return nullptr;
----------------
alexey-bataev wrote:

I thought about it, but I think we still may see such nodes in SLP.
But I agree, that we need this in Instcombiner

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


More information about the llvm-commits mailing list