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.

DMD: https://goo.gl/wHTPzz
GDC & LDC: https://godbolt.org/g/QFSgaX

With this PR:


The code:

  int basicfunc(int i) {
    return i;

  int dataflow(int b) {
    int ret;

    if (b==4)
      ret = 3;
      ret = 5;

    if (ret == 4)
      return 0;
      return 1;

Produces on Win32:

  _D5test49basicfuncFiZi  comdat
                ret   // this is not a bug, as `i` is passed in EAX

  _D5test48dataflowFiZi   comdat
                mov     EAX,1

I'm sure you can find a case where LLVM does a better job. But I think I've made the point :-)

Reply via email to