Skip to content

Simplification Comparison for (a | b) ? (a ^ b) : (a & b) etc. (Clang13 vs Clang trunk) #71792

@k-arrows

Description

@k-arrows

Consider the following six functions.
https://godbolt.org/z/cTsd43jhh

bool test1(bool a, bool b)
{
    return (a | b) ? (a ^ b) : (a & b);
}

bool test2(bool a, bool b)
{
    return (a | b) ? (a & b) : (a ^ b);
}

bool test3(bool a, bool b)
{
    return (a & b) ? (a | b) : (a ^ b);
}

bool test4(bool a, bool b)
{
    return (a & b) ? (a ^ b) : (a | b);
}

bool test5(bool a, bool b)
{
    return (a ^ b) ? (a | b) : (a & b);
}

bool test6(bool a, bool b)
{
    return (a ^ b) ? (a & b) : (a | b);
}

Clang13 can simplify four of these, test1, test2, test3 and test4, while Clang trunk cannot. Neither Clang13 nor Clang trunk can simplify test5 and test6.

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