On Thu, 21 Jun 2018, Richard Biener wrote: > > PR86223 points out that we currently gimplify the testcase inconsistently. > For the incomplete CTORs we use block-clearing while for the complete > one we emit initializations of the individual elements (up to the > limits imposed in following checks). > > So the following makes us always use = {}; form for all-zero CTORs > which is most compact for GIMPLE IL and should only result in better > code (fingers crossing...) since but not only beacause SRA got the > ability to handle a = .LC0; style inits as well. > > Bootstrap & regtest running on x86_64-unknown-linux-gnu.
Fine apart from FAIL: g++.dg/tm/pr45940-3.C -std=gnu++11 (internal compiler error) FAIL: g++.dg/tm/pr45940-3.C -std=gnu++11 (test for excess errors) FAIL: g++.dg/tm/pr45940-3.C -std=gnu++14 (internal compiler error) FAIL: g++.dg/tm/pr45940-3.C -std=gnu++14 (test for excess errors) FAIL: g++.dg/tm/pr45940-3.C -std=gnu++98 (internal compiler error) FAIL: g++.dg/tm/pr45940-3.C -std=gnu++98 (test for excess errors) FAIL: g++.dg/tm/pr45940-4.C -std=gnu++11 (internal compiler error) FAIL: g++.dg/tm/pr45940-4.C -std=gnu++11 (test for excess errors) FAIL: g++.dg/tm/pr45940-4.C -std=gnu++14 (internal compiler error) FAIL: g++.dg/tm/pr45940-4.C -std=gnu++14 (test for excess errors) FAIL: g++.dg/tm/pr45940-4.C -std=gnu++98 (internal compiler error) FAIL: g++.dg/tm/pr45940-4.C -std=gnu++98 (test for excess errors) during GIMPLE pass: tmmark^M In constructor 'shared_count::shared_count() transaction_safe':^M cc1plus: internal compiler error: in create_tmp_var, at gimple-expr.c:479^M 0x6c8dc7 create_tmp_var(tree_node*, char const*)^M /space/rguenther/src/svn/trunk/gcc/gimple-expr.c:479^M 0xc5375b create_tmp_from_val^M /space/rguenther/src/svn/trunk/gcc/gimplify.c:516^M 0xc5375b lookup_tmp_var^M /space/rguenther/src/svn/trunk/gcc/gimplify.c:537^M 0xc5375b internal_get_tmp_var^M /space/rguenther/src/svn/trunk/gcc/gimplify.c:590^M 0xc4d481 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int)^M /space/rguenther/src/svn/trunk/gcc/gimplify.c:12386^M 0xc572d4 gimplify_addr_expr^M /space/rguenther/src/svn/trunk/gcc/gimplify.c:5994^M 0xc4f82d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int)^M /space/rguenther/src/svn/trunk/gcc/gimplify.c:11485^M 0xc5f4cc force_gimple_operand_1(tree_node*, gimple**, bool (*)(tree_node*), tree_node*)^M /space/rguenther/src/svn/trunk/gcc/gimplify-me.c:78^M 0xc5f57f force_gimple_operand_gsi_1(gimple_stmt_iterator*, tree_node*, bool (*)(tree_node*), tree_node*, bool, gsi_iterator_update)^M /space/rguenther/src/svn/trunk/gcc/gimplify-me.c:115^M 0xe9ac6a expand_assign_tm^M /space/rguenther/src/svn/trunk/gcc/trans-mem.c:2446^M 0xe9df02 expand_block_tm^M /space/rguenther/src/svn/trunk/gcc/trans-mem.c:2646^M 0xe9df02 execute_tm_mark^M /space/rguenther/src/svn/trunk/gcc/trans-mem.c:3130^M 0xe9df02 execute^M /space/rguenther/src/svn/trunk/gcc/trans-mem.c:3175^M we're doing gimplify_addr (gsi, rhs); on a {} RHS. Looks like TM doesn't handle stores from {} at all... is there a TM-safe memset()? and FAIL: gnat.dg/opt34.adb scan-tree-dump esra "Created a replacement for result" no time to investigate right now, so I'm putting this on hold. Eric, can you see if the opt34.adb FAIL is "harmless"? Richard. > Richard. > > 2018-06-21 Richard Biener <rguent...@suse.de> > > PR middle-end/86223 > * gimplify.c (gimplify_init_constructor): For an all-zero > constructor emit a block-clear. > > * gcc.dg/pr86223-1.c: New testcase. > > Index: gcc/gimplify.c > =================================================================== > --- gcc/gimplify.c (revision 261839) > +++ gcc/gimplify.c (working copy) > @@ -4805,6 +4805,10 @@ gimplify_init_constructor (tree *expr_p, > requires trickery to avoid quadratic compile-time behavior in > large cases or excessive memory use in small cases. */ > cleared = !CONSTRUCTOR_NO_CLEARING (ctor); > + else if (num_nonzero_elements == 0) > + /* If all elements are zero it is most efficient to block-clear > + things. */ > + cleared = true; > else if (num_ctor_elements - num_nonzero_elements > > CLEAR_RATIO (optimize_function_for_speed_p (cfun)) > && num_nonzero_elements < num_ctor_elements / 4) > Index: gcc/testsuite/gcc.dg/pr86223-1.c > =================================================================== > --- gcc/testsuite/gcc.dg/pr86223-1.c (revision 0) > +++ gcc/testsuite/gcc.dg/pr86223-1.c (working copy) > @@ -0,0 +1,17 @@ > +/* { dg-do compile } */ > +/* { dg-options "-fdump-tree-gimple" } */ > + > +void f (int *); > +void g () > +{ > + int a[3] = { 0, 0, 0 }; > + f (a); > +} > +void h () > +{ > + int a[3] = { 0 }; > + f (a); > +} > + > +/* We should use block-clearing for the initializer of a in both cases. */ > +/* { dg-final { scan-tree-dump-times "a = {};" 2 "gimple" } } */ > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)