[Bug lto/55113] ICE with LTO and -fshort-double

2014-03-04 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

pmatos at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #18 from pmatos at gcc dot gnu.org ---
Fixed in r208312.


[Bug lto/55113] ICE with LTO and -fshort-double

2014-03-02 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

--- Comment #17 from pmatos at gcc dot gnu.org ---
Patch submitted to gcc-patches.


[Bug lto/55113] ICE with LTO and -fshort-double

2014-02-28 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

--- Comment #16 from pmatos at gcc dot gnu.org ---
(In reply to Richard Biener from comment #14)
 
 Well.  At least to my theory (didn't try).
 

Theory and practice match. It seems to fix the bug and work fine. I will do
some further testing and post a patch. 

Thanks.


[Bug lto/55113] ICE with LTO and -fshort-double

2014-02-27 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

--- Comment #14 from Richard Biener rguenth at gcc dot gnu.org ---
(In reply to pmatos from comment #13)
 (In reply to Richard Biener from comment #11)
  If double_type_node is FE dependent then it needs treatment in
  tree-streamer.c:preload_common_nodes:
  
  static void
  preload_common_nodes (struct streamer_tree_cache_d *cache)
  {
unsigned i;
  
for (i = 0; i  itk_none; i++)
  /* Skip itk_char.  char_type_node is dependent on -f[un]signed-char.  */
  if (i != itk_char)
record_common_node (cache, integer_types[i]);
  
for (i = 0; i  stk_type_kind_last; i++)
  record_common_node (cache, sizetype_tab[i]);
  
for (i = 0; i  TI_MAX; i++)
  /* Skip boolean type and constants, they are frontend dependent.  */
  if (i != TI_BOOLEAN_TYPE
   i != TI_BOOLEAN_FALSE
   i != TI_BOOLEAN_TRUE)
record_common_node (cache, global_trees[i]);
  }
 
 Richard,
 I tried what you suggested but led me nowhere. In the meantime I noticed
 that -fshort-double shows up in COLLECT_GCC_OPTIONS before collect2 is
 called:
 
 COLLECT_GCC_OPTIONS='-fshort-double' '-flto' '-nostdlib' '-o' 'test'
 '-save-temps' '-v' '-da' '-fdump-tree-all-all' '-mcpu=8540'
  /home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-
 eabispe/4.8.3/collect2 -plugin
 /home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-
 eabispe/4.8.3/liblto_plugin.so
 -plugin-opt=/home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/
 powerpc-eabispe/4.8.3/lto-wrapper -plugin-opt=-fresolution=pr55113.res -flto
 --sysroot=/home/pmatos/work/pr55113/top-4_8/toolchain/prex_sysroot
 --eh-frame-hdr -V -dn -Bstatic -o test
 -L/home/pmatos/work/pr55113/top-4_8/toolchain/install/lib/gcc/powerpc-
 eabispe/4.8.3
 -L/home/pmatos/work/pr55113/top-4_8/toolchain/install/lib/gcc/powerpc-
 eabispe/4.8.3/../../../../powerpc-eabispe/lib pr55113.o
 
 but not after when lto1 is called:
 COLLECT_GCC_OPTIONS='-c' '-mcpu=8540' '-nostdlib' '-save-temps' '-v' '-da'
 '-fdump-tree-all-all' '-mcpu=8540' '-dumpdir' './' '-dumpbase' 'test.wpa'
 '-fltrans-output-list=test.ltrans.out' '-fwpa' '-fresolution=pr55113.res'
  /home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-
 eabispe/4.8.3/lto1 -quiet -da -dumpdir ./ -dumpbase test.wpa -mcpu=8540
 -mcpu=8540 -auxbase pr55113 -version -fdump-tree-all-all
 -fltrans-output-list=test.ltrans.out -fwpa -fresolution=pr55113.res
 @/tmp/ccW7YQPl
 
 Somewhere along the line the option is lost. It seems to be that only some
 options are kept and optimization options are lost, like fshort-double.

-fshort-double is a C frontend family option and thus not generally available
(you can add LTO to the list of FEs that support it).

 However, in lto/lto-lang.c:lto_init you have:
   /* Create the basic integer types.  */
   build_common_tree_nodes (flag_signed_char, /*short_double=*/false);
 
 This hardcodes short double to false. If I were to hardcode this to true,
 Patricks example would work.
 
 I think similarly to what we do in c-family/c-common.c:
   build_common_tree_nodes (flag_signed_char, flag_short_double);
 
 we need to pass flag_short_double but the only way to do so is by letting
 fshort-double pass through the flag filtering that goes on before lto1 is
 called.

Yes, see above - this will fix the immediate issue.  Of course it won't
fix things if you have mismatched -fshort-double options in TUs or
in compile vs. link-time.  For this was my original suggestion - do not
stream double_type_node but stream the type literally.

Index: tree-streamer.c
===
--- tree-streamer.c (revision 208066)
+++ tree-streamer.c (working copy)
@@ -264,7 +264,8 @@

   gcc_checking_assert (node != boolean_type_node
node != boolean_true_node
-   node != boolean_false_node);
+   node != boolean_false_node
+   node != double_type_node);

   /* We have to make sure to fill exactly the same number of
  elements for all frontends.  That can include NULL trees.
@@ -318,7 +319,10 @@
 /* Skip boolean type and constants, they are frontend dependent.  */
 if (i != TI_BOOLEAN_TYPE
 i != TI_BOOLEAN_FALSE
-i != TI_BOOLEAN_TRUE)
+i != TI_BOOLEAN_TRUE
+i != TI_DOUBLE_TYPE
+i != TI_COMPLEX_DOUBLE_TYPE
+i != TI_DOUBLE_PTR_TYPE)
   record_common_node (cache, global_trees[i]);
 }

This should fix both errors - not passing on -fshort-double _and_ mixing
-f[no-]short-double.

Well.  At least to my theory (didn't try).

 I will prepare a patch to add this exception, let me know if you think
 there's a better way.

See above - if that works I'd prefer that.


[Bug lto/55113] ICE with LTO and -fshort-double

2014-02-27 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

--- Comment #15 from pmatos at gcc dot gnu.org ---
(In reply to Richard Biener from comment #14)
 See above - if that works I'd prefer that.

Makes sense. Thanks Richard. I will give that a try and if everything looks ok
I will prepare a patch today along with a testcase.


[Bug lto/55113] ICE with LTO and -fshort-double

2014-02-26 Thread pmatos at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

--- Comment #13 from pmatos at gcc dot gnu.org ---
(In reply to Richard Biener from comment #11)
 If double_type_node is FE dependent then it needs treatment in
 tree-streamer.c:preload_common_nodes:
 
 static void
 preload_common_nodes (struct streamer_tree_cache_d *cache)
 {
   unsigned i;
 
   for (i = 0; i  itk_none; i++)
 /* Skip itk_char.  char_type_node is dependent on -f[un]signed-char.  */
 if (i != itk_char)
   record_common_node (cache, integer_types[i]);
 
   for (i = 0; i  stk_type_kind_last; i++)
 record_common_node (cache, sizetype_tab[i]);
 
   for (i = 0; i  TI_MAX; i++)
 /* Skip boolean type and constants, they are frontend dependent.  */
 if (i != TI_BOOLEAN_TYPE
  i != TI_BOOLEAN_FALSE
  i != TI_BOOLEAN_TRUE)
   record_common_node (cache, global_trees[i]);
 }

Richard,
I tried what you suggested but led me nowhere. In the meantime I noticed that
-fshort-double shows up in COLLECT_GCC_OPTIONS before collect2 is called:

COLLECT_GCC_OPTIONS='-fshort-double' '-flto' '-nostdlib' '-o' 'test'
'-save-temps' '-v' '-da' '-fdump-tree-all-all' '-mcpu=8540'

/home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-eabispe/4.8.3/collect2
-plugin
/home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-eabispe/4.8.3/liblto_plugin.so
-plugin-opt=/home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-eabispe/4.8.3/lto-wrapper
-plugin-opt=-fresolution=pr55113.res -flto
--sysroot=/home/pmatos/work/pr55113/top-4_8/toolchain/prex_sysroot
--eh-frame-hdr -V -dn -Bstatic -o test
-L/home/pmatos/work/pr55113/top-4_8/toolchain/install/lib/gcc/powerpc-eabispe/4.8.3
-L/home/pmatos/work/pr55113/top-4_8/toolchain/install/lib/gcc/powerpc-eabispe/4.8.3/../../../../powerpc-eabispe/lib
pr55113.o

but not after when lto1 is called:
COLLECT_GCC_OPTIONS='-c' '-mcpu=8540' '-nostdlib' '-save-temps' '-v' '-da'
'-fdump-tree-all-all' '-mcpu=8540' '-dumpdir' './' '-dumpbase' 'test.wpa'
'-fltrans-output-list=test.ltrans.out' '-fwpa' '-fresolution=pr55113.res'

/home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-eabispe/4.8.3/lto1
-quiet -da -dumpdir ./ -dumpbase test.wpa -mcpu=8540 -mcpu=8540 -auxbase
pr55113 -version -fdump-tree-all-all -fltrans-output-list=test.ltrans.out -fwpa
-fresolution=pr55113.res @/tmp/ccW7YQPl

Somewhere along the line the option is lost. It seems to be that only some
options are kept and optimization options are lost, like fshort-double.
However, in lto/lto-lang.c:lto_init you have:
  /* Create the basic integer types.  */
  build_common_tree_nodes (flag_signed_char, /*short_double=*/false);

This hardcodes short double to false. If I were to hardcode this to true,
Patricks example would work.

I think similarly to what we do in c-family/c-common.c:
  build_common_tree_nodes (flag_signed_char, flag_short_double);

we need to pass flag_short_double but the only way to do so is by letting
fshort-double pass through the flag filtering that goes on before lto1 is
called.

I will prepare a patch to add this exception, let me know if you think there's
a better way.


[Bug lto/55113] ICE with LTO and -fshort-double

2014-01-20 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

--- Comment #11 from Richard Biener rguenth at gcc dot gnu.org ---
If double_type_node is FE dependent then it needs treatment in
tree-streamer.c:preload_common_nodes:

static void
preload_common_nodes (struct streamer_tree_cache_d *cache)
{
  unsigned i;

  for (i = 0; i  itk_none; i++)
/* Skip itk_char.  char_type_node is dependent on -f[un]signed-char.  */
if (i != itk_char)
  record_common_node (cache, integer_types[i]);

  for (i = 0; i  stk_type_kind_last; i++)
record_common_node (cache, sizetype_tab[i]);

  for (i = 0; i  TI_MAX; i++)
/* Skip boolean type and constants, they are frontend dependent.  */
if (i != TI_BOOLEAN_TYPE
 i != TI_BOOLEAN_FALSE
 i != TI_BOOLEAN_TRUE)
  record_common_node (cache, global_trees[i]);
}


[Bug lto/55113] ICE with LTO and -fshort-double

2014-01-20 Thread patrick at motec dot com.au
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

--- Comment #12 from Patrick Oppenlander patrick at motec dot com.au ---
(In reply to Andrew Pinski from comment #10)
  -fshort-double is what is causing the issue.  Why are you using that option
 in the first place?  It changes the ABI.

We are using the option as it suits our e200z6 core very well. When it is in
use GCC 4.4.3 generates efficient code using the scalar SPFP APU (efs*
mnemonics). We don't have a hardware double-precision FPU, and no need for
double precision math.


[Bug lto/55113] ICE with LTO and -fshort-double

2014-01-19 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

Andrew Pinski pinskia at gcc dot gnu.org changed:

   What|Removed |Added

Summary|ICE in  |ICE with LTO and
   |emit_library_call_value_1,  |-fshort-double
   |at calls.c:3757 |

--- Comment #10 from Andrew Pinski pinskia at gcc dot gnu.org ---
 -fshort-double is what is causing the issue.  Why are you using that option in
the first place?  It changes the ABI.

With 4.7.0 (and checking enabled), I get the following ICE on all targets with
-flto -fshort-double -Os:
t7.c: In function ‘main’:
t7.c:3:5: error: non-trivial conversion at assignment
float
double
# .MEM_2 = VDEF .MEM_1(D)
f = 1.0e+0;