[Mlir-commits] [mlir] [mlir][tosa] Enhance TosaInferShapes pass for simple shape inference (PR #178418)

Luke Hutton llvmlistbot at llvm.org
Wed Feb 25 05:50:32 PST 2026


================
@@ -315,7 +315,14 @@ struct TosaInferShapes
 
         if (foldShapeExpressions &&
             op.hasTrait<OpTrait::tosa::TosaShapeOperator>()) {
-          (void)folder.tryToFold(&op);
+          const LogicalResult foldResult = folder.tryToFold(&op);
+          if (succeeded(foldResult))
+            // Clean up any dead const_shape ops as a result of folding.
+            llvm::for_each(op.getOperands(), [](Value operand) {
----------------
lhutton1 wrote:

You're correct, infact, I'm not sure how this worked. I'll change this logic to use @Tai78641's suggestion and remove dead ops after infer shapes has run. Thanks for the catch!

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


More information about the Mlir-commits mailing list