https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122155

            Bug ID: 122155
           Summary: cond_if_else_store_replacement_1 does not need to
                    create an extra name if the rhs is equal
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: compile-time-hog, internal-improvement,
                    missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: pinskia at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
void f(int *a, int b, int c)
{
  if (c)
    *a = b;
  else
    *a = b;
}
```

Currently phiopt does:
```
factoring out stores:
        then:
# .MEM_7 = VDEF <.MEM_3(D)>
*a_4(D) = b_5(D);
        else:
# .MEM_6 = VDEF <.MEM_3(D)>
*a_4(D) = b_5(D);

to use phi:
cstore_8 = PHI <b_5(D)(3), b_5(D)(4)>

# .MEM_1 = VDEF <.MEM_9>
*a_4(D) = cstore_8;
```

But really since b_5(D) is used for both sides of the if, we could just
directly b_5(D) instead of creating a new ssa name.

Reply via email to