4 ms·
AFAIK GCC doesn't add "restrict" to pointers by itself. Fortran semantics mean that pointers are "restrict" by default.
by wolf550e 15y ago
AFAIK GCC doesn't add "restrict" to pointers by itself. Fortran semantics mean that pointers are "restrict" by default.
- gcp 15y agoHow does this matter when the compiler can see all the source code? It can see what the pointers are pointing to and determine if there is aliasing. Feel free to point out the source code in the shootout where this would somehow not be the case. Shouldn't be hard to find if you focus on the benchmarks where Fortran beats C heavily. Additionally, the argument about restrict is flawed because it can be added to the C code too, so it can't be an advantage of Fortran.
- xyzzyz 15y agoIt is impossible write a compiler that reads a C source code and for every point in program decides if two names visible from that point cannot alias each other. You cannot do that even under assumption that every code path may be visited.
- gcp 15y agoI agree it is impossible in the general case (it's obviously impossible when input data controls program flow, for example). But I don't think that has much meaning for the benchmarks under consideration, which, by the way, one would expect to sidestep the obvious pitfalls here. The impossibility of solving aliasing in the general case doesn't stop C compiler writers from implementing alias analysis.
- shasta 15y agoI assume xyzzyz was referring to the undecidability of the halting problem, not just user input. Comparisons to the halting problem are often made inappropriately, as would be the case here, since the compiler doesn't need to answer whether an arbitrary program contains aliasing, but only identify programs that admit arguments (often simple ones) demonstrating that they don't alias. It's still undecidable, though.
- figglesonrails 15y agovoid* p1; void* p2; p2 = function(p1); Do p1 and p2 alias? Note: function() is in a *.so file, no source available. How many times do you have all of the source code available for analysis?
- gcp 15y agoI pointed out specifically that all source code is available exactly for this reason. The original claim was that "for Fortran this is expected" which isn't true at all in this condition. So aliasing information can't explain the performance difference.