Skip to content

missed optimization: Optimization based on the first of the two conditions #76043

@k-arrows

Description

@k-arrows

Test case from gcc testsuite:
https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-11.c

int f(int a, int b, int c)
{
  if (a == 0 && b > c)
   return 0;
 return a;
}

int g(int a, int b, int c)
{
  if (a == 42 && b > c)
   return 42;
 return a;
}

int h(int a, int b, int c, int d)
{
  if (a == d && b > c)
   return d;
 return a;
}

https://godbolt.org/z/hd8Pb116n

Any of these functions can be optimized to a function which returns a. I feel like there may be a duplicate of this issue.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions