[Issue 18542] New: DMD could generate better assembly for common range check idioms
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 1 11:25:13 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18542
Issue ID: 18542
Summary: DMD could generate better assembly for common range
check idioms
Product: D
Version: D2
Hardware: x86_64
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: n8sh.secondary at hotmail.com
DMD could generate better assembly for common range check idioms. Take this
program:
---
bool isUpper(dchar c) @safe pure nothrow @nogc
{
// Identical code to current std.ascii : isUpper.
return c <= 'Z' && 'A' <= c;
}
void main(string[] args)
{
}
---
Compiled with dmd -O -release, the code for isUpper is:
push RBP
mov RBP,RSP
cmp EDI,05Ah
ja LE
cmp EDI,041h
jae L12
LE: xor EAX,EAX
jmp short L17
L12: mov EAX,1
L17: pop RBP
ret
Compiled with ldc2 -O1, the code for isUpper is:
addl $-65, %edi
cmpl $26, %edi
setb %al
retq
--
More information about the Digitalmars-d-bugs
mailing list