This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug regression/67288] [4.9 regression] non optimal simple function (useless additional shift/remove/shift/add)


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

--- Comment #2 from Christophe Leroy <christophe.leroy@c-s.fr> ---
Compilation ok with below code

[root@localhost knl]# cat flush.c

#define L1_CACHE_SHIFT  4
#define L1_CACHE_BYTES  (1 << L1_CACHE_SHIFT)

#define mb()   __asm__ __volatile__ ("sync" : : : "memory")

static inline void dcbf(void *addr)
{
        __asm__ __volatile__ ("dcbf 0, %0" : : "r"(addr) : "memory");
}

void flush_dcache_range(unsigned long start, unsigned long stop)
{
        void *addr = (void *)(start & ~(L1_CACHE_BYTES - 1));
        unsigned int size = stop - (unsigned long)addr + (L1_CACHE_BYTES - 1);
        unsigned int i;

        for (i = 0; i < size >> L1_CACHE_SHIFT; i++, addr += L1_CACHE_BYTES)
                dcbf(addr);
        if (i)
                mb();   /* sync */
}

[root@localhost knl]# ppc-linux-gcc -c -O2 flush.c

[root@localhost knl]# ppc-linux-objdump -d flush.o 
flush.o:     file format elf32-powerpc


Disassembly of section .text:

00000000 <flush_dcache_range>:
   0:   54 63 00 36     rlwinm  r3,r3,0,0,27
   4:   38 84 00 0f     addi    r4,r4,15
   8:   7c 83 20 50     subf    r4,r3,r4
   c:   54 89 e1 3f     rlwinm. r9,r4,28,4,31
  10:   4d 82 00 20     beqlr   
  14:   55 24 20 36     rlwinm  r4,r9,4,0,27
  18:   39 24 ff f0     addi    r9,r4,-16
  1c:   55 29 e1 3e     rlwinm  r9,r9,28,4,31
  20:   39 29 00 01     addi    r9,r9,1
  24:   7d 29 03 a6     mtctr   r9
  28:   7c 00 18 ac     dcbf    0,r3
  2c:   38 63 00 10     addi    r3,r3,16
  30:   42 00 ff f8     bdnz    28 <flush_dcache_range+0x28>
  34:   7c 00 04 ac     sync    
  38:   4e 80 00 20     blr


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]