[Mlir-commits] [mlir] [MLIR][Vector] Implement transferXXPermutationLowering as MaskableOpRewritePattern (PR #91987)

Andrzej WarzyƄski llvmlistbot at llvm.org
Fri May 17 09:30:47 PDT 2024


================
@@ -157,7 +157,10 @@ struct MaskableOpRewritePattern : OpRewritePattern<SourceOp> {
     if (failed(newOp))
       return failure();
 
-    rewriter.replaceOp(rootOp, *newOp);
+    if (rootOp->getNumResults() == 0 || *newOp == Value())
+      rewriter.eraseOp(rootOp);
+    else
+      rewriter.replaceOp(rootOp, *newOp);
----------------
banach-space wrote:

IIUC, the only case that we are testing now is when "there's no return value" **and** "newOp is Value()". Hence I'm suggesting to replace `||` with `&&`. 

```suggestion
    // In the memref case there won't be a return value to replace. Instead, use an empty value to signal success.
    if (rootOp->getNumResults() == 0 && *newOp == Value())
      rewriter.eraseOp(rootOp);
    else
      rewriter.replaceOp(rootOp, *newOp);
```

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


More information about the Mlir-commits mailing list