art.08.09@gmail.com changed bug 147
What Removed Added
CC   art.08.09@gmail.com

Comment # 2 on bug 147 from
I reported this because I was suspecting it was a symptom of some frontend+glue
problem, which was preventing the dead code from being removed. But I've now 
checked what GCC does for similar 'C' cases and apparently the problem exists
there too, it's just not as visible in 'C' because of the lack of default init.
So this might be an upstream issue and could be closed, if you think there
isn't anything that could be done about it in GDC.

Because of the default initialization in D and frequent use of structs for
creating new types, the impact of this missed optimization is much larger than
for C. For example, a bounds-checked int implementation becomes more expensive
because of this.

I tried a few other things, but was not able to find a workaround. Eg

-------------------------------------------------------
void main(string[] argv) {
   S a = void; 

   import gcc.builtins;
   __builtin_memset(&a, 0, S.sizeof);

   a.v = argv.length; /* Modifies the whole struct. */

   if (a.v==42)
      f();
}
-------------------------------------------------------

In this case the memset *is* completely eliminated. But now the unnecessary a.v
store isn't removed...


You are receiving this mail because: