Skip to content

Simplification for (~a & b) && ~a #69050

Closed
@k-arrows

Description

@k-arrows

GCC outputs the same sequence of instructions for the following two functions. Clang doesn't simplify the function foo. The transformation from foo to bar can be proved.

int foo(int a, int b)
{
   return (~a & b) && ~a;
}

int bar(int a, int b)
{
   return (~a & b) && b;
}

Godbolt: https://godbolt.org/z/1cfP7Y5x6
Alive2: https://alive2.llvm.org/ce/z/HDJVkD

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions