[llvm] [VectorCombine] Preserves the maximal legal FPMathFlags during foldShuffleToIdentity (PR #94295)

David Green via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 4 00:19:57 PDT 2024


================
@@ -1736,23 +1739,64 @@ static Value *generateNewInstTree(ArrayRef<InstLane> Item, FixedVectorType *Ty,
     Ops[Idx] = generateNewInstTree(generateInstLaneVectorFromOperand(Item, Idx),
                                    Ty, IdentityLeafs, SplatLeafs, Builder);
   }
+
+  FastMathFlags FMF;
+  FMF.setFast();
+  for_each(Item, [&FMF, Lane = FrontLane](const InstLane &E) {
+    if (E.second != Lane)
+      return;
+    auto *I = cast<Instruction>(E.first);
+    if (isa<FPMathOperator>(I))
----------------
davemgreen wrote:

`if (auto *I = dyn_cast_or_null<FPMathOperator>(E.first))`, and I think it can drop the `E.second != Lane`, which I would guess is guarding against undef lanes where the value will be nullptr?

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


More information about the llvm-commits mailing list