[flang-commits] [clang] [clang-tools-extra] [compiler-rt] [llvm] [flang] [VPlan] Replace VPRecipeOrVPValue with VP2VP recipe simplification. (PR #76090)

via flang-commits flang-commits at lists.llvm.org
Fri Jan 26 03:34:26 PST 2024


================
@@ -806,6 +806,19 @@ static unsigned getOpcodeForRecipe(VPRecipeBase &R) {
 
 /// Try to simplify recipe \p R.
 static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
+  // Try to remove redundant blend recipes.
+  if (auto *Blend = dyn_cast<VPBlendRecipe>(&R)) {
+    bool AllEqual = true;
+    for (unsigned I = 1; I != Blend->getNumIncomingValues(); ++I)
+      AllEqual &= Blend->getIncomingValue(0) == Blend->getIncomingValue(I);
+    if (AllEqual) {
+      Blend->replaceAllUsesWith(Blend->getIncomingValue(0));
+      Blend->eraseFromParent();
+      return;
+    }
+    return;
+  }
----------------
ayalz wrote:

Can be simplified?
```suggestion
  if (auto *Blend = dyn_cast<VPBlendRecipe>(&R)) {
    for (unsigned I = 1; I != Blend->getNumIncomingValues(); ++I)
      if (Blend->getIncomingValue(0) != Blend->getIncomingValue(I))
        return;
    Blend->replaceAllUsesWith(Blend->getIncomingValue(0));
    Blend->eraseFromParent();
    return;
  }
```

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


More information about the flang-commits mailing list