This patch adds a pattern for folding 
                x < (short) ((unsigned short)x + const)
to
         x <= SHORT_MAX - const
(and similarly for other integral types) if const is not 0.
as described in PR97223.

For example, without this patch the x86_64-pc-linux code generated for this 
function

bool f(char x)
{
    return x < (char)(x + 12);
}

is

lea    eax,[rdi+0xc]
cmp    al,dil
setg   al
ret  

With the patch the code is 

cmp    dil,0x73
setle  al
ret    

Tested on x86_64-pc-linux.

Eugene

Attachment: 0001-Add-a-tree-optimization-described-in-PR97223.patch
Description: 0001-Add-a-tree-optimization-described-in-PR97223.patch

Reply via email to