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

            Bug ID: 127153
           Summary: LoongArch: wrong code at -O1 or above
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xry111 at gcc dot gnu.org
  Target Milestone: ---

$ cat test.cc
__attribute__ ((noipa)) static int
a ()
{
  return 0;
}

__attribute__ ((noipa)) static int
b ()
{
  return 1;
}

__attribute__ ((noipa)) static int
calc (int cond)
{
  int v = a ();
  if (cond)
    return b () && v;
  return v;
}

int
main ()
{
  int r = calc (1); // gv+1 is nonzero at runtime -> && path
  if (r)
    __builtin_trap ();
}
$ g++ -O1 test.cc
$ ./a.out
Illegal instruction        (core dumped) ./a.out

Reply via email to