Skip to content

[hls-fuzzer] Add non-functional fuzzer to bitwidth optimizations#808

Merged
zero9178 merged 3 commits intomainfrom
users/zero9179/bitwidth-non-opt-oracle
Mar 26, 2026
Merged

[hls-fuzzer] Add non-functional fuzzer to bitwidth optimizations#808
zero9178 merged 3 commits intomainfrom
users/zero9179/bitwidth-non-opt-oracle

Conversation

@zero9178
Copy link
Copy Markdown
Collaborator

With the recently landed bitwidth type system we have an initial generator that is capable of generating C programs known to compute under a given bitwidth. The initial PR used this for functional testing, where the programs generated are simply more likely to trigger mis-compilations in the optimization pass.

The new non-functional oracle introduced in this PR tests the optimization capabilities of the pass: It checks the output IR for any computations that are done at a higher bitwidth than expected. The logic for doing so is currently simple: All results of operations that aren't operands of an end should be done using a bitwidth that is at most equal to the bitwidth the generator used. The logic for this is via a separate oracle executable called hls-fuzzer-check-bitwidth. This enables a nice workflow where reproduction can be done through a simple bash execute.sh as is done for the functional testing.

The mode is currently selected using a --non-functional flag.

The PR contains following limitations to be fixed later or simple known issues:

As a drive-by fix, also disable right-shift generation for now (the logic was incorrect and was accidentally included).

@zero9178 zero9178 requested a review from Jiahui17 March 23, 2026 15:05
With the recently landed bitwidth type system we have an initial generator that is capable of generating C programs known to compute under a given bitwidth. The initial PR used this for functional testing, where the programs generated are simply more likely to trigger mis-compilations in the optimization pass.

The new non-functional oracle introduced in this PR tests the optimization capabilities of the pass: It checks the output IR for any computations that are done at a higher bitwidth than expected.
The logic for doing so is currently simple: All results of operations that aren't operands of an `end` should be done using a bitwidth that is at most equal to the bitwidth the generator used.
The logic for this is via a separate oracle executable called `hls-fuzzer-check-bitwidth`. This enables a nice workflow where reproduction can be done through a simple `bash execute.sh` as is done for the functional testing.

The mode is currently selected using a `--non-functional` flag.

The PR contains following limitations to be fixed later or simple known issues:
* It finds bugs very, very quickly due to: #798 which is blocked by #792 which is blocked by #802. I manually verified some bugs it found that the logic ought to work, but it is hard to say until we get more usage.

As a drive-by fix, also disable right-shift generation for now (the logic was incorrect and was accidentally included).
@zero9178 zero9178 force-pushed the users/zero9179/bitwidth-non-opt-oracle branch from d4b30b6 to 17a1088 Compare March 23, 2026 15:06
Comment thread tools/hls-fuzzer/targets/BitwidthOptimizationsTarget.cpp
Comment thread tools/hls-fuzzer/targets/BitwidthOptimizationsTarget.cpp Outdated
@zero9178 zero9178 requested a review from Jiahui17 March 25, 2026 09:13
@zero9178 zero9178 merged commit 7260473 into main Mar 26, 2026
10 of 11 checks passed
@zero9178 zero9178 deleted the users/zero9179/bitwidth-non-opt-oracle branch March 26, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants