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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-12-18
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is what I get on aarch64:
        ldr     x2, [x1]
        str     x2, [x0]
        str     xzr, [x1]
        ldr     x2, [x0]
        sub     x2, x2, #2
        cmp     x2, 1
        bls     .L6
        ret
        .p2align 2,,3
.L6:
        ldr     w1, [x1, 8]
        str     w1, [x0, 8]

Looks like GCC is losing restrict information somewhere.

What is more interesting is GCC does not combine:
  if (_5 <= 3)
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 3> [local count: 536870913]:
  MEM[(union any *)a_3(D)].st = _5;
  MEM[(union any &)b_2(D)].st = 0;
  goto <bb 5>; [100.00%]

  <bb 4> [local count: 536870913]:
  _6 = (void *) _5;
  MEM[(struct exception_ptr *)a_3(D)]._M_exception_object = _6;
  MEM[(struct exception_ptr &)b_2(D)]._M_exception_object = 0B;


At the tree level.
This might be the reason why restrict is being lost.  It is combined at the RTL
and that might be the reason why it is lost.  BUT GImple level PRE should have
figured out the stores don't change the value.  So even that does not use
restrict here.  I have not debugged why though.  I even try adding restrict in
places but it does not change the results.

Reply via email to