Skip to content
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

Assignments with if statements are not optimized #1475

Open
m-torhan opened this issue Jun 12, 2024 · 0 comments
Open

Assignments with if statements are not optimized #1475

m-torhan opened this issue Jun 12, 2024 · 0 comments
Labels
optimizer Related to IR optimization or analysis

Comments

@m-torhan
Copy link

Describe the bug
During working on another issue (#1461), we noticed that if statements used to assign values based on some condition are not optimized.

To Reproduce

  1. Cherry pick the commit antmicro@3507f0a (with slow_if and fast_if samples).
  2. Run IR benchmark for both implementations.
  3. Observe critical paths:
  • slow_if
Critical path delay: 221ps
Critical path entry count: 2
Critical path:
      0ps as synthesized (+0ps); 0.00%
    221ps (+221ps): sel.10: bits[1024] = sel(cond, cases=[arg2, arg1], id=10, pos=[(0,2,4)])
      0ps (+  0ps): arg1: bits[1024] = param(arg1, id=2)
  • fast_if
Critical path delay: 63ps
Critical path entry count: 4
Critical path:
      0ps as synthesized (+0ps); 0.00%
     63ps (+ 19ps): or.27: bits[1024] = or(and.25: bits[1024], nor.26: bits[1024], id=27, pos=[(0,8,18)])
     44ps (+ 27ps): nor.26: bits[1024] = nor(not.24: bits[1024], mask: bits[1024], id=26, pos=[(0,8,26)])
     17ps (+ 17ps): mask: bits[1024] = sign_ext(cond: bits[1], new_bit_count=1024, id=23, pos=[(0,7,15)])
      0ps (+  0ps): cond: bits[1] = param(cond, id=1)

Expected behavior
The slow_if, which uses if statement, should be converted to the equivalent of the fast_if.

Environment (this can be helpful for troubleshooting):

@proppy proppy added the optimizer Related to IR optimization or analysis label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimizer Related to IR optimization or analysis
Projects
None yet
Development

No branches or pull requests

2 participants