Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Have you tried using the restrict keyword everywhere you can in c?

In Fortran, arrays are not allowed to overlap which allows some optimisations. c has rules in the spec about how memory accesses must occur, and overlapping arrays being possible prevents some compiler optimisations. The restrict keyword is you promising that the memory at some pointer won't be accessed through another pointer.

You can compare two implementations in Fortran/c using godbolt to see how each of them compile.



Dummy arguments may not alias anything else, including other dummy arguments, in conforming Fortran if either are modified, with some exceptions. But there are many ways in which arrays can overlap that don’t involve dummy arguments. GNU Fortran optimizes ASSOCIATE names as if they were free of aliasing, too, but that is a bug.


i apologize i missed this. the core hot loop was fairly straightforward to optimize and audit all aliasing. we ported from c89 to all cutting edge (at time) c99+ compilers. we still couldnt quite eek out that minor difference. the intel compiler unsurprisingly generated the most close asm for the machine

the fortran library we only had one license on a physical machine, i had to travel for one extensive recompilation of that side lol! it wasnt the library mentioned below, i would have to ask a collegue.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: