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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This doesn't look to me like a mere omission to invalidate debug stmts after
some stmt move that (correctly) has not considered debug stmts when determining
if they should be moved or not, but it looks to me like wrong-code
transformation.
Before unswitch, if c is non-zero, we have endless loop, but during unswitching
it is wrongly changed to branch to the bb that returns instead.
Say if you compile with -O3 (no -g):
int a;
volatile int b;
short c, d;
int
fn1 ()
{
  int e;
  for (;;)
    {
      a = 3;
      if (c)
        continue;
      e = 0;
      for (; e > -30; e--)
        if (b)
          {
            int f = e;
            return d;
          }
    }
}

int
main ()
{
  c = 1;
  asm volatile ("" : : "m" (c) : "memory");
  fn1 ();
  __builtin_abort ();
}

then before the change this would just hang (expected), now it aborts instead.

Reply via email to