Repository navigation
perf(sv): evaluate stateless constant functions once #2235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3288,6 +3288,17 @@ impl<'p, 'a> Comb<'p, 'a> { | |
| args: &[Option<sv::ir::Expr>], | ||
| arg_order: &[usize], | ||
| ) -> Result<Option<Value>, sv::AnalyzerError> { | ||
| if args.is_empty() | ||
| && let Some(literal) = self.m.constant_functions.value(name) | ||
|
Comment on lines
+3291
to
+3292
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In either state mode, the newly reused interpreter compares each case label independently instead of using the common width and signedness of the selector and all labels. For example, an automatic function containing Useful? React with 👍 / 👎. |
||
| { | ||
| let node = self.alloc(SLTNode::Constant( | ||
| literal.value, | ||
| literal.mask, | ||
| literal.width, | ||
| literal.signed, | ||
| ))?; | ||
| return Ok(Some((node, Sources::default()))); | ||
| } | ||
| let subroutine = self | ||
| .m | ||
| .subroutine(name) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In four-state mode, a zero-argument function containing an ordinary
casecan now be replaced with the wrong constant. For example,function automatic int f(); logic x; case (x) 1'bx: return 1; default: return 0; endcase endfunctionshould return 1, but the reused interpreter compares case labels withBinaryOp::EqinFrame::stmt, then treats the unknown comparison as false, producing 0. Ordinary runtime lowering correctly usesBinaryOp::EqCaseforCaseKind::ExactinComb::case. Use the same case-equality semantics in the interpreter, or decline this optimization for unknown-sensitive case comparisons.Useful? React with 👍 / 👎.