Skip to content

Commit

Permalink
[Handshake] Add NoSideEffect to SinkOp to participate in CSE. (llvm#620)
Browse files Browse the repository at this point in the history
This allows unused constants and anything else that ends up in a
SinkOp to be removed by CSE and canonicalization.
  • Loading branch information
mikeurbach authored Feb 22, 2021
1 parent d4655d1 commit f1adbf0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions include/circt/Dialect/Handshake/HandshakeOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,9 @@ def ConditionalBranchOp : Handshake_Op<"conditional_branch", [
}];
}

def SinkOp
: Handshake_Op<"sink", [DeclareOpInterfaceMethods<ExecutableOpInterface>]> {
def SinkOp : Handshake_Op<"sink", [
NoSideEffect, DeclareOpInterfaceMethods<ExecutableOpInterface>
]> {
let summary = "sink operation";
let description = [{
The "handshake.sink" operation discards any data that arrives at its
Expand Down
4 changes: 2 additions & 2 deletions test/Conversion/StandardToHandshake/test_canonicalize.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module {
// CHECK-SAME: %[[VAL_0:.*]]: none, ...) -> none {
handshake.func @simple(%arg0: none, ...) -> none {

// CHECK: %[[VAL_1:.*]] = "handshake.constant"(%[[VAL_0:.*]]) {value = 1 : index} : (none) -> index
// CHECK-NOT: "handshake.constant"(%arg0)
%0 = "handshake.constant"(%arg0) {value = 1 : index} : (none) -> index

// CHECK-NOT: %[[TMP_0:.*]] = "handshake.branch"(%[[VAL_0:.*]]) {control = true} : (none) -> none
Expand All @@ -26,4 +26,4 @@ module {
"handshake.sink"(%7) : (index) -> ()
handshake.return %5#1 : none
}
}
}

0 comments on commit f1adbf0

Please sign in to comment.