http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56124



             Bug #: 56124

           Summary: Redundant reload for loading from memory

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: rtl-optimization

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: amker.ch...@gmail.com





For below test case:



typedef __builtin_va_list __gnuc_va_list;

typedef __gnuc_va_list va_list;



struct _reent

{

    int _stdout;

};

struct _reent *_impure_ptr;

int bar (struct _reent *, int, const char *, va_list);

int

foo(const char *fmt , ...)

{

  int ret;

  va_list ap;

  struct _reent *ptr = _impure_ptr;



  __builtin_va_start(ap,fmt);

  ret = bar (ptr, ((ptr)->_stdout), fmt, ap);

  __builtin_va_end(ap);

  return ret;

}



The dump of reload pass is:

    1: NOTE_INSN_DELETED

    4: NOTE_INSN_BASIC_BLOCK 2

   28: r3:SI=sp:SI+0x10

      REG_EQUAL sp:SI+0x10

    2: r2:SI=[r3:SI++]

      REG_INC r3:SI

      REG_EQUIV [afp:SI]

   31: [sp:SI+0x10]=r2:SI

    3: NOTE_INSN_FUNCTION_BEG

    6: r2:SI=[`*.LC0']

      REG_EQUIV `_impure_ptr'

    7: r0:SI=[r2:SI]

    9: [sp:SI+0x4]=r3:SI

   10: r1:SI=[r0:SI]

   14: r2:SI=[sp:SI+0x10]

   16: r0:SI=call [`bar'] argc:0

   25: use r0:SI

   29: NOTE_INSN_DELETED



which could be:



    1: NOTE_INSN_DELETED

    4: NOTE_INSN_BASIC_BLOCK 2

   28: r3:SI=sp:SI+0x10

      REG_EQUAL sp:SI+0x10

    2: r2:SI=[r3:SI++]

      REG_INC r3:SI

      REG_EQUIV [afp:SI]

    3: NOTE_INSN_FUNCTION_BEG

    6: r1:SI=[`*.LC0']

      REG_EQUIV `_impure_ptr'

    7: r0:SI=[r1:SI]

    9: [sp:SI+0x4]=r3:SI

   10: r1:SI=[r0:SI]

   16: r0:SI=call [`bar'] argc:0

   25: use r0:SI

   29: NOTE_INSN_DELETED



It is obvious that insn 31/14 are generated/kept by redundant reload.



The command line is:

arm-none-eabi-gcc -mthumb -mcpu=cortex-m0 -Os ...

Reply via email to