diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td --- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td +++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td @@ -49,7 +49,7 @@ let verifier = [{ return verifySizeOrIndexOp(*this); }]; } -def Shape_BroadcastOp : Shape_Op<"broadcast", [Commutative]> { +def Shape_BroadcastOp : Shape_Op<"broadcast", [Commutative, NoSideEffect]> { let summary = "Returns the broadcasted output shape of two or more inputs"; let description = [{ Returns the broadcasted shape for input shapes or extent tensors. The rest diff --git a/mlir/test/Dialect/Shape/canonicalize.mlir b/mlir/test/Dialect/Shape/canonicalize.mlir --- a/mlir/test/Dialect/Shape/canonicalize.mlir +++ b/mlir/test/Dialect/Shape/canonicalize.mlir @@ -132,6 +132,17 @@ // ----- +// Dead code +// CHECK-LABEL: @broadcast +func @broadcast(%arg0 : !shape.shape, %arg1 : !shape.shape) { + // CHECK-NEXT: return + %0 = shape.broadcast %arg0, %arg1 + : !shape.shape, !shape.shape -> !shape.shape + return +} + +// ----- + // Basic case. // CHECK-LABEL: func @f func @f() -> !shape.shape {