Aliasing

(xania.org)

47 points | by ibobev 6 days ago ago

8 comments

  • Ono-Sendai 37 minutes ago ago

    When you have done enough C++ you don't need to fire up compiler explorer, you just use local variables to avoid aliasing pessimisations.

    I also wrote about this a while ago: https://forwardscattering.org/post/51

  • turol 3 hours ago ago

    For a real world example of how this can affect code check out this commit I made in mesa: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20...

  • adev_ 3 hours ago ago

    Aliasing is no joke and currently the only reason why some arithmetic intensive code-bases still prefer Fortran even nowadays.

    While it is possible to remove most aliasing performance issues in a C or C++ codebase, it is a pain to do it properly.

    • bregma an hour ago ago

      Aliasing can be a problem in Fortran too.

      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/11). As you can imagine, hilarity ensued.

  • Bootvis 6 hours ago ago

    The whole series is excellent and as a non regular user of assembly I learned a ton.

  • artemonster 5 hours ago ago

    I wonder how much potential optimisation there is if we entirely drop pointer nonsense.

    • aw1621107 3 hours ago 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 everything - programming languages, their implementations, compilers, etc. (in which case I'm not sure that's even possible)?

      • artemonster 3 hours ago 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