[mlir][Shape] Mark BroadcastOp as not having side effects

This allows it to be dead code eliminated when unused.

Differential Revision: https://reviews.llvm.org/D96797
This commit is contained in:
Benjamin Kramer 2021-02-16 18:29:19 +01:00
parent e1a64aa66c
commit 82b692e546
2 changed files with 12 additions and 1 deletions

View File

@ -49,7 +49,7 @@ def Shape_AddOp : Shape_Op<"add", [Commutative, NoSideEffect]> {
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

View File

@ -132,6 +132,17 @@ func @f() -> !shape.shape {
// -----
// 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 {