Aliasing

(xania.org)

48 points by ibobev6 days ago

5 comments

  • Ono-Sendai48 minutes ago
    When you have done enough C++ you don&#x27;t need to fire up compiler explorer, you just use local variables to avoid aliasing pessimisations.<p>I also wrote about this a while ago: <a href="https:&#x2F;&#x2F;forwardscattering.org&#x2F;post&#x2F;51" rel="nofollow">https:&#x2F;&#x2F;forwardscattering.org&#x2F;post&#x2F;51</a>
  • turol3 hours ago
    For a real world example of how this can affect code check out this commit I made in mesa: <a href="https:&#x2F;&#x2F;gitlab.freedesktop.org&#x2F;mesa&#x2F;mesa&#x2F;-&#x2F;merge_requests&#x2F;20877&#x2F;diffs?commit_id=4b8dfaae89eedd54f7f9881adc8712d99ff30a60" rel="nofollow">https:&#x2F;&#x2F;gitlab.freedesktop.org&#x2F;mesa&#x2F;mesa&#x2F;-&#x2F;merge_requests&#x2F;20...</a>
  • adev_3 hours ago
    Aliasing is no joke and currently the only reason why some arithmetic intensive code-bases still prefer Fortran even nowadays.<p>While it is possible to remove most aliasing performance issues in a C or C++ codebase, it is <i>a pain</i> to do it properly.
    • bregma1 hour ago
      Aliasing can be a problem in Fortran too.<p>Decades ago I was a Fortran developer and encountered a very odd bug in which the wrong values were being calculated. After a lot of investigation I tracked it down to a subroutine call in which a hard-coded zero was being passed as an argument. It turned out that in the body of that subroutine the value 4 was being assigned to that parameter for some reason. The side effect was that the value of zero because 4 for the rest of the program execution because Fortran aliases all parameters since it passes by descriptor (or at least DEC FORTRAN IV did so on RSX&#x2F;11). As you can imagine, hilarity ensued.
  • Bootvis6 hours ago
    The whole series is excellent and as a non regular user of assembly I learned a ton.
  • artemonster5 hours ago
    I wonder how much potential optimisation there is if we entirely drop pointer nonsense.
    • newpavlov5 minutes ago
      For a system programming language the right solution is to properly track aliasing information in the type system as done in Rust.<p>Aliasing issues is just yet another instance of C&#x2F;C++ inferiority holding the industry back. C could&#x27;ve learnt from Fortran, but we ended up with the language we have...
    • aw16211072 hours ago
      Are you talking about dropping pointers as a programmer-facing programming language concept (in which case you might find Hylo and similar languages interesting), or dropping pointers from <i>everything</i> - programming languages, their implementations, compilers, etc. (in which case I&#x27;m not sure that&#x27;s even possible)?
      • artemonster2 hours ago
        Only the first one. Ofc under the hood they will stay, but I think its time to ditch random access model and pull fetching and concept of time closer to programmer