Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: amaranth-lang/amaranth
base: 38b75ba4bce2
Choose a base ref
...
head repository: amaranth-lang/amaranth
compare: 8c6c3643cd1c
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Aug 26, 2020

  1. sim._pyrtl: optimize uses of reflexive operators.

    When a literal is used on the left-hand side of a numeric operator,
    Python is able to constant-fold some expressions:
    
        >>> dis.dis(lambda x: 0 + 0 + x)
          1           0 LOAD_CONST               1 (0)
                      2 LOAD_FAST                0 (x)
                      4 BINARY_ADD
                      6 RETURN_VALUE
    
    If a literal is used on the right-hand side such that the left-hand
    side is variable, this doesn't happen:
    
        >>> dis.dis(lambda x: x + 0 + 0)
          1           0 LOAD_FAST                0 (x)
                      2 LOAD_CONST               1 (0)
                      4 BINARY_ADD
                      6 LOAD_CONST               1 (0)
                      8 BINARY_ADD
                     10 RETURN_VALUE
    
    PyRTL generates fairly redundant code due to the pervasive masking,
    and because of that, transforming expressions into the former form,
    where possible, improves runtime by about 10% on Minerva SRAM SoC.
    whitequark committed Aug 26, 2020
    Copy the full SHA
    8c6c364 View commit details
    Browse the repository at this point in the history