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

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually looks like there is an infinite loop:
Simplified
  RoundingAlignment = MEM[(const struct CharUnits &)this_22(D) + 32];
after previous
  this_22(D)->Alignment = MEM[(const struct CharUnits &)this_22(D) + 32];
into
  RoundingAlignment = MEM[(const struct CharUnits &)this_22(D) + 32];

Simplified
  RoundingAlignment = MEM[(const struct CharUnits &)this_22(D) + 32];
after previous
  this_22(D)->Alignment = MEM[(const struct CharUnits &)this_22(D) + 32];
into
  RoundingAlignment = MEM[(const struct CharUnits &)this_22(D) + 32];

The problem is now:
  /* If the new store is `src2 = src2;` skip over it. */
  if (operand_equal_p (src2, dest2, 0))
    return false;
And
  /* If the statement is `src = src;` then ignore it. */
  if (operand_equal_p (dest, src, 0))
    return false;


Is not decent enough to detect that.

It comes from originally:
```
  _3 = &this_38(D)->RequiredAlignment;
  _4 = &this_38(D)->Alignment;
  _47 = MEM[(const struct CharUnits *)this_38(D) + 32B].Quantity;
  _45 = MEM[(const struct CharUnits &)this_38(D) + 48].Quantity;
  if (_45 > _47)
    goto <bb 4>; [34.00%]
  else
    goto <bb 5>; [66.00%]

  <bb 4> :

  <bb 5> :
  # _42 = PHI <_4(3), _3(4)>
  this_38(D)->Alignment = *_42;
  RoundingAlignment = *_42;
```
phiprop1 then does:
```
  <bb 3> :
  _3 = &this_38(D)->RequiredAlignment;
  _4 = &this_38(D)->Alignment;
  _47 = MEM[(const struct CharUnits *)this_38(D) + 32B].Quantity;
  _45 = MEM[(const struct CharUnits &)this_38(D) + 48].Quantity;
  if (_45 > _47)
    goto <bb 4>; [34.00%]
  else
    goto <bb 24>; [66.00%]

  <bb 24> :
  this_38(D)->Alignment = MEM[(const struct CharUnits &)_4];
  goto <bb 5>; [100.00%]

  <bb 4> :
  this_38(D)->Alignment = MEM[(const struct CharUnits &)_3];

  <bb 5> :
  # _42 = PHI <_4(24), _3(4)>
  RoundingAlignment = *_42;

```

And then phiprop2 does:
```
  <bb 3> [local count: 536870912]:
  _1 = &this_22(D)->RequiredAlignment;
  _2 = &this_22(D)->Alignment;
  _29 = MEM[(const struct CharUnits *)this_22(D) + 32B].Quantity;
  if (_29 < _41)
    goto <bb 5>; [34.00%]
  else
    goto <bb 4>; [66.00%]

  <bb 4> [local count: 354334800]:
  this_22(D)->Alignment = MEM[(const struct CharUnits &)_2]; // NOP LOAD/Store
  RoundingAlignment = MEM[(const struct CharUnits &)_2];
  goto <bb 6>; [100.00%]

  <bb 5> [local count: 182536112]:
  this_22(D)->Alignment = MEM[(const struct CharUnits &)_1];
  RoundingAlignment = MEM[(const struct CharUnits &)_1];
```

And then we go into an infinite loop.

Reply via email to