User account creation filtered due to spam.

Bug 48846 - Many -O2 -flto testsuite failures with -m32 -mavx
Summary: Many -O2 -flto testsuite failures with -m32 -mavx
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Richard Biener
Depends on:
Reported: 2011-05-02 20:29 UTC by Uroš Bizjak
Modified: 2011-05-03 16:44 UTC (History)
2 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: x86_64-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2011-05-03 03:05:33


Note You need to log in before you can comment on or make changes to this bug.
Description Uroš Bizjak 2011-05-02 20:29:54 UTC
Currently, many tests fail with -O2 -flto -m32 -mavx, for example gcc.c-torture/execute/pr38151.c:

~/gcc-build/gcc/xgcc -B ~/gcc-build/gcc -O2 -flto -mavx -m32 pr38151.c
In file included from :0:0:
pr38151.c: In function ‘check2848va’:
pr38151.c:17:1: internal compiler error: Segmentation fault
Please submit a full bug report,

[pr38151.o obtained from -save-temps]

gdb --args ~/gcc-build/gcc/lto1 pr38151.o

Program received signal SIGSEGV, Segmentation fault.
is_gimple_min_invariant (t=0x0) at ../../gcc-svn/trunk/gcc/gimple.c:2814
2814	  if (TREE_CODE (t) == ADDR_EXPR)

(gdb) bt
#0  is_gimple_min_invariant (t=0x0) at ../../gcc-svn/trunk/gcc/gimple.c:2814
#1  0x0000000000653c4d in gimplify_compound_lval (expr_p=0x7fffffffdd28, 
    pre_p=0x7fffffffddb8, post_p=0x7fffffffdc40, fallback=1)
    at ../../gcc-svn/trunk/gcc/gimplify.c:2053
#2  0x000000000064ffbb in gimplify_expr (expr_p=0x7fffffffdd28, 
    pre_p=0x7fffffffddb8, post_p=0x7fffffffdc40, 
    gimple_test_f=0x639bb0 <is_gimple_val>, fallback=1)
    at ../../gcc-svn/trunk/gcc/gimplify.c:6717
#3  0x0000000000662f0b in force_gimple_operand_1 (expr=0x7ffff202d780, 
    stmts=0x7fffffffddb8, gimple_test_f=0x639bb0 <is_gimple_val>, var=0x0)
    at ../../gcc-svn/trunk/gcc/gimplify.c:8162
#4  0x0000000000663083 in force_gimple_operand_gsi_1 (gsi=0x7fffffffde60, expr=Unhandled dwarf expression opcode 0xf3

) at ../../gcc-svn/trunk/gcc/gimplify.c:8202
#5  0x00000000007b1aac in expand_complex_move ()
    at ../../gcc-svn/trunk/gcc/tree-complex.c:810
#6  expand_complex_operations_1 ()
    at ../../gcc-svn/trunk/gcc/tree-complex.c:1459
#7  tree_lower_complex () at ../../gcc-svn/trunk/gcc/tree-complex.c:1600
#8  tree_lower_complex () at ../../gcc-svn/trunk/gcc/tree-complex.c:1566
Comment 1 Uroš Bizjak 2011-05-02 20:43:31 UTC
valgrind says:

==29628== Invalid read of size 2
==29628==    at 0x641800: is_gimple_min_invariant (gimple.c:2814)
==29628==    by 0x65BC5C: gimplify_compound_lval (gimplify.c:2053)
==29628==    by 0x680984: gimplify_expr (gimplify.c:6717)
==29628==    by 0x68A9E4: force_gimple_operand_1 (gimplify.c:8162)
==29628==    by 0x68AB83: force_gimple_operand_gsi_1 (gimplify.c:8202)
==29628==    by 0x68ACC9: force_gimple_operand_gsi (gimplify.c:8236)
==29628==    by 0x7DC3A2: expand_complex_operations_1 (tree-complex.c:810)
==29628==    by 0x7DD583: tree_lower_complex (tree-complex.c:1600)
==29628==    by 0x71BAC5: execute_one_pass (passes.c:1556)
==29628==    by 0x71BDC4: execute_pass_list (passes.c:1611)
==29628==    by 0x81B835: tree_rest_of_compilation (tree-optimize.c:423)
==29628==    by 0x9D7183: cgraph_expand_function (cgraphunit.c:1579)
==29628==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
Comment 2 H.J. Lu 2011-05-03 03:05:33 UTC
It is caused by revision 172871:
Comment 3 Richard Biener 2011-05-03 09:05:58 UTC
We have a field-decl with off_align == 255, thus DECL_OFFSET_ALIGN is
technically undefined (computed as 1u << 255).  Things go downhill from there
in at gimplify.c:2051 where we call

              /* Divide the offset by its alignment.  */
              offset = size_binop_loc (loc, EXACT_DIV_EXPR, offset, factor);

with offset and factor == 0 because inn int_const_binop we do

    case ROUND_DIV_EXPR:
      if (double_int_zero_p (op2))
        return NULL_TREE;

and nothing checks for that result.

The bug is in the LTO streamer which packs DECL_OFFSET_ALIGN as a 8 bit
value, assumig it is decl_common.off_align which it is not.

Not sure why this is exposed by the build_int_cst patch.

Well, I have a patch anyway.
Comment 4 Richard Biener 2011-05-03 10:18:32 UTC
Author: rguenth
Date: Tue May  3 10:18:29 2011
New Revision: 173298

2011-05-03  Richard Guenther  <>

	PR lto/48846
	* lto-streamer-in.c (unpack_ts_decl_common_value_fields):
	Stream decl_common.off_align instead of the derived DECL_OFFSET_ALIGN.
	* lto-streamer-out.c (pack_ts_decl_common_value_fields): Likewise.

Comment 5 Richard Biener 2011-05-03 10:21:48 UTC
Author: rguenth
Date: Tue May  3 10:21:44 2011
New Revision: 173299

2011-05-03  Richard Guenther  <>

	PR lto/48846
	* lto-streamer-in.c (unpack_ts_decl_common_value_fields):
	Stream decl_common.off_align instead of the derived DECL_OFFSET_ALIGN.
	* lto-streamer-out.c (pack_ts_decl_common_value_fields): Likewise.

Comment 6 Uroš Bizjak 2011-05-03 16:44:20 UTC
Works OK, fixed.