[Issue 6767] Range case statements generate horrific code

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Aug 23 22:01:45 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=6767

hsteoh at quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |hsteoh at quickfur.ath.cx
         Resolution|---                         |WORKSFORME

--- Comment #1 from hsteoh at quickfur.ath.cx ---
This seems to have been fixed in git HEAD. Tested on Linux/64-bit, compile with
dmd -O. The function compiles to:

------
0000000000000000 <_D4test3fooFiZi>:
   0:   55                      push   %rbp
   1:   48 8b ec                mov    %rsp,%rbp
   4:   48 83 ec 10             sub    $0x10,%rsp
   8:   48 81 ff ff 00 00 00    cmp    $0xff,%rdi
   f:   77 0e                   ja     1f <_D4test3fooFiZi+0x1f>
  11:   ff 24 fd 00 00 00 00    jmpq   *0x0(,%rdi,8)
  18:   31 c0                   xor    %eax,%eax
  1a:   48 8b e5                mov    %rbp,%rsp
  1d:   5d                      pop    %rbp
  1e:   c3                      retq   
  1f:   b8 01 00 00 00          mov    $0x1,%eax
  24:   48 8b e5                mov    %rbp,%rsp
  27:   5d                      pop    %rbp
  28:   c3                      retq   
  29:   0f 1f 80 00 00 00 00    nopl   0x0(%rax)
------

Which is probably close to optimal. At least, it no longer produces the O(n)
nastiness. :-)

--


More information about the Digitalmars-d-bugs mailing list