Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/NeuraDialect/NeuraOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,15 @@ def Neura_FMinOp : Op<NeuraDialect, "fmin"> {
// Defines a bitwise OR operation.
def Neura_AndOp : Op<NeuraDialect, "and"> {
let summary = "Bitwise AND operation";
let arguments = (ins AnyType:$lhs, AnyType:$rhs);
let arguments = (ins AnyType:$lhs, Optional<AnyType>:$rhs);
let results = (outs AnyType:$result);
// let assemblyFormat = "$lhs `,` $rhs `,` attr-dict `:` type($result)";
let traits = [SameOperandsAndResultElementType];
}

def Neura_OrOp : Op<NeuraDialect, "or"> {
let summary = "Bitwise OR operation";
let arguments = (ins AnyType:$lhs, AnyType:$rhs);
let arguments = (ins AnyType:$lhs, Optional<AnyType>:$rhs);
let results = (outs AnyType:$result);
// let assemblyFormat = "$lhs `,` $rhs `,` attr-dict `:` type($result)";
let traits = [SameOperandsAndResultElementType];
Expand Down
19 changes: 16 additions & 3 deletions lib/NeuraDialect/Transforms/CanonicalizeLiveInPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,11 @@ LogicalResult promoteLiveInValuesToBlockArgs(Region &region,
continue;
}

if (direct_dominating_live_in_values[&current_block].contains(
live_in)) {
continue;
}

// If it is defined in the current block, that means it is not a
// live-in value for the current block. We can skip it.
if (Operation *def_op = live_in.getDefiningOp()) {
Expand Down Expand Up @@ -696,7 +701,7 @@ LogicalResult promoteLiveInValuesToBlockArgs(Region &region,
} else if (all_live_ins[pred_block].contains(live_in)) {
new_operands.push_back(block_value_to_arg[{pred_block, live_in}]);
} else {
assert(false && "Unexpected live-in value");
assert(false && "Unexpected live-in value (br operation)");
}
}
OpBuilder builder(br_op);
Expand All @@ -720,11 +725,15 @@ LogicalResult promoteLiveInValuesToBlockArgs(Region &region,
true_operands.push_back(live_in);
} else if (block_arg && block_arg.getOwner() == pred_block) {
true_operands.push_back(block_arg);
} else if (direct_dominating_live_in_values[pred_block].contains(
live_in)) {
true_operands.push_back(live_in);
} else if (all_live_ins[pred_block].contains(live_in)) {
true_operands.push_back(
block_value_to_arg[{pred_block, live_in}]);
} else {
assert(false && "Unexpected live-in value");
assert(false && "Unexpected live-in value (true branch of "
"cond_br operation)");
}
}
}
Expand All @@ -739,11 +748,15 @@ LogicalResult promoteLiveInValuesToBlockArgs(Region &region,
false_operands.push_back(live_in);
} else if (block_arg && block_arg.getOwner() == pred_block) {
false_operands.push_back(block_arg);
} else if (direct_dominating_live_in_values[pred_block].contains(
live_in)) {
false_operands.push_back(live_in);
} else if (all_live_ins[pred_block].contains(live_in)) {
false_operands.push_back(
block_value_to_arg[{pred_block, live_in}]);
} else {
assert(false && "Unexpected live-in value");
assert(false && "Unexpected live-in value (false branch of "
"cond_br operation)");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/benchmark/CGRA-Bench
Loading