[Issue 11508] [REG 2.064] Wrong code with -O on x86_64 for char comparisons
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 15 19:20:36 PST 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11508
tchajed+d at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tchajed+d at gmail.com
--- Comment #1 from tchajed+d at gmail.com 2013-11-15 19:20:32 PST ---
I wasn't able to isolate the issue in the compiler, but it looks like starting
at
https://github.com/D-Programming-Language/dmd/commit/fd999804a0d79fcbbfac39191d4e8f4ba7872467
an optimization was added for sequences of OR operations that is doing
something strange to this code. Just prior to this commit the isWordChar
function looked like this (in earlier versions there was no optimization and
the code just did a straightforward sequence of cmp and je):
0000000000000050 <_D4dbug10isWordCharFaZb>:
50: 55 push %rbp
51: 48 8b ec mov %rsp,%rbp
54: 48 83 ec 10 sub $0x10,%rsp
58: 89 7d f8 mov %edi,-0x8(%rbp)
5b: 0f b6 45 f8 movzbl -0x8(%rbp),%eax
5f: 83 c0 d5 add $0xffffffd5,%eax
62: 83 f8 34 cmp $0x34,%eax
65: 77 0a ja 71 <_D4dbug10isWordCharFaZb+0x21>
67: b9 0d 00 00 00 mov $0xd,%ecx
6c: 0f a3 c1 bt %eax,%ecx
6f: 72 04 jb 75 <_D4dbug10isWordCharFaZb+0x25>
71: 31 c0 xor %eax,%eax
73: eb 05 jmp 7a <_D4dbug10isWordCharFaZb+0x2a>
75: b8 01 00 00 00 mov $0x1,%eax
7a: 48 8b e5 mov %rbp,%rsp
7d: 5d pop %rbp
7e: c3 retq
While afterward it looks like (but only on X86_64):
70: 55 push %rbp
71: 48 8b ec mov %rsp,%rbp
74: 48 83 ec 10 sub $0x10,%rsp
78: 89 7d f8 mov %edi,-0x8(%rbp)
7b: 0f b6 45 f8 movzbl -0x8(%rbp),%eax
7f: 83 c0 d5 add $0xffffffd5,%eax
82: 83 f8 34 cmp $0x34,%eax
85: 77 0f ja 96 <_D4dbug10isWordCharFaZb+0x26>
87: 48 b9 0d 00 00 00 00 movabs $0x1000000000000d,%rcx
8e: 00 10 00
91: 0f a3 c1 bt %eax,%ecx
94: 72 04 jb 9a <_D4dbug10isWordCharFaZb+0x2a>
96: 31 c0 xor %eax,%eax
98: eb 05 jmp 9f <_D4dbug10isWordCharFaZb+0x2f>
9a: b8 01 00 00 00 mov $0x1,%eax
9f: 48 8b e5 mov %rbp,%rsp
a2: 5d pop %rbp
a3: c3 retq
I don't understand the codebase well enough to see how to fix the issue, but
hope this helps!
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list