This patch adds a pattern for optimizing 
x < y || x == XXX_MIN to x <= y-1
if y is an integer with TYPE_OVERFLOW_WRAPS.

This fixes pr96674.

Tested on x86_64-pc-linux-gnu.

For this function

bool f(unsigned a, unsigned b)
{
    return (b == 0) | (a < b);
}

the code without the patch is

test   esi,esi
sete   al
cmp    esi,edi
seta   dl
or     eax,edx
ret    

the code with the patch is

sub    esi,0x1
cmp    esi,edi
setae  al
ret    

Eugene

gcc/
PR tree-optimization/96674
* match.pd: New pattern x < y || x == XXX_MIN --> x <= y - 1

gcc/testsuite
* gcc.dg/pr96674.c: New test.

Attachment: 0001-Optimize-combination-of-comparisons-to-dec-compare.patch
Description: 0001-Optimize-combination-of-comparisons-to-dec-compare.patch

Reply via email to