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

            Bug ID: 128933
           Summary: ADD_OVERFLOW detection keeps around a convert that is
                    not needed
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: compile-time-hog, missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
unsigned int g(unsigned int a, unsigned int b, unsigned int *h)
{
  unsigned long t = a;
  t += b;
  *h = t >> 32;
  return a+b;
}
```

widdening_multiply pass (which is where the add_overflow detection is),
produces:
```
unsigned int g (unsigned int a, unsigned int b, unsigned int * h)
{
  long unsigned int t;
  long unsigned int _1;
  long unsigned int _2;
  unsigned int _3;
  unsigned int _11;
  __complex__ unsigned int _12;
  unsigned int _13;
  unsigned int _14;
  bool _15;

  <bb 2> [local count: 1073741824]:
  t_5 = (long unsigned int) a_4(D);
  _1 = (long unsigned int) b_6(D);
  _12 = .ADD_OVERFLOW (a_4(D), b_6(D));
  _13 = REALPART_EXPR <_12>;
  _14 = IMAGPART_EXPR <_12>;
  _3 = (unsigned int) _14;
  *h_9(D) = _3;
  _11 = _13;
  return _11;

}
```

Notice the assignment to _3 is from a convert of `unsigned int` to an `unsigned
int`.  

sccopy does not treat that as a copy even though it is exactly a copy as the
convert is a `useless_type_conversion`.

Reply via email to