forked from OSchip/llvm-project
[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:
parent
e1a64aa66c
commit
82b692e546
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue