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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-07-20
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |wrong-code
          Component|c++                         |middle-end

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Xi Ruoyao from comment #1)
> Is this a bug?  The standard defines accessing volatile objects as
> side-effects so it's not allowed to merge volatile loads, AFAIU.

Yes because assume attribute is defined not to have any side effects.

Confirmed.

gimplifier produces:

  [[assume (D.2786)]]
    {
      {
        int n.0;

        n.0 = n;
        D.2786 = n.0 == 1;
      }
    }

And then lowering produces:
  _2 = n;
  .ASSUME (_Z3bari._assume.0, _2);

But really it should have passed the address of n rather than the value since n
is volatile here .

Reply via email to