Skip to content

[InstCombine] !a == (a < 0) is not optimized #67916

@k-arrows

Description

@k-arrows

Consider the following functions:

int foo(int a)
{
   return !a == (a > 0);
}

int bar(int a)
{
   return (a < 0);
}

int baz(int a)
{
   return !a == (a < 0);
}

int qux(int a)
{
   return (a > 0);
}

Both Clang and GCC can optimize foo to bar. GCC can also optimize baz to qux, but Clang cannot.
https://godbolt.org/z/exvTE8Gn7
https://alive2.llvm.org/ce/z/LGvASc

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions