Skip to content
Draft
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
5 changes: 1 addition & 4 deletions xls/fuzzer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,6 @@ generate_crasher_regression_tests(
"crashers/crasher_2025-09-03_c1e3.x",
# TODO: https://github.com/google/xls/issues/2998 - Remove when fixed.
"crashers/crasher_2025-09-04_54f4.x",
# TODO: https://github.com/google/xls/issues/3577 - Remove when fixed.
"crashers/crasher_2025-12-18_bd85.x",
# TODO: https://github.com/google/xls/issues/686 - Remove when fixed.
"crashers/crasher_2022-09-01_f672.x",
# TODO: https://github.com/google/xls/issues/4044 - Remove when fixed.
Expand All @@ -413,8 +411,6 @@ generate_crasher_regression_tests(
"crashers/crasher_2026-04-10_7b7e.x",
# TODO: https://github.com/google/xls/issues/4142 - Remove when fixed.
"crashers/crasher_2026-04-22_2292.x",
# TODO: https://github.com/google/xls/issues/4209 - Remove when fixed.
"crashers/crasher_2026-05-05_45c4.x",
# TODO: https://github.com/google/xls/issues/4213 - Remove when fixed.
"crashers/crasher_2026-05-06_cad8.x",
# TODO: https://github.com/google/xls/issues/4214 - Remove when fixed.
Expand All @@ -425,6 +421,7 @@ generate_crasher_regression_tests(
"crashers/crasher_2026-05-21_c47d.x",
"crashers/crasher_2026-05-26_cf55.x",
],

# Tests which are too slow in the unopt-ir interpreter.
no_unopt_interpreter = [
# TODO(https://github.com/google/xls/issues/2263): Enormous copies of
Expand Down
4 changes: 2 additions & 2 deletions xls/fuzzer/crashers/crasher_2025-12-18_bd85.x
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// optimize_ir: true
// use_jit: true
// codegen: true
// codegen_args: "--use_system_verilog"
// codegen_args: "--nouse_system_verilog"
// codegen_args: "--output_block_ir_path=sample.block.ir"
// codegen_args: "--generator=pipeline"
// codegen_args: "--pipeline_stages=7"
Expand All @@ -33,7 +33,7 @@
// codegen_args: "--reset_asynchronous=true"
// codegen_args: "--reset_data_path=true"
// simulate: true
// use_system_verilog: true
// use_system_verilog: false
// timeout_seconds: 1500
// calls_per_sample: 128
// proc_ticks: 0
Expand Down
126 changes: 81 additions & 45 deletions xls/passes/bdd_query_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,56 +66,92 @@ namespace xls {

namespace {

// BDD evaluation of very wide data paths (e.g., shift operations on 1000+
// bits) can grow exponentially and hang the fuzzer or optimizer. We restrict
// evaluations to nodes with a bit width below this threshold to prevent
// explosion while keeping BDD optimization active for control logic and
// standard integer paths.
constexpr int64_t kMaxBddBitWidth = 128;

// BDD evaluation of very wide data paths for complex operations can grow
// exponentially. Restrict evaluations of these operations to nodes with a
// bit width below a threshold. Cheap operations like logical operations
// can be safely evaluated at any bit width.
constexpr auto kComplexOps = std::to_array<Op>({
Op::kAdd,
Op::kSub,
Op::kShll,
Op::kShrl,
Op::kShra,
Op::kEq,
Op::kNe,
Op::kULt,
Op::kULe,
Op::kUGt,
Op::kUGe,
Op::kSLt,
Op::kSLe,
Op::kSGt,
Op::kSGe,
Op::kDynamicBitSlice,
Op::kBitSliceUpdate,
});

// Ops which don't really have any reasonable BDD interpretation or which we
// otherwise wish to ignore (eg Gate, Map etc).
constexpr auto kNonAnalyzableOps = std::to_array<Op>({
Op::kAfterAll,
Op::kMinDelay,
Op::kArray,
Op::kArrayConcat,
Op::kArrayIndex,
Op::kArraySlice,
Op::kArrayUpdate,
Op::kAssert,
Op::kCountedFor,
Op::kCover,
Op::kDynamicCountedFor,
Op::kGate,
Op::kInputPort,
Op::kInstantiationInput,
Op::kInstantiationOutput,
Op::kInvoke,
Op::kMap,
Op::kNewChannel,
Op::kOutputPort,
Op::kParam,
Op::kStateRead,
Op::kNext,
Op::kReceive,
Op::kRecvChannelEnd,
Op::kRegisterRead,
Op::kRegisterWrite,
Op::kSend,
Op::kSendChannelEnd,
Op::kTrace,
Op::kTuple,
Op::kTupleIndex,
});

constexpr auto kMultiplicationOps = std::to_array<Op>({
Op::kSMul,
Op::kUMul,
Op::kSMulp,
Op::kUMulp,
Op::kSDiv,
Op::kUDiv,
Op::kSMod,
Op::kUMod,
});

// Returns whether the given op should be included in BDD computations.
bool ShouldEvaluate(const Node* node) {
if (!node->GetType()->IsBits()) {
return false;
}
// Ops which don't really have any reasonable BDD interpretation or which we
// otherwise wish to ignore (eg Gate, Map etc).
static constexpr auto kNonAnalyzableOps = std::to_array<Op>({
Op::kAfterAll,
Op::kMinDelay,
Op::kArray,
Op::kArrayConcat,
Op::kArrayIndex,
Op::kArraySlice,
Op::kArrayUpdate,
Op::kAssert,
Op::kCountedFor,
Op::kCover,
Op::kDynamicCountedFor,
Op::kGate,
Op::kInputPort,
Op::kInstantiationInput,
Op::kInstantiationOutput,
Op::kInvoke,
Op::kMap,
Op::kNewChannel,
Op::kOutputPort,
Op::kParam,
Op::kStateRead,
Op::kNext,
Op::kReceive,
Op::kRecvChannelEnd,
Op::kRegisterRead,
Op::kRegisterWrite,
Op::kSend,
Op::kSendChannelEnd,
Op::kTrace,
Op::kTuple,
Op::kTupleIndex,
});
constexpr static auto kMultiplicationOps = std::to_array<Op>({
Op::kSMul,
Op::kUMul,
Op::kSMulp,
Op::kUMulp,
Op::kSDiv,
Op::kUDiv,
Op::kSMod,
Op::kUMod,
});
if (node->BitCountOrDie() > kMaxBddBitWidth && node->OpIn(kComplexOps)) {
return false;
}
return !(node->OpIn(kNonAnalyzableOps) || node->OpIn(kMultiplicationOps));
}

Expand Down
Loading