Skip to content

missed optimization: ((a ^ b) & c) | a -> a | (b & c) #76554

@k-arrows

Description

@k-arrows

Consider the following.
https://godbolt.org/z/Tzzx1aveT

int foo(int a, int b, int c)
{
  return ((a ^ b) & c) | a;
}

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

Alive2 proof (I used i16 to prevent timeout.)
https://alive2.llvm.org/ce/z/CReg2u

Original test (gcc testsuite):
https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.dg/tree-ssa/pr109938.c

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions