[Bug target/56351] ARM Big-Endian: storing local double to packed variable causes corruption

2013-03-14 Thread ebotcazou at gcc dot gnu.org


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



--- Comment #4 from Eric Botcazou ebotcazou at gcc dot gnu.org 2013-03-14 
18:52:26 UTC ---

Author: ebotcazou

Date: Thu Mar 14 18:52:18 2013

New Revision: 196664



URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=196664

Log:

PR target/56351

Backport from mainline

2012-10-22  Julian Brown  jul...@codesourcery.com



* config/arm/arm.h (CANNOT_CHANGE_MODE_CLASS): Avoid subreg'ing

VFP D registers in big-endian mode.



Modified:

branches/gcc-4_7-branch/gcc/ChangeLog

branches/gcc-4_7-branch/gcc/config/arm/arm.h


[Bug target/56351] ARM Big-Endian: storing local double to packed variable causes corruption

2013-03-14 Thread ebotcazou at gcc dot gnu.org


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



Eric Botcazou ebotcazou at gcc dot gnu.org changed:



   What|Removed |Added



 Status|UNCONFIRMED |RESOLVED

 CC||ebotcazou at gcc dot

   ||gnu.org

 Resolution||FIXED

   Target Milestone|--- |4.7.3



--- Comment #5 from Eric Botcazou ebotcazou at gcc dot gnu.org 2013-03-14 
18:57:44 UTC ---

Thanks for reporting the problem.


[Bug target/56351] ARM Big-Endian: storing local double to packed variable causes corruption

2013-02-15 Thread sethml at google dot com


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



--- Comment #1 from Seth LaForge sethml at google dot com 2013-02-15 20:16:43 
UTC ---

Ugh, my attachment was a bit mangled.  Here's the source to stimulate the issue

- gcc_bug.c:



#include stdio.h



void PrintDouble(double v) __attribute__((noinline));

void PrintDouble(double v) {

  union { double d; int i[2]; } u = { v };

  printf(%f (0x%08X:%08X), v, u.i[0], u.i[1]);

}



struct { double val; } __attribute__((packed)) unaligned_double;



void PrintAndStoreUnaligned(double v) __attribute__((noinline));

void PrintAndStoreUnaligned(double v) {

  PrintDouble(v);

  unaligned_double.val = v;

}



int main() {

  double val = 1.234567;

  printf(val is: );

  PrintDouble(val);

  printf(\nCalling PrintAndStoreUnaligned: );

  PrintAndStoreUnaligned(val);

  printf(\nunaligned_double.val is: );

  PrintDouble(unaligned_double.val);

  printf(\n);

  return 0;

}


[Bug target/56351] ARM Big-Endian: storing local double to packed variable causes corruption

2013-02-15 Thread pinskia at gcc dot gnu.org


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



--- Comment #2 from Andrew Pinski pinskia at gcc dot gnu.org 2013-02-15 
20:20:28 UTC ---

I think this was fixed on the trunk with:

2012-10-22  Julian Brown  jul...@codesourcery.com



* config/arm/arm.h (CANNOT_CHANGE_MODE_CLASS): Avoid subreg'ing

VFP D registers in big-endian mode.


[Bug target/56351] ARM Big-Endian: storing local double to packed variable causes corruption

2013-02-15 Thread sethml at google dot com


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



Seth LaForge sethml at google dot com changed:



   What|Removed |Added



 CC||sethml at google dot com



--- Comment #3 from Seth LaForge sethml at google dot com 2013-02-15 22:43:56 
UTC ---

Thank you Andrew, super useful pointer!  Yes, that patch does appear to fix my

problem.  I've backported it to gcc 4.7 and posted a patch:

http://gcc.gnu.org/ml/gcc-patches/2013-02/msg00800.html



With gcc 4.7.2 with my/Julian's patch, I get correct code:



  43PrintAndStoreUnaligned:

  46 0020 B538push  {r3, r4, r5, lr}

  47 0022 EC523B10fmrrd r3, r2, d0

  48 0026 4614mov r4, r2

  49 0028 461Dmov r5, r3

  50 002a 4622mov r2, r4

  51 002c EC423B10fmdrr d0, r3, r2

  52 0030 F7FEbl  PrintDouble

  53 0034 F2400300movw  r3, #:lower16:unaligned_double

  54 0038 F2C00300movt  r3, #:upper16:unaligned_double

  55 003c 605Dstr r5, [r3, #4]

  56 003e 601Cstr r4, [r3, #0]  

  57 0040 BD38pop {r3, r4, r5, pc}