[Issue 14436] Optimizer fails to remove comparison loop when comparing array against null
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Apr 15 06:20:20 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14436
Marc Schütz <schuetzm at gmx.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
CC| |schuetzm at gmx.net
Resolution|FIXED |---
--- Comment #3 from Marc Schütz <schuetzm at gmx.net> ---
Comparing with an empty array or string literal still generates suboptimal
code:
bool isEmpty(string s) {
return s == "";
}
# dmd -c -O -inline -release xx.d
0000000000000000 <_D2xx7isEmptyFAyaZb>:
0: 55 push %rbp
1: 48 8b ec mov %rsp,%rbp
4: 48 83 ec 10 sub $0x10,%rsp
8: 48 89 7d f0 mov %rdi,-0x10(%rbp)
c: 48 89 75 f8 mov %rsi,-0x8(%rbp)
10: 48 3b 3d 00 00 00 00 cmp 0x0(%rip),%rdi # 17
<_D2xx7isEmptyFAyaZb+0x17>
17: 75 15 jne 2e <_D2xx7isEmptyFAyaZb+0x2e>
19: 48 8b 75 f8 mov -0x8(%rbp),%rsi
1d: 48 8b 3d 00 00 00 00 mov 0x0(%rip),%rdi # 24
<_D2xx7isEmptyFAyaZb+0x24>
24: 48 8b 4d f0 mov -0x10(%rbp),%rcx
28: 33 c0 xor %eax,%eax
2a: f3 a6 repz cmpsb %es:(%rdi),%ds:(%rsi)
2c: 74 04 je 32 <_D2xx7isEmptyFAyaZb+0x32>
2e: 31 c0 xor %eax,%eax
30: eb 05 jmp 37 <_D2xx7isEmptyFAyaZb+0x37>
32: b8 01 00 00 00 mov $0x1,%eax
37: 48 8b e5 mov %rbp,%rsp
3a: 5d pop %rbp
3b: c3 retq
Reopening, as it is a closely related enhancement (though strictly speaking not
identical).
--
More information about the Digitalmars-d-bugs
mailing list