On 7/4/2017 4:09 PM, Johan Engelen wrote:
On Tuesday, 4 July 2017 at 21:10:45 UTC, Walter Bright wrote:
The backend has also been accused of not doing data flow analysis. It does as
good a flow analysis as any compiler.
Please...
DMD: https://goo.gl/wHTPzz
GDC & LDC: https://godbolt.org/g/QFSgaX
With this PR:
https://github.com/dlang/dmd/pull/6968
The code:
int basicfunc(int i) {
return i;
}
int dataflow(int b) {
int ret;
if (b==4)
ret = 3;
else
ret = 5;
if (ret == 4)
return 0;
else
return 1;
}
Produces on Win32:
_D5test49basicfuncFiZi comdat
ret // this is not a bug, as `i` is passed in EAX
_D5test48dataflowFiZi comdat
mov EAX,1
ret
I'm sure you can find a case where LLVM does a better job. But I think I've made
the point :-)