Skip to content
Draft
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
6 changes: 6 additions & 0 deletions xls/codegen/node_expressions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,9 @@ absl::StatusOr<Expression*> NodeToExpression(
case Op::kShrl:
return EmitShift(node, inputs[0], inputs[1], file);
case Op::kSignExt: {
if (node->BitCountOrDie() == node->operand(0)->BitCountOrDie()) {
return inputs[0];
}
if (node->operand(0)->BitCountOrDie() == 1) {
// A sign extension of a single-bit value is just replication.
return file->Concat(
Expand Down Expand Up @@ -709,6 +712,9 @@ absl::StatusOr<Expression*> NodeToExpression(
case Op::kXorReduce:
return file->XorReduce(inputs[0], node->loc());
case Op::kZeroExt: {
if (node->BitCountOrDie() == node->operand(0)->BitCountOrDie()) {
return inputs[0];
}
int64_t bits_added =
node->BitCountOrDie() - node->operand(0)->BitCountOrDie();

Expand Down
Loading