Skip to content

Commit

Permalink
[Substrait] Make all RelOps Pure.
Browse files Browse the repository at this point in the history
This allows canonicalization to remove ops whose results aren't used.
The commit also adapts one test to make sure that that is actually the
case.

Signed-off-by: Ingo Müller <ingomueller@google.com>
  • Loading branch information
ingomueller-net committed May 22, 2024
1 parent 13f2ac4 commit 16e333f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/structured/Dialect/Substrait/IR/SubstraitOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include "structured/Dialect/Substrait/IR/SubstraitDialect.td"
include "structured/Dialect/Substrait/IR/SubstraitInterfaces.td"
include "structured/Dialect/Substrait/IR/SubstraitTypes.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/IR/BuiltinAttributes.td"
include "mlir/IR/CommonAttrConstraints.td"
include "mlir/IR/OpBase.td"
Expand Down Expand Up @@ -212,7 +213,7 @@ def Substrait_LiteralOp : Substrait_ExpressionOp<"literal", [
/// Attaches all traits that ops representing a `Rel` message type should have.
class Substrait_RelOp<string mnemonic, list<Trait> traits = []> :
Substrait_Op<mnemonic, traits # [
Substrait_RelOpInterface,
Substrait_RelOpInterface, Pure,
PredOpTrait<"result must be extactly one Relation",
And<[
CPred<"$_op.getNumResults() == 1">,
Expand Down
3 changes: 1 addition & 2 deletions test/Dialect/Substrait/canonicalize.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ substrait.plan version 0 : 42 : 1 {
// CHECK-LABEL: substrait.plan
// CHECK-NEXT: relation
// CHECK-NEXT: %[[V0:.*]] = named_table
// TODO(ingomueller): check for DCE once implemented.
// CHECK: yield %[[V0]]
// CHECK-NEXT: yield %[[V0]]

substrait.plan version 0 : 42 : 1 {
relation {
Expand Down

0 comments on commit 16e333f

Please sign in to comment.