Skip to content

(a >= b-1) & (a < b) is not simplified for the case b=0 #63751

Closed
@k-arrows

Description

@k-arrows

This issue is similar to #62586.
https://godbolt.org/z/b5jYsnseT

int foo(int a)
{
    return (a >= -1) & (a < 0);
}

int bar(int a)
{
    return (a == -1);
}
foo(int):                                # @foo(int)
        xor     eax, eax
        cmp     edi, -1
        setge   al
        shr     edi, 31
        and     eax, edi
        ret
bar(int):                                # @bar(int)
        xor     eax, eax
        cmp     edi, -1
        sete    al
        ret

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions