[Bug rtl-optimization/61772] New: RTL if-conversion removes asm volatile goto

matz at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jul 10 13:03:00 GMT 2014


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

            Bug ID: 61772
           Summary: RTL if-conversion removes asm volatile goto
           Product: gcc
           Version: 4.8.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matz at gcc dot gnu.org

This is reduced from a bug our kernel people hit.  The problem is
the use of asm volatile gotos inside a conditional, when the outgoing
blocks of the asm-goto are itself both empty.  Ala:

------------------------- snip ---------------------------------------
/* { dg-do compile } */
/* { dg-final { scan-assembler-times "XXX" 2 } } */

static inline __attribute__((always_inline)) int dec_and_test (int *i)
{
    asm volatile goto ("XXX %0, %l[cc_label]"
                       : : "m" (*i) : "memory" : cc_label);
    return 0;
cc_label:
    return 1;
}
extern int getit (int *);
int f (int *i, int cond)
{
  if (cond) {
      getit (0);
      if (dec_and_test (i))
        getit (i);
      return 42;
  }
  if (dec_and_test (i))
    (void)1;
  return getit (i);
}
------------------ snap ----------------------------------------------

This should have two "XXX" in the resulting assembler, but will have only
one with any optimization level.  It's the RTL if conversion that removes
the seemingly empty second dec_and_test(), because the then-block is
empty and because it doesn't check that the removed jump really is only
a jump without side effects.

I don't know if it's a regression (it probably isn't as I don't see that
ifcvt.c
was touched with the introduction of asm gotos), but it at least affects
trunk and 4.8.



More information about the Gcc-bugs mailing list