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

            Bug ID: 127847
           Summary: Hoist can move expr reading asm goto outputs before
                    asm goto
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vineetg at gcc dot gnu.org
  Target Milestone: ---

Hoist can move an expression which depends on output of asm goto to before the
asm.


__attribute__((noipa, cold)) int
f1 (int a)
{
  int x;
  asm goto ("" : "=r" (x) : "0" (a) : : lab);
  return (x + 100) ^ 1;
 lab:
  return (x + 100) ^ 2;
}

// triggers at -Os; cold causes it to happen at -O2 and -O3 too.

// f1 (5) must be 104, but generates 101

f1:
    movl $101, %eax 
    ret  
.L4:
    movl $102, %eax 
    ret  

Verified the problem exists on both x86 and aarch64.

Reply via email to