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

            Bug ID: 83175
           Summary: compiler optimizing the code corresponding to double
                    precision operations
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sbansal at ciena dot com
  Target Milestone: ---

I am migrating my tool chain from 3.4.5 to 4.8.1. 

Migration to 4.8.1 is working great till now but the only problem I am recently
encountering is about code getting optimized when some "double" operations are
done.

Source code :
=========================
553               unlockAddr1_f64 = (double*) thisVars(vol)->unlockAddr1;
554               unlockAddr2_f64 = (double*) thisVars(vol)->unlockAddr2;
555               cmd.word32[0] = ((command<<16) | command);
556               cmd.word32[1] = cmd.word32[0];
557               unlockAddr1_f64[0] = unlock1_cmd.fword64;
558               unlockAddr2_f64[0] = unlock2_cmd.fword64;
559               unlockAddr1_f64[0] = cmd.fword64;

Corresponding assembly with 3.4.5 (working good)
====================================================
/vobs/equinox_ne_bsp/kernel/sources/drivers/ffs/amd16x4mtdome.c:553
  13adb0:       81 23 00 18     lwz     r9,24(r3)
  13adb4:       81 69 00 00     lwz     r11,0(r9)
/vobs/equinox_ne_bsp/kernel/sources/drivers/ffs/amd16x4mtdome.c:554
  13adb8:       81 49 00 04     lwz     r10,4(r9)
/vobs/equinox_ne_bsp/kernel/sources/drivers/ffs/amd16x4mtdome.c:555
  13adbc:       54 a0 80 1e     rlwinm  r0,r5,16,0,15
  13adc0:       7c 00 2b 78     or      r0,r0,r5
  13adc4:       7c 07 03 78     mr      r7,r0
/vobs/equinox_ne_bsp/kernel/sources/drivers/ffs/amd16x4mtdome.c:556
  13adc8:       7c 08 03 78     mr      r8,r0
/vobs/equinox_ne_bsp/kernel/sources/drivers/ffs/amd16x4mtdome.c:557
  13adcc:       3d 20 00 67     lis     r9,103
  13add0:       c8 09 7d 08     lfd     f0,32008(r9)
  13add4:       d8 0b 00 00     stfd    f0,0(r11)
/vobs/equinox_ne_bsp/kernel/sources/drivers/ffs/amd16x4mtdome.c:558
  13add8:       3d 20 00 67     lis     r9,103
  13addc:       c8 09 7d 10     lfd     f0,32016(r9)
  13ade0:       d8 0a 00 00     stfd    f0,0(r10)
/vobs/equinox_ne_bsp/kernel/sources/drivers/ffs/amd16x4mtdome.c:559
  13ade4:       90 e1 00 08     stw     r7,8(r1)
  13ade8:       91 01 00 0c     stw     r8,12(r1)
  13adec:       c9 a1 00 08     lfd     f13,8(r1)
  13adf0:       d9 ab 00 00     stfd    f13,0(r11)


Corresponding assembly with 4.8.1 (not working well) :
================================================================
/vobs/equinox_ne_bsp/kernel/sources/drivers/ffs/amd16x4mtdome.c:554
  138e04:       81 0a 00 04     lwz     r8,4(r10)
/vobs/equinox_ne_bsp/kernel/sources/drivers/ffs/amd16x4mtdome.c:555
  138e08:       54 aa 80 1e     rlwinm  r10,r5,16,0,15
  138e0c:       7d 45 2b 78     or      r5,r10,r5
/vobs/equinox_ne_bsp/kernel/sources/drivers/ffs/amd16x4mtdome.c:557
  138e10:       3c e0 00 66     lis     r7,102
/vobs/equinox_ne_bsp/kernel/sources/drivers/ffs/amd16x4mtdome.c:558
  138e14:       c8 07 01 c8     lfd     f0,456(r7)
  138e18:       d8 08 00 00     stfd    f0,0(r8)
/vobs/equinox_ne_bsp/kernel/sources/drivers/ffs/amd16x4mtdome.c:559
  138e1c:       90 a9 00 00     stw     r5,0(r9)
  138e20:       90 a9 00 04     stw     r5,4(r9)


The problem I see is that, no assembly instructions (lfd, stfd) are generated
corresponding to line 557 & 559. It seems compiler is doing some optimization.

Surprisingly, If I add some printf or debug code after line 558, these
instructions are getting generated and code works well.

I know 4.8.1 is no longer supported by GCC, but I would appreciate if you could
give some directions which I can look. Probably some flags etc which I can set.

let me know if you need more information.

Thanks.
Sumit

Reply via email to