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: nob...@puremagic.com Reporter: n8sh.second...@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 --