Re: [PATCH] FMA_EXPR can cause -fnon-call-exceptions with floating point args (PR middle-end/79396)
On February 24, 2017 9:56:25 PM GMT+01:00, Jakub Jelinekwrote: >Hi! > >On the following testcase we replace a PLUS_EXPR (which is considered >throwing with -fnon-call-exceptions when it has floating point >arguments >and FP exceptions or sNaNs are enabled) with a FMA_EXPR; I believe it >can throw the same, but stmt_could_throw_1_p doesn't think so (as it is >not unary/binary/comparison). While we could tweak the widen_mul patch >to deal with dropping EH from gsi_replace and cleaning up cfg etc., I >believe the right fix is to fix stmt_could_throw_1_p. > >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. Can you make sure this is then consistent with the other throw predicates?. Richard >2017-02-24 Jakub Jelinek > > PR middle-end/79396 > * tree-eh.c (stmt_could_throw_1_p): Handle FMA_EXPR like tcc_binary > or tcc_unary. > > * g++.dg/opt/pr79396.C: New test. > >--- gcc/tree-eh.c.jj 2017-02-06 13:32:13.0 +0100 >+++ gcc/tree-eh.c 2017-02-24 19:14:04.964854279 +0100 >@@ -2738,7 +2738,8 @@ stmt_could_throw_1_p (gimple *stmt) > > if (TREE_CODE_CLASS (code) == tcc_comparison > || TREE_CODE_CLASS (code) == tcc_unary >- || TREE_CODE_CLASS (code) == tcc_binary) >+ || TREE_CODE_CLASS (code) == tcc_binary >+ || code == FMA_EXPR) > { > if (is_gimple_assign (stmt) > && TREE_CODE_CLASS (code) == tcc_comparison) >--- gcc/testsuite/g++.dg/opt/pr79396.C.jj 2017-02-24 19:22:18.499312974 >+0100 >+++ gcc/testsuite/g++.dg/opt/pr79396.C 2017-02-24 19:21:38.0 >+0100 >@@ -0,0 +1,13 @@ >+// PR middle-end/79396 >+// { dg-do compile } >+// { dg-options "-fnon-call-exceptions -O2" } >+// { dg-additional-options "-mfma" { target i?86-*-* x86_64-*-* } } >+ >+struct A { A (); ~A (); }; >+ >+float >+foo (float x) >+{ >+ A a; >+ return __builtin_pow (x, 2) + 2; >+} > > Jakub
Re: [PATCH] PR79584, lra ICE in base_to_reg
On 02/24/2017 12:07 AM, Alan Modra wrote: I'm going to wait for Vlad's opinion. I've written a couple of replies and erased them, since I figure whatever I have to say doesn't carry much weight. I would prefer not to touch simplify_subreg_operand, especially a code related to subreg of mem. Changes of the code usually result in a long time stabilization work. The change might result in LRA cycling (I remember it happened before exactly for ppc SD memory handling). It is dangerous when we are closer to the release. I hope more work on clearing the simplify_subreg_operand code will be done for GCC-8 (at least Matt Fortune expressed his willingness to do this). Although it is better to avoid a wrong RTL code creation earlier, LRA already can create a wrong code during its work for a long period of time. It already happens for some cases. So please commit your patch, Allan. But before doing it also please check that the patch does not creates problems on x86-64 bootstrap and GCC tests. Thank you.
[Patch, fortran] PRs 79597 and 79601.
Dear All, These trivial bugs have been fixed in revision 245729. 2017-02-25 Dominique d'HumieresPR fortran/79597 * interface.c (gfc_match_end_interface): Remove spurious comma and space, replace 'got %s' with 'got %qs'. 2017-02-25 Dominique d'Humieres PR fortran/79597 * gfortran.dg/dtio_6.f90: Update test. 2017-02-25 Dominique d'Humieres PR fortran/79601 * interface.c (check_dtio_arg_TKR_intent): Change 'intent' to 'INTENT'. 2017-02-25 Dominique d'Humieres PR fortran/79601 * gfortran.dg/interface_operator_2.f90: New test. Cheers, Dominique
Re: [PATCH] Fix regressions caused by early debug (DW_OP_GNU_variable_value extension 161109.2; PR debug/77589)
On Fri, Feb 24, 2017 at 02:27:46PM -0800, Jason Merrill wrote: > Makes sense. The patch is OK with the above refactoring. Thanks. Here is what I'll bootstrap/regtest and commit if it passes (first incremental diff, attached full patch): --- gcc/dwarf2out.c 2017-02-24 10:01:22.538447008 +0100 +++ gcc/dwarf2out.c 2017-02-24 10:01:22.538447008 +0100 @@ -16320,6 +16320,16 @@ return !list->ll_symbol; } +/* Duplicate a single element of location list. */ + +static inline dw_loc_descr_ref +copy_loc_descr (dw_loc_descr_ref ref) +{ + dw_loc_descr_ref copy = ggc_alloc (); + memcpy (copy, ref, sizeof (dw_loc_descr_node)); + return copy; +} + /* To each location in list LIST append loc descr REF. */ static void @@ -16330,16 +16340,10 @@ list = list->dw_loc_next; while (list) { - copy = ggc_alloc (); - memcpy (copy, ref, sizeof (dw_loc_descr_node)); + copy = copy_loc_descr (ref); add_loc_descr (>expr, copy); while (copy->dw_loc_next) - { - dw_loc_descr_ref new_copy = ggc_alloc (); - memcpy (new_copy, copy->dw_loc_next, sizeof (dw_loc_descr_node)); - copy->dw_loc_next = new_copy; - copy = new_copy; - } + copy = copy->dw_loc_next = copy_loc_descr (copy->dw_loc_next); list = list->dw_loc_next; } } @@ -16357,16 +16361,9 @@ while (list) { dw_loc_descr_ref end = list->expr; - copy = ggc_alloc (); - memcpy (copy, ref, sizeof (dw_loc_descr_node)); - list->expr = copy; + list->expr = copy = copy_loc_descr (ref); while (copy->dw_loc_next != ref_end) - { - dw_loc_descr_ref new_copy = ggc_alloc (); - memcpy (new_copy, copy->dw_loc_next, sizeof (dw_loc_descr_node)); - copy->dw_loc_next = new_copy; - copy = new_copy; - } + copy = copy->dw_loc_next = copy_loc_descr (copy->dw_loc_next); copy->dw_loc_next = end; list = list->dw_loc_next; } Jakub 2017-02-24 Jakub JelinekPR debug/77589 include/ * dwarf2.def (DW_OP_GNU_variable_value): New opcode. gcc/ * dwarf2out.c (struct dw_loc_list_struct): Add noted_variable_value bitfield. (size_of_loc_descr): Handle DW_OP_GNU_variable_value. (output_loc_operands): Handle DW_OP_call_ref and DW_OP_GNU_variable_value. (struct variable_value_struct): New type. (struct variable_value_hasher): Likewise. (variable_value_hash): New variable. (string_types): Remove. (copy_loc_descr): New function. (add_loc_descr_to_each): Clarify comment. Use copy_loc_descr. (prepend_loc_descr_to_each): New function. (add_loc_list): Fix comment typo. Use prepend_loc_descr_to_each instead of add_loc_descr_to_each if the first argument is single location list and the second has multiple. (resolve_args_picking_1): Handle DW_OP_GNU_variable_value. (loc_list_from_tree_1): For early_dwarf, emit DW_OP_GNU_variable_value when looking for variable value which doesn't have other location info. (loc_list_from_tree): Formatting fix. (gen_array_type_die): Simplify DW_AT_string_length handling. (adjust_string_types): Remove. (gen_subprogram_die): Don't call adjust_string_types nor test/set string_types. Call resolve_variable_values. (prune_unused_types_walk_loc_descr): Handle DW_OP_GNU_variable_value. (resolve_addr_in_expr): Likewise. Add A argument. (copy_deref_exprloc): Remove deref argument. Adjust for the original expression being DW_OP_GNU_variable_value with optionally DW_OP_stack_value after it instead of DW_OP_call4 with DW_OP_deref optionally after it. (optimize_string_length): Rework for DW_OP_GNU_variable_value. (resolve_addr): Adjust optimize_string_length and resolve_addr_in_expr callers. Set remove_AT_byte_size if removing DW_AT_string_length. (variable_value_hasher::hash, variable_value_hasher::equal): New methods. (resolve_variable_value_in_expr, resolve_variable_value, resolve_variable_values, note_variable_value_in_expr, note_variable_value): New functions. (dwarf2out_early_finish): Call note_variable_value on all toplevel DIEs. --- include/dwarf2.def.jj 2017-02-23 23:01:14.410952922 +0100 +++ include/dwarf2.def 2017-02-24 09:37:58.943132731 +0100 @@ -675,6 +675,9 @@ DW_OP (DW_OP_GNU_parameter_ref, 0xfa) /* Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission. */ DW_OP (DW_OP_GNU_addr_index, 0xfb) DW_OP (DW_OP_GNU_const_index, 0xfc) +/* The GNU variable value extension. + See http://dwarfstd.org/ShowIssue.php?issue=161109.2 . */ +DW_OP (DW_OP_GNU_variable_value, 0xfd) /* HP extensions. */ DW_OP_DUP (DW_OP_HP_unknown, 0xe0) /* Ouch, the same as GNU_push_tls_address. */ DW_OP
Re: [PATCH 3/6] microblaze: Fixes for RTL checking
On Tue, Feb 21, 2017 at 01:02:30PM -0800, Michael Eager wrote: > >>Why generate an unnecessary NOP? > > > >Why not? It will be optimised away anyway, and the code to get at the > >subregs is hairy... But could optimise away the useless move here > >already if both ops are a reg and both are the same, if you prefer that? > >Or rtx_equal_p (operands[0], operands[1])? > > It's optimized away only if optimization is on. > > The existing code checks and does not generate the unneeded move. > Whatever you change to clean up code should maintain the same behavior. > > if ((operands[2] == const0_rtx) && !rtx_equal_p (operands[0], operands[1])) > { > emit_insn (gen_movsi (operands[0], operands[1])); > } Hi Michael, Will you take care of it? Segher
Re: [PATCH 4/6] nios2: Fixes for RTL checking
On 02/21/2017 12:41 PM, Sandra Loosemore wrote: On 02/21/2017 07:48 AM, Segher Boessenkool wrote: You cannot call REGNO on something that isn't a REG, and you cannot call INTVAL on something that isn't a CONST_INT. The way I fixed nios2_alternate_compare_const is admittedly a bit lame. Yeah. :-P 2017-02-21 Segher Boessenkool* config/nios2/nios2.c (nios2_simple_const_p): Returns false if the argument isn't a CONST_INT. (nios2_alternate_compare_const): Set *alt_code and *alt_op to code and op if op is not a CONST_INT. (nios2_valid_compare_const_p): Return false if the argument isn't a CONST_INT. (ldstwm_operation_p): Return false if first_base is not a REG or if first_offset is not a CONST_INT. Give me a couple days to fiddle with this a bit and run regression tests. -Sandra I've checked in the attached version of the patch. I basically moved the CONST_INT test into nios2_validate_compare and changed its two helper functions to assert if they get the wrong thing, instead of trying to make them cope with other cases. I regression-tested this on nios2-elf and did some tests on nios2-linux-gnu as well. Thanks, Segher, for identifying these bugs. -Sandra 2017-02-24 Segher Boessenkool Sandra Loosemore gcc/ * config/nios2/nios2.c (nios2_simple_const_p): Returns false if the argument isn't a CONST_INT. (nios2_alternate_compare_const): Assert op is a CONST_INT. (nios2_valid_compare_const_p): Assert op is a CONST_INT. (nios2_validate_compare): Bypass alternate compare logic if *op2 is not a CONST_INT. (ldstwm_operation_p): Return false if first_base is not a REG or if first_offset is not a CONST_INT. Index: gcc/config/nios2/nios2.c === --- gcc/config/nios2/nios2.c (revision 245646) +++ gcc/config/nios2/nios2.c (working copy) @@ -1416,6 +1416,8 @@ nios2_option_override (void) static bool nios2_simple_const_p (const_rtx cst) { + if (!CONST_INT_P (cst)) +return false; HOST_WIDE_INT val = INTVAL (cst); return SMALL_INT (val) || SMALL_INT_UNSIGNED (val) || UPPER16_INT (val); } @@ -1753,6 +1755,8 @@ nios2_alternate_compare_const (enum rtx_ enum rtx_code *alt_code, rtx *alt_op, machine_mode mode) { + gcc_assert (CONST_INT_P (op)); + HOST_WIDE_INT opval = INTVAL (op); enum rtx_code scode = signed_condition (code); bool dec_p = (scode == LT || scode == GE); @@ -1788,6 +1792,7 @@ nios2_alternate_compare_const (enum rtx_ static bool nios2_valid_compare_const_p (enum rtx_code code, rtx op) { + gcc_assert (CONST_INT_P (op)); switch (code) { case EQ: case NE: case GE: case LT: @@ -1846,7 +1851,7 @@ nios2_validate_compare (machine_mode mod if (GET_MODE_CLASS (mode) == MODE_FLOAT) return nios2_validate_fpu_compare (mode, cmp, op1, op2, true); - if (!reg_or_0_operand (*op2, mode)) + if (CONST_INT_P (*op2) && *op2 != const0_rtx) { /* Create alternate constant compare. */ nios2_alternate_compare_const (code, *op2, _code, _op2, mode); @@ -1878,8 +1883,11 @@ nios2_validate_compare (machine_mode mod code = alt_code; *op2 = alt_op2; } - *op2 = force_reg (SImode, *op2); + *op2 = force_reg (mode, *op2); } +else if (!reg_or_0_operand (*op2, mode)) + *op2 = force_reg (mode, *op2); + check_rebuild_cmp: if (code == GT || code == GTU || code == LE || code == LEU) { @@ -4558,6 +4566,8 @@ ldstwm_operation_p (rtx op, bool load_p) if (!split_mem_address (XEXP (mem, 0), _base, _offset)) return false; + if (!REG_P (first_base) || !CONST_INT_P (first_offset)) + return false; base_reg = first_base; inc_p = INTVAL (first_offset) >= 0; }
Re: [PATCH] Fix regressions caused by early debug (DW_OP_GNU_variable_value extension 161109.2; PR debug/77589)
On Fri, Feb 24, 2017 at 1:57 PM, Jakub Jelinekwrote: > On Fri, Feb 24, 2017 at 01:40:37PM -0800, Jason Merrill wrote: >> On Fri, Feb 24, 2017 at 3:58 AM, Jakub Jelinek wrote: >> > + copy = ggc_alloc (); >> > + memcpy (copy, ref, sizeof (dw_loc_descr_node)); >> > + list->expr = copy; >> > + while (copy->dw_loc_next != ref_end) >> > + { >> > + dw_loc_descr_ref new_copy = ggc_alloc (); >> > + memcpy (new_copy, copy->dw_loc_next, sizeof (dw_loc_descr_node)); >> > + copy->dw_loc_next = new_copy; >> > + copy = new_copy; >> > + } >> >> This seems like it could use a copy_loc_descr function, shared with >> add_loc_descr_to_each. > > Ok, will do that. > >> > + && (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (loc))) >> > + <= DWARF2_ADDR_SIZE)) >> >> Is this condition necessary, given that DWARF 5 supports typed >> expressions that are not restricted to the size of the generic type? > > The extension pushes the variable value as generic type. We could have > also DW_OP_GNU_variable_value_type that would provide type and push the > value as typed value, but we don't need it right now and in the DW_OP_GNU* > range we don't have many spare positions left. In the standard range there > are more, so perhaps we can propose for DWARF6 both DW_OP_variable_value > and DW_OP_variable_value_type. > >> > @@ -27532,6 +27538,18 @@ prune_unused_types_walk_loc_descr (dw_lo >> > if (loc->dw_loc_oprnd1.val_class == dw_val_class_die_ref) >> > prune_unused_types_mark (loc->dw_loc_oprnd1.v.val_die_ref.die, >> > 1); >> > break; >> > + case DW_OP_GNU_variable_value: >> > + if (loc->dw_loc_oprnd1.val_class == dw_val_class_decl_ref) >> > + { >> > + dw_die_ref ref >> > + = lookup_decl_die (loc->dw_loc_oprnd1.v.val_decl_ref); >> > + if (ref == NULL) >> > + break; >> > + loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref; >> > + loc->dw_loc_oprnd1.v.val_die_ref.die = ref; >> > + loc->dw_loc_oprnd1.v.val_die_ref.external = 0; >> > + } >> >> Doing this adjustment in prune_unused_types is surprising. Why is it >> needed here as well as in the other places you do it? What if the >> user specifies -fno-eliminate-unused-debug-types? > > This falls through into code that wants to mark the type of the die, > so this is just an attempt if it can resolve to something, fallthrough > into that with the die, otherwise we can't do anything and defer it for > later. > With -fno-eliminate-unused-debug-types, this will not be done, and only in > note_variable_value it will try to look it up. The reason for not > putting note_variable_value before the type pruning is that there is the > dups elimination and -fdebug-types-section handling that often copies DIEs > etc. and so I wanted to populate the hash table with the final DIE tree > layout after the early dwarf. > Indeed, such lookup_decl_die calls are in multiple places, and if all fail > to look up, there is code that either will try to do something from the RTL, > or create the DIE or drop the expression. Makes sense. The patch is OK with the above refactoring. Jason
Re: [PATCH] Fix -Wformat -Werror=format-security -Wformat (PR c/79677)
On Fri, 24 Feb 2017, Jakub Jelinek wrote: > Hi! > > As mentioned in the PR, -Wformat -Werror=format-security -Wformat > surprisingly means -Wno-format-security in the end (same effect > e.g. with -Wall at the end), while > -Wformat -Wformat-security -Wformat (or -Wall) is -Wformat-security. > > The problem is that all the EnabledBy and LangEnabledBy options > are changed by the related options only if not explicitly set by the user, > and for explicit setting by user we mean only those options themselves, > not some other option that includes it. In most cases I think that is > just fine, say for -Wformat -Wformat=2 -Wformat nobody should expect > -Wformat-security to be on. But I think -Werror= should, -pedantic-errors > and -Werror-implicit-function-declaration should be an exception, if > one uses -Werror=foobar, we should consider -Wfoobar to be set explicitly, > similarly for -pedantic-errors we should consider -Wpedantic to be set > explicitly and for -Werror-implicit-function-declaration > -Wimplicit-function-declaration to be set explicitly. > > So the following patch implements that, pretty much ensures that > control_warning_option when it calls handle_generated_option -> > handle_option it will still set_option even in opts_set, not just opts. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. -- Joseph S. Myers jos...@codesourcery.com
Re: [PATCH] Fix regressions caused by early debug (DW_OP_GNU_variable_value extension 161109.2; PR debug/77589)
On Fri, Feb 24, 2017 at 01:40:37PM -0800, Jason Merrill wrote: > On Fri, Feb 24, 2017 at 3:58 AM, Jakub Jelinekwrote: > > + copy = ggc_alloc (); > > + memcpy (copy, ref, sizeof (dw_loc_descr_node)); > > + list->expr = copy; > > + while (copy->dw_loc_next != ref_end) > > + { > > + dw_loc_descr_ref new_copy = ggc_alloc (); > > + memcpy (new_copy, copy->dw_loc_next, sizeof (dw_loc_descr_node)); > > + copy->dw_loc_next = new_copy; > > + copy = new_copy; > > + } > > This seems like it could use a copy_loc_descr function, shared with > add_loc_descr_to_each. Ok, will do that. > > + && (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (loc))) > > + <= DWARF2_ADDR_SIZE)) > > Is this condition necessary, given that DWARF 5 supports typed > expressions that are not restricted to the size of the generic type? The extension pushes the variable value as generic type. We could have also DW_OP_GNU_variable_value_type that would provide type and push the value as typed value, but we don't need it right now and in the DW_OP_GNU* range we don't have many spare positions left. In the standard range there are more, so perhaps we can propose for DWARF6 both DW_OP_variable_value and DW_OP_variable_value_type. > > @@ -27532,6 +27538,18 @@ prune_unused_types_walk_loc_descr (dw_lo > > if (loc->dw_loc_oprnd1.val_class == dw_val_class_die_ref) > > prune_unused_types_mark (loc->dw_loc_oprnd1.v.val_die_ref.die, 1); > > break; > > + case DW_OP_GNU_variable_value: > > + if (loc->dw_loc_oprnd1.val_class == dw_val_class_decl_ref) > > + { > > + dw_die_ref ref > > + = lookup_decl_die (loc->dw_loc_oprnd1.v.val_decl_ref); > > + if (ref == NULL) > > + break; > > + loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref; > > + loc->dw_loc_oprnd1.v.val_die_ref.die = ref; > > + loc->dw_loc_oprnd1.v.val_die_ref.external = 0; > > + } > > Doing this adjustment in prune_unused_types is surprising. Why is it > needed here as well as in the other places you do it? What if the > user specifies -fno-eliminate-unused-debug-types? This falls through into code that wants to mark the type of the die, so this is just an attempt if it can resolve to something, fallthrough into that with the die, otherwise we can't do anything and defer it for later. With -fno-eliminate-unused-debug-types, this will not be done, and only in note_variable_value it will try to look it up. The reason for not putting note_variable_value before the type pruning is that there is the dups elimination and -fdebug-types-section handling that often copies DIEs etc. and so I wanted to populate the hash table with the final DIE tree layout after the early dwarf. Indeed, such lookup_decl_die calls are in multiple places, and if all fail to look up, there is code that either will try to do something from the RTL, or create the DIE or drop the expression. Jakub
Re: [PATCH rs6000] Fix PR79544
On Fri, Feb 24, 2017 at 11:44:29AM -0600, Pat Haugen wrote: > The following patch fixes the problem of generating a logical shift for > vec_sra of an unsigned v2di vector. > > Bootstrap/regtest on powerpc64le-unknown-linux-gnu with no new > regressions. Ok for trunk? Ok for backport to 5/6 branches after testing? Okay for all, thanks! Segher > 2017-02-24 Pat Haugen> > PR target/79544 > * rs6000/rs6000-c.c (struct altivec_builtin_types): Use VSRAD for > arithmetic shift of unsigned V2DI. > > testsuite/ChangeLog: > 2017-02-24 Pat Haugen > > * gcc.target/powerpc/pr79544.c: New.
Re: [PATCH] Fix regressions caused by early debug (DW_OP_GNU_variable_value extension 161109.2; PR debug/77589)
On Fri, Feb 24, 2017 at 3:58 AM, Jakub Jelinekwrote: > + copy = ggc_alloc (); > + memcpy (copy, ref, sizeof (dw_loc_descr_node)); > + list->expr = copy; > + while (copy->dw_loc_next != ref_end) > + { > + dw_loc_descr_ref new_copy = ggc_alloc (); > + memcpy (new_copy, copy->dw_loc_next, sizeof (dw_loc_descr_node)); > + copy->dw_loc_next = new_copy; > + copy = new_copy; > + } This seems like it could use a copy_loc_descr function, shared with add_loc_descr_to_each. > + && (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (loc))) > + <= DWARF2_ADDR_SIZE)) Is this condition necessary, given that DWARF 5 supports typed expressions that are not restricted to the size of the generic type? > @@ -27532,6 +27538,18 @@ prune_unused_types_walk_loc_descr (dw_lo > if (loc->dw_loc_oprnd1.val_class == dw_val_class_die_ref) > prune_unused_types_mark (loc->dw_loc_oprnd1.v.val_die_ref.die, 1); > break; > + case DW_OP_GNU_variable_value: > + if (loc->dw_loc_oprnd1.val_class == dw_val_class_decl_ref) > + { > + dw_die_ref ref > + = lookup_decl_die (loc->dw_loc_oprnd1.v.val_decl_ref); > + if (ref == NULL) > + break; > + loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref; > + loc->dw_loc_oprnd1.v.val_die_ref.die = ref; > + loc->dw_loc_oprnd1.v.val_die_ref.external = 0; > + } Doing this adjustment in prune_unused_types is surprising. Why is it needed here as well as in the other places you do it? What if the user specifies -fno-eliminate-unused-debug-types? Jason
[PATCH] FMA_EXPR can cause -fnon-call-exceptions with floating point args (PR middle-end/79396)
Hi! On the following testcase we replace a PLUS_EXPR (which is considered throwing with -fnon-call-exceptions when it has floating point arguments and FP exceptions or sNaNs are enabled) with a FMA_EXPR; I believe it can throw the same, but stmt_could_throw_1_p doesn't think so (as it is not unary/binary/comparison). While we could tweak the widen_mul patch to deal with dropping EH from gsi_replace and cleaning up cfg etc., I believe the right fix is to fix stmt_could_throw_1_p. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-02-24 Jakub JelinekPR middle-end/79396 * tree-eh.c (stmt_could_throw_1_p): Handle FMA_EXPR like tcc_binary or tcc_unary. * g++.dg/opt/pr79396.C: New test. --- gcc/tree-eh.c.jj2017-02-06 13:32:13.0 +0100 +++ gcc/tree-eh.c 2017-02-24 19:14:04.964854279 +0100 @@ -2738,7 +2738,8 @@ stmt_could_throw_1_p (gimple *stmt) if (TREE_CODE_CLASS (code) == tcc_comparison || TREE_CODE_CLASS (code) == tcc_unary - || TREE_CODE_CLASS (code) == tcc_binary) + || TREE_CODE_CLASS (code) == tcc_binary + || code == FMA_EXPR) { if (is_gimple_assign (stmt) && TREE_CODE_CLASS (code) == tcc_comparison) --- gcc/testsuite/g++.dg/opt/pr79396.C.jj 2017-02-24 19:22:18.499312974 +0100 +++ gcc/testsuite/g++.dg/opt/pr79396.C 2017-02-24 19:21:38.0 +0100 @@ -0,0 +1,13 @@ +// PR middle-end/79396 +// { dg-do compile } +// { dg-options "-fnon-call-exceptions -O2" } +// { dg-additional-options "-mfma" { target i?86-*-* x86_64-*-* } } + +struct A { A (); ~A (); }; + +float +foo (float x) +{ + A a; + return __builtin_pow (x, 2) + 2; +} Jakub
[PATCH] Fix -Wformat -Werror=format-security -Wformat (PR c/79677)
Hi! As mentioned in the PR, -Wformat -Werror=format-security -Wformat surprisingly means -Wno-format-security in the end (same effect e.g. with -Wall at the end), while -Wformat -Wformat-security -Wformat (or -Wall) is -Wformat-security. The problem is that all the EnabledBy and LangEnabledBy options are changed by the related options only if not explicitly set by the user, and for explicit setting by user we mean only those options themselves, not some other option that includes it. In most cases I think that is just fine, say for -Wformat -Wformat=2 -Wformat nobody should expect -Wformat-security to be on. But I think -Werror= should, -pedantic-errors and -Werror-implicit-function-declaration should be an exception, if one uses -Werror=foobar, we should consider -Wfoobar to be set explicitly, similarly for -pedantic-errors we should consider -Wpedantic to be set explicitly and for -Werror-implicit-function-declaration -Wimplicit-function-declaration to be set explicitly. So the following patch implements that, pretty much ensures that control_warning_option when it calls handle_generated_option -> handle_option it will still set_option even in opts_set, not just opts. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-02-24 Jakub JelinekPR c/79677 * opts.h (handle_generated_option): Add GENERATED_P argument. * opts-common.c (handle_option): Adjust function comment. (handle_generated_option): Add GENERATED_P argument, pass it to handle_option. (control_warning_option): Pass false to handle_generated_option GENERATED_P. * opts.c (maybe_default_option): Pass true to handle_generated_option GENERATED_P. * optc-gen.awk: Likewise. ada/ * gcc-interface/misc.c (gnat_handle_option): Pass true to handle_generated_option GENERATED_P. testsuite/ * gcc.dg/pr79677.c: New test. --- gcc/opts.h.jj 2017-01-01 12:45:38.0 +0100 +++ gcc/opts.h 2017-02-24 16:30:05.287564997 +0100 @@ -353,7 +353,7 @@ bool handle_generated_option (struct gcc size_t opt_index, const char *arg, int value, unsigned int lang_mask, int kind, location_t loc, const struct cl_option_handlers *handlers, - diagnostic_context *dc); + bool generated_p, diagnostic_context *dc); void generate_option (size_t opt_index, const char *arg, int value, unsigned int lang_mask, struct cl_decoded_option *decoded); --- gcc/opts-common.c.jj2017-01-01 12:45:39.0 +0100 +++ gcc/opts-common.c 2017-02-24 16:40:35.878378793 +0100 @@ -959,9 +959,10 @@ keep: option for options from the source file, UNKNOWN_LOCATION otherwise. GENERATED_P is true for an option generated as part of processing another option or otherwise generated internally, false - for one explicitly passed by the user. Returns false if the switch - was invalid. DC is the diagnostic context for options affecting - diagnostics state, or NULL. */ + for one explicitly passed by the user. control_warning_option + generated options are considered explicitly passed by the user. + Returns false if the switch was invalid. DC is the diagnostic + context for options affecting diagnostics state, or NULL. */ static bool handle_option (struct gcc_options *opts, @@ -1005,13 +1006,13 @@ handle_generated_option (struct gcc_opti size_t opt_index, const char *arg, int value, unsigned int lang_mask, int kind, location_t loc, const struct cl_option_handlers *handlers, -diagnostic_context *dc) +bool generated_p, diagnostic_context *dc) { struct cl_decoded_option decoded; generate_option (opt_index, arg, value, lang_mask, ); return handle_option (opts, opts_set, , lang_mask, kind, loc, - handlers, true, dc); + handlers, generated_p, dc); } /* Fill in *DECODED with an option described by OPT_INDEX, ARG and @@ -1503,7 +1504,7 @@ control_warning_option (unsigned int opt handle_generated_option (opts, opts_set, opt_index, arg, value, lang_mask, - kind, loc, handlers, dc); + kind, loc, handlers, false, dc); } } } --- gcc/opts.c.jj 2017-01-30 19:10:51.0 +0100 +++ gcc/opts.c 2017-02-24 16:30:38.168137303 +0100 @@ -403,13 +403,13 @@ maybe_default_option (struct gcc_options handle_generated_option (opts, opts_set, default_opt->opt_index, default_opt->arg, default_opt->value, lang_mask, DK_UNSPECIFIED, loc, -handlers, dc);
[PATCH] Two small translation related tweaks
Hi! After hinting Marek to use const char *const in his G_ addition patch, I've grepped for other similar cases. The number_of_iterations_exit code doesn't make sense after we ended up (change from 6.x) with only a single wording, and in the C++ FE the addition of const allows -Wformat to see those format strings. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-02-24 Jakub Jelinek* tree-ssa-loop-niter.c (number_of_iterations_exit): Simplify warning. cp/ * call.c (build_op_delete_call): Make msg1 and msg2 const. --- gcc/tree-ssa-loop-niter.c.jj2017-01-24 23:29:05.0 +0100 +++ gcc/tree-ssa-loop-niter.c 2017-02-24 15:34:24.119941951 +0100 @@ -2362,13 +2362,9 @@ number_of_iterations_exit (struct loop * return true; if (warn) -{ - const char *wording; - - wording = N_("missed loop optimization, the loop counter may overflow"); - warning_at (gimple_location_safe (stmt), - OPT_Wunsafe_loop_optimizations, "%s", gettext (wording)); -} +warning_at (gimple_location_safe (stmt), + OPT_Wunsafe_loop_optimizations, + "missed loop optimization, the loop counter may overflow"); return false; } --- gcc/cp/call.c.jj2017-02-23 08:40:30.0 +0100 +++ gcc/cp/call.c 2017-02-24 15:31:49.041955772 +0100 @@ -6225,10 +6225,10 @@ build_op_delete_call (enum tree_code cod allocation function, the program is ill-formed." */ if (second_parm_is_size_t (fn)) { - const char *msg1 + const char *const msg1 = G_("exception cleanup for this placement new selects " "non-placement operator delete"); - const char *msg2 + const char *const msg2 = G_("%qD is a usual (non-placement) deallocation " "function in C++14 (or with -fsized-deallocation)"); Jakub
Re: [PATCH] Move -Wrestrict warning later in the FEs and fix some issues in it (PR c++/79588)
On Thu, Feb 23, 2017 at 03:09:47PM -0700, Jeff Law wrote: > Please refactor the restrict warning bits into their own function, then > calling that from check_function_arguments. That's the style already used > there. > > OK with that change. Here is what I've committed after another bootstrap/regtest: 2017-02-24 Jakub JelinekPR c++/79588 c-family/ * c-common.c (check_function_restrict): New function. (check_function_arguments): Add FNDECL argument. Call check_function_restrict if -Wrestrict. * c-warn.c (warn_for_restrict): Remove ARGS argument, add ARGARRAY and NARGS. Use auto_vec for ARG_POSITIONS, simplify. * c-common.h (check_function_arguments): Add FNDECL argument. (warn_for_restrict): Remove ARGS argument, add ARGARRAY and NARGS. c/ * c-parser.c (c_parser_postfix_expression_after_primary): Don't handle -Wrestrict here. * c-typeck.c (build_function_call_vec): Adjust check_function_arguments caller. cp/ * call.c (build_over_call): Call check_function_arguments even for -Wrestrict, adjust check_function_arguments caller. * parser.c (cp_parser_postfix_expression): Don't handle -Wrestrict here. * typeck.c (cp_build_function_call_vec): Adjust check_function_arguments caller. testsuite/ * g++.dg/warn/Wrestrict-1.C: New test. * g++.dg/warn/Wrestrict-2.C: New test. --- gcc/c-family/c-common.c.jj 2017-02-20 13:43:15.169555324 +0100 +++ gcc/c-family/c-common.c 2017-02-24 19:44:47.239427073 +0100 @@ -5364,6 +5364,49 @@ check_function_sentinel (const_tree fnty } } +/* Check that the same argument isn't passed to restrict arguments + and other arguments. */ + +static void +check_function_restrict (const_tree fndecl, const_tree fntype, +int nargs, tree *argarray) +{ + int i; + tree parms; + + if (fndecl + && TREE_CODE (fndecl) == FUNCTION_DECL + && DECL_ARGUMENTS (fndecl)) +parms = DECL_ARGUMENTS (fndecl); + else +parms = TYPE_ARG_TYPES (fntype); + + for (i = 0; i < nargs; i++) +TREE_VISITED (argarray[i]) = 0; + + for (i = 0; i < nargs && parms && parms != void_list_node; i++) +{ + tree type; + if (TREE_CODE (parms) == PARM_DECL) + { + type = TREE_TYPE (parms); + parms = DECL_CHAIN (parms); + } + else + { + type = TREE_VALUE (parms); + parms = TREE_CHAIN (parms); + } + if (POINTER_TYPE_P (type) + && TYPE_RESTRICT (type) + && !TYPE_READONLY (TREE_TYPE (type))) + warn_for_restrict (i, argarray, nargs); +} + + for (i = 0; i < nargs; i++) +TREE_VISITED (argarray[i]) = 0; +} + /* Helper for check_function_nonnull; given a list of operands which must be non-null in ARGS, determine if operand PARAM_NUM should be checked. */ @@ -5605,8 +5648,8 @@ attribute_fallthrough_p (tree attr) There are NARGS arguments in the array ARGARRAY. LOC should be used for diagnostics. Return true if -Wnonnull warning has been diagnosed. */ bool -check_function_arguments (location_t loc, const_tree fntype, int nargs, - tree *argarray) +check_function_arguments (location_t loc, const_tree fndecl, const_tree fntype, + int nargs, tree *argarray) { bool warned_p = false; @@ -5624,6 +5667,9 @@ check_function_arguments (location_t loc if (warn_format) check_function_sentinel (fntype, nargs, argarray); + + if (warn_restrict) +check_function_restrict (fndecl, fntype, nargs, argarray); return warned_p; } --- gcc/c-family/c-warn.c.jj2017-02-20 13:43:15.126555893 +0100 +++ gcc/c-family/c-warn.c 2017-02-24 19:39:43.621454404 +0100 @@ -2170,55 +2170,49 @@ maybe_warn_bool_compare (location_t loc, restrict-qualified param, and it aliases with another argument. */ void -warn_for_restrict (unsigned param_pos, vec *args) +warn_for_restrict (unsigned param_pos, tree *argarray, unsigned nargs) { - tree arg = (*args)[param_pos]; - if (TREE_VISITED (arg) || operand_equal_p (arg, null_pointer_node, 0)) + tree arg = argarray[param_pos]; + if (TREE_VISITED (arg) || integer_zerop (arg)) return; location_t loc = EXPR_LOC_OR_LOC (arg, input_location); gcc_rich_location richloc (loc); unsigned i; - tree current_arg; - int *arg_positions = XNEWVEC (int, args->length ()); - unsigned arg_positions_len = 0; + auto_vec arg_positions; - FOR_EACH_VEC_ELT (*args, i, current_arg) + for (i = 0; i < nargs; i++) { if (i == param_pos) continue; - tree current_arg = (*args)[i]; + tree current_arg = argarray[i]; if (operand_equal_p (arg, current_arg, 0)) { TREE_VISITED (current_arg) = 1; - arg_positions[arg_positions_len++] = (i + 1); + arg_positions.safe_push (i + 1); }
Re: [PATCH][x86_64] Enable AVX512 VPOPCNTD/VPOPCNTQ instructions
2017-01-10 13:58 GMT+01:00 Kirill Yukhin: > On 10 Jan 15:00, Andrew Senkevich wrote: >> 2017-01-10 13:31 GMT+03:00 Uros Bizjak : >> > On Tue, Jan 10, 2017 at 11:21 AM, Andrew Senkevich >> > wrote: >> >> 2017-01-10 13:04 GMT+03:00 Kirill Yukhin : >> >>> Hi, >> >>> In addition to Uroš's inputs: >> diff --git a/gcc/config/i386/avx512vpopcntdqintrin.h >> b/gcc/config/i386/avx512vpopcntdqintrin.h >> new file mode 100644 >> index 000..28305f6 >> --- /dev/null >> +++ b/gcc/config/i386/avx512vpopcntdqintrin.h >> @@ -0,0 +1,90 @@ >> +/* Copyright (C) 2016 Free Software Foundation, Inc. >> >>> Pls, fix year. >> >>> >> >>> Pattern should perfectly fit into subst infra. >> >> >> >> Indeed, patch attached. >> >> Changelogs will be fixed accordingly. >> > >> > Patch is OK for mainline. >> >> Thanks! >> >> Attached with updated ChangeLogs. >> Kirill, could you commit please? > Done. > > Also, could you pls implement runtime test cases for new intrinsics. Hi, those tests are attached, are they Ok? ChangLog: gcc/testsuite/ * gcc.target/i386/avx512vpopcntdq-check.h: New. * gcc.target/i386/avx512vpopcntdq-vpopcntd-1.c: Ditto. * gcc.target/i386/avx512vpopcntdq-vpopcntq-1.c: Ditto. * gcc.target/i386/avx512f-helper.h: Add avx512vpopcntdq-check.h. * gcc.target/i386/i386.exp (check_effective_target_avx512vpopcntdq): New. -- WBR, Andrew avx512vpopcntdq_rt_tests.patch Description: Binary data
Re: ARC options documentation questions
Hi, Indeed, we are not up to speed regarding updating and cleaning the documentation. On 12/02/2017 05:18, Sandra Loosemore wrote: I noticed a bunch of copy-editing issues in the "ARC Options" section of invoke.texi. I'm willing to take a stab at fixing them, but I need some technical assistance since I'm not familiar with the details of this architecture myself. * In e.g. "Compile for ARC 600 cpu with norm instruction enabled." is "norm" literally the name of an instruction, GCC implementor jargon, or a term that is used and capitalized like that in the processor documentation? Ditto for "mul32x16", "mul64", "LR", "SR", "mpy", "mac", "mulu64", "swap", "DIV/REM", "MPY", "MPYU", "MPYW", "MPYUW", "MPY_S", "MPYM", "MPYMU". For other targets, literal names of instructions are usually marked up with @code{}, and it would be good to be consistent All those names are additional instructions support which are not available in the base ARC configurations. Indeed, we should be consistent here. * In "FPX: Generate Double Precision FPX instructions", is "Double Precision FPX" a proper name literally capitalized like that, or is this a mistake for "double-precision FPX instructions"? Likewise for "Single Precision FPX"? It is a mistake, we should use lower letters. * In e.g. the discussion of fpuda_div, is "simple precision" a typo for "single precision"? Likewise is "multiple and add" a typo for "multiply and add"? Here are typos. -Sandra Thank you, Claudiu
Re: [PATCH] arc: Fixes for RTL checking
Thank you for ur contribution, Claudiu
Re: C++ PATCH to fix wrong-code with pointer-to-data-members (PR c++/79687)
On Fri, Feb 24, 2017 at 8:22 AM, Marek Polacekwrote: > I had an interesting time tracking down some of the problems with this code. > Hopefully I've sussed out now how this stuff works. > > We've got > > struct A { char c; }; > char A::*p = ::c; > static char A::*const q = p; > and then > &(a.*q) - > which should evaluate to 0. Here "p" will be 0, that's the offset from the > start of the struct to "c". "q" is const-qualified and static and initialized > with "p", so we get to cp_fold_maybe_rvalue -> decl_constant_value -> > constant_value_1. Now, NULL pointer-to-data-members are represented by -1, so > that a null pointer is distinguishable from an offset of the first member of a > struct (0). So constant_value_1 looks at the DECL_INITIAL of "q", which is > -1, > a constant, we fold "q" to -1, and sadness ensues. I believe the -1 value is > only an internal representation and shouldn't be used like that. Since q is initialized from p, it shouldn't have a DECL_INITIAL of -1; that sounds like the bug. Jason
Re: C++ PATCH to make a message translatable (PR translation/79705)
OK. On Fri, Feb 24, 2017 at 7:33 AM, Marek Polacekwrote: > This PR complains that a message is not marked for translation. Also make > the pointer const for the benefit of -Wformat. > > Bootstrapped/regtested on x86_64-linux, ok for trunk? > > 2017-02-24 Marek Polacek > > PR translation/79705 > * decl.c (check_redeclaration_exception_specification): Mark a string > for translation. Make the pointer const. > > diff --git gcc/cp/decl.c gcc/cp/decl.c > index fa1d645..3dd1f5c 100644 > --- gcc/cp/decl.c > +++ gcc/cp/decl.c > @@ -1273,8 +1273,8 @@ check_redeclaration_exception_specification (tree > new_decl, >if (! DECL_IS_BUILTIN (old_decl) >&& !comp_except_specs (new_exceptions, old_exceptions, ce_normal)) > { > - const char *msg > - = "declaration of %qF has a different exception specifier"; > + const char *const msg > + = G_("declaration of %qF has a different exception specifier"); >bool complained = true; >location_t new_loc = DECL_SOURCE_LOCATION (new_decl); >if (DECL_IN_SYSTEM_HEADER (old_decl)) > > Marek
Re: [PATCH, doc]: Mention that -mfpmath=sse is the default on 32bit x86 w/ SSE2 and -ffast-math
On Thu, Feb 23, 2017 at 11:13 PM, Martin Seborwrote: >>> A minor grammatical nit: >>> >>> +This is the default choice for most of x86-32 targets. >>> >>> "for most x86-32 targets" is correct unless the targets are some >>> specific subset, in which case "most of the [previously mentioned] >>> x86-32 targets" would work. >> >> >> Maybe we can say "This is the default choice for non-Darwin x86-32 >> targets." here? >> >> And further extend: >> "This is the default choice for the x86-64 compiler, Darwin x86-32 >> targets, and the default choice for x86-32 targets with SSE2 >> instruction set when @option{-ffast-math} is enabled." > > > The phrasing looks good to me. There should be an article before > SSE2, i.e., "targets with the SSE2 instruction set" Attached is the committed patch. Thanks, Uros. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 6e5fa56..3322281 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -24591,7 +24591,7 @@ The temporary results are computed in 80-bit precision instead of the precision specified by the type, resulting in slightly different results compared to most of other chips. See @option{-ffloat-store} for more detailed description. -This is the default choice for x86-32 targets. +This is the default choice for non-Darwin x86-32 targets. @item sse Use scalar floating-point instructions present in the SSE instruction set. @@ -24611,7 +24611,9 @@ The resulting code should be considerably faster in the majority of cases and av the numerical instability problems of 387 code, but may break some existing code that expects temporaries to be 80 bits. -This is the default choice for the x86-64 compiler. +This is the default choice for the x86-64 compiler, Darwin x86-32 targets, +and the default choice for x86-32 targets with the SSE2 instruction set +when @option{-ffast-math} is enabled. @item sse,387 @itemx sse+387
Re: enable -Wformat-truncation with -Og (PR 79691)
On 02/24/2017 03:10 AM, Richard Biener wrote: On Fri, Feb 24, 2017 at 1:35 AM, Martin Seborwrote: Bug 79691 - -Wformat-truncation suppressed by (and only by) -Og points out that the gimple-ssa-sprintf pass doesn't run when this optimization option is used. That's because I forgot to add it to the set of optimization passes that run with that option. The attached trivial patch tested on x86_64 corrects the oversight. Is this okay for 7.0? Any reason for the placement before copy-prop? I'd have done it after pass_late_warn_uninitialized for example. I wanted to make sure that folded sprintf return values would be eligible for further copy propagation. E.g., that a + b would be folded into a constant: int foo (void) { int a = snprintf (0, 0, "%i", 123); int b = snprintf (0, 0, "%i", 1234); return a + b; } But I could have easily missed some important use case where this placement will compromise the warning. I don't have any tests for this one way or the other so I'm happy to go with your recommendation. Let me know which you think is more appropriate (if you have a suggestion for a test case I'd be grateful). Also doesn't pass_sprintf_length rely on get_range_info ()? With -Og nothing populates those so you'll always get effectively VARYING ranges. It does when it's available but as Jakub noted, it works without it as well (at -O0). Thanks Martin
[PATCH rs6000] Fix PR79544
The following patch fixes the problem of generating a logical shift for vec_sra of an unsigned v2di vector. Bootstrap/regtest on powerpc64le-unknown-linux-gnu with no new regressions. Ok for trunk? Ok for backport to 5/6 branches after testing? -Pat 2017-02-24 Pat HaugenPR target/79544 * rs6000/rs6000-c.c (struct altivec_builtin_types): Use VSRAD for arithmetic shift of unsigned V2DI. testsuite/ChangeLog: 2017-02-24 Pat Haugen * gcc.target/powerpc/pr79544.c: New. Index: config/rs6000/rs6000-c.c === --- config/rs6000/rs6000-c.c (revision 245687) +++ config/rs6000/rs6000-c.c (working copy) @@ -2444,7 +2444,7 @@ const struct altivec_builtin_types altiv RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 }, { ALTIVEC_BUILTIN_VEC_SRA, P8V_BUILTIN_VSRAD, RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_unsigned_V2DI, 0 }, - { ALTIVEC_BUILTIN_VEC_SRA, P8V_BUILTIN_VSRD, + { ALTIVEC_BUILTIN_VEC_SRA, P8V_BUILTIN_VSRAD, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 }, { ALTIVEC_BUILTIN_VEC_VSRAW, ALTIVEC_BUILTIN_VSRAW, RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_unsigned_V4SI, 0 }, @@ -5012,7 +5012,7 @@ const struct altivec_builtin_types altiv { P8V_BUILTIN_VEC_VSRAD, P8V_BUILTIN_VSRAD, RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_unsigned_V2DI, 0 }, - { P8V_BUILTIN_VEC_VSRAD, P8V_BUILTIN_VSRD, + { P8V_BUILTIN_VEC_VSRAD, P8V_BUILTIN_VSRAD, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 }, { P8V_BUILTIN_VEC_VSUBCUQ, P8V_BUILTIN_VSUBCUQ, Index: testsuite/gcc.target/powerpc/pr79544.c === --- testsuite/gcc.target/powerpc/pr79544.c (nonexistent) +++ testsuite/gcc.target/powerpc/pr79544.c (working copy) @@ -0,0 +1,15 @@ +/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-options "-mcpu=power8 -O2" } */ + +#include + +vector unsigned long long +test_sra (vector unsigned long long x, vector unsigned long long y) +{ + return vec_sra (x, y); +} + +/* { dg-final { scan-assembler "vsrad" } } */ +
RE: [PATCH,MIPS] Handle paired single test changes
> -Original Message- > From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches- > ow...@gcc.gnu.org] On Behalf Of Matthew Fortune > Sent: Thursday, February 23, 2017 5:21 PM > To: Moore, Catherine> Cc: 'gcc-patches@gcc.gnu.org' (gcc-patches@gcc.gnu.org) patc...@gcc.gnu.org> > Subject: [PATCH,MIPS] Handle paired single test changes > > Hi Catherine, > > I missed a couple of testsuite changes that are needed to deal with the > fallout of fixing the ABI issues for floating point vectors. I had them > in my tree but forgot to post. The ABI change for V2SF i.e. paired > single is a bug fix as the behaviour was unintended and violates the goal > of having FP64 a compatible ABI extension for o32. The probability of > having code dependent on this corner case of the calling convention in > the wild is exceptionally low so I see no significant risk still. > > The tests for paired single just need a little encouragement to still > produce the necessary instructions now that paired single is not returned > in registers. > > Does it look OK to you? > > Thanks, > Matthew > > gcc/testsuite/ > > * gcc.target/mips/mips-ps-type-2.c (move): Force generation > of mov.ps. > * gcc.target/mips/mips-ps-type.c (move): Likewise. > (cond_move1): Simplify condition to force generation of > mov[nz].ps. > (cond_move2): Likewise. Hi Matthew -- Looks good to me. Catherine
C++ PATCH to fix wrong-code with pointer-to-data-members (PR c++/79687)
I had an interesting time tracking down some of the problems with this code. Hopefully I've sussed out now how this stuff works. We've got struct A { char c; }; char A::*p = ::c; static char A::*const q = p; and then &(a.*q) - which should evaluate to 0. Here "p" will be 0, that's the offset from the start of the struct to "c". "q" is const-qualified and static and initialized with "p", so we get to cp_fold_maybe_rvalue -> decl_constant_value -> constant_value_1. Now, NULL pointer-to-data-members are represented by -1, so that a null pointer is distinguishable from an offset of the first member of a struct (0). So constant_value_1 looks at the DECL_INITIAL of "q", which is -1, a constant, we fold "q" to -1, and sadness ensues. I believe the -1 value is only an internal representation and shouldn't be used like that. Hence my attempt to fix this as below. Anybody see a problem with this approach? My first version just skipped folding TYPE_PTRMEMDATA_P, much like with REFERENCE_TYPEs above, but the problem is just with NULL member pointers, methinks. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2017-02-24 Marek PolacekPR c++/79687 * cp-gimplify.c (cp_fold_maybe_rvalue): Don't fold NULL pointer-to-data-members. * g++.dg/expr/ptrmem8.C: New test. * g++.dg/expr/ptrmem9.C: New test. diff --git gcc/cp/cp-gimplify.c gcc/cp/cp-gimplify.c index 3eec940..6de88af 100644 --- gcc/cp/cp-gimplify.c +++ gcc/cp/cp-gimplify.c @@ -1976,7 +1976,9 @@ cp_fold_maybe_rvalue (tree x, bool rval) && TREE_CODE (TREE_TYPE (x)) != REFERENCE_TYPE) { tree v = decl_constant_value (x); - if (v != x && v != error_mark_node) + if (v != x + && v != error_mark_node + && !null_member_pointer_value_p (v)) { x = v; continue; diff --git gcc/testsuite/g++.dg/expr/ptrmem8.C gcc/testsuite/g++.dg/expr/ptrmem8.C index e69de29..c5a766a 100644 --- gcc/testsuite/g++.dg/expr/ptrmem8.C +++ gcc/testsuite/g++.dg/expr/ptrmem8.C @@ -0,0 +1,15 @@ +// PR c++/79687 +// { dg-do run } + +struct A +{ + char c; +}; + +int main() +{ + char A::* p = ::c; + static char A::* const q = p; + A a; + return &(a.*q) - +} diff --git gcc/testsuite/g++.dg/expr/ptrmem9.C gcc/testsuite/g++.dg/expr/ptrmem9.C index e69de29..32ce777 100644 --- gcc/testsuite/g++.dg/expr/ptrmem9.C +++ gcc/testsuite/g++.dg/expr/ptrmem9.C @@ -0,0 +1,19 @@ +// PR c++/79687 +// { dg-do run } + +struct A +{ + char c; +}; + +int main() +{ + static char A::* p1 = ::c; + char A::* const q1 = p1; + + char A::* p2 = ::c; + static char A::* const q2 = p2; + + A a; + return (&(a.*q1) - ) || (&(a.*q2) - ); +} Marek
RE: [PATCH,MIPS] Document -mload-store-pairs
Moore, Catherinewrites: > > -Original Message- > > From: Matthew Fortune [mailto:matthew.fort...@imgtec.com] > > Sent: Friday, February 24, 2017 8:58 AM > > To: Moore, Catherine > > Cc: 'gcc-patches@gcc.gnu.org' (gcc-patches@gcc.gnu.org) > patc...@gcc.gnu.org> > > Subject: [PATCH,MIPS] Document -mload-store-pairs > > > > Hi Catherine, > > > > Can you review the description for -mload-store-pairs please? > > > > Thanks, > > Matthew > > > > gcc/ > > PR target/79473 > > * doc/invoke.texi: Document -mload-store-pairs. > > > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > > index 6e5fa56..f1fc449 100644 > > --- a/gcc/doc/invoke.texi > > +++ b/gcc/doc/invoke.texi > > @@ -879,6 +879,7 @@ Objective-C and Objective-C++ Dialects}. > > -mexplicit-relocs -mno-explicit-relocs @gol > > -mcheck-zero-division -mno-check-zero-division @gol > > -mdivide-traps -mdivide-breaks @gol > > +-mload-store-pairs -mno-load-store-pairs @gol > > -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol > > -mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused- > > madd -nocpp @gol > > -mfix-24k -mno-fix-24k @gol > > @@ -19495,6 +19496,16 @@ overridden at configure time using > > @option{--with-divide=breaks}. > > Divide-by-zero checks can be completely disabled using > > @option{-mno-check-zero-division}. > > > > +@item -mload-store-pairs > > +@itemx -mno-load-store-pairs > > +@opindex mload-store-pairs > > +@opindex mno-load-store-pairs > > +Enable (disable) an optimization that keeps consecutive load or store > > +instructions sequential to allow MIPS processors that perform load > > +and store bonding to optimize the access. This option is enabled by > > +default but only takes effect when the selected architecture is known > > +to support bonding. > > + > > @item -mmemcpy > > @itemx -mno-memcpy > > @opindex mmemcpy > > -- > > 2.2.1 > > Hi Matthew -- How about this instead? > > +@item -mload-store-pairs > +@itemx -mno-load-store-pairs > +@opindex mload-store-pairs > +@opindex mno-load-store-pairs > +Enable (disable) an optimization that pairs consecutive load or store > +instructions to enable load/store bonding. This option is enabled by > +default but only takes effect when the selected architecture is known > +to support bonding. > + Sure, I'll commit this along with the paired single fix when you've had chance to review. Thanks, Matthew
RE: [PATCH,MIPS] Document -mload-store-pairs
> -Original Message- > From: Matthew Fortune [mailto:matthew.fort...@imgtec.com] > Sent: Friday, February 24, 2017 8:58 AM > To: Moore, Catherine> Cc: 'gcc-patches@gcc.gnu.org' (gcc-patches@gcc.gnu.org) patc...@gcc.gnu.org> > Subject: [PATCH,MIPS] Document -mload-store-pairs > > Hi Catherine, > > Can you review the description for -mload-store-pairs please? > > Thanks, > Matthew > > gcc/ > PR target/79473 > * doc/invoke.texi: Document -mload-store-pairs. > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index 6e5fa56..f1fc449 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -879,6 +879,7 @@ Objective-C and Objective-C++ Dialects}. > -mexplicit-relocs -mno-explicit-relocs @gol > -mcheck-zero-division -mno-check-zero-division @gol > -mdivide-traps -mdivide-breaks @gol > +-mload-store-pairs -mno-load-store-pairs @gol > -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol > -mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused- > madd -nocpp @gol > -mfix-24k -mno-fix-24k @gol > @@ -19495,6 +19496,16 @@ overridden at configure time using > @option{--with-divide=breaks}. > Divide-by-zero checks can be completely disabled using > @option{-mno-check-zero-division}. > > +@item -mload-store-pairs > +@itemx -mno-load-store-pairs > +@opindex mload-store-pairs > +@opindex mno-load-store-pairs > +Enable (disable) an optimization that keeps consecutive load or store > +instructions sequential to allow MIPS processors that perform load > +and store bonding to optimize the access. This option is enabled by > +default but only takes effect when the selected architecture is known > +to support bonding. > + > @item -mmemcpy > @itemx -mno-memcpy > @opindex mmemcpy > -- > 2.2.1 Hi Matthew -- How about this instead? +@item -mload-store-pairs +@itemx -mno-load-store-pairs +@opindex mload-store-pairs +@opindex mno-load-store-pairs +Enable (disable) an optimization that pairs consecutive load or store +instructions to enable load/store bonding. This option is enabled by +default but only takes effect when the selected architecture is known +to support bonding. +
[PATCH][ PR rtl-optimization/79286] Drop may_trap_p exception to testing dominance in update_equiv_regs
Per a discussion with Alan... update_equiv_regs now tests that the insn which creates an equivalence dominates its uses. With one exception, if may_trap_p returns false, we don't require dominance. may_trap_p unfortunately returns false for PIC references in cases where they can clearly trap (as seen with the reduced testcase for this BZ in PIC mode). I'm not really up for pulling on that thread right now. Instead we just drop the may_trap_p exception and always verify dominance. This fixes 79286 when generating PIC (and thus ought to fix the i686 darwin issues. Bootstrapped and regression tested on i686-pc-linux-gnu. Also hand verified the reduced testcase works with PIC. Installing on the trunk. Jeff commit 3a05b44836c9576b33101ed7c381ad21aa5f1581 Author: lawDate: Fri Feb 24 15:36:10 2017 + PR rtl-optimizatoin/79286 * ira.c (update_equiv_regs): Drop may_trap_p exception to dominance test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245714 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 22964c8..1239c4a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-02-24 Jeff Law + + PR rtl-optimizatoin/79286 + * ira.c (update_equiv_regs): Drop may_trap_p exception to + dominance test. + 2017-02-24 Richard Biener PR tree-optimization/79389 diff --git a/gcc/ira.c b/gcc/ira.c index 6fb8aaf..b41c480 100644 --- a/gcc/ira.c +++ b/gcc/ira.c @@ -3551,8 +3551,7 @@ update_equiv_regs (void) if (DF_REG_DEF_COUNT (regno) == 1 && note && !rtx_varies_p (XEXP (note, 0), 0) - && (!may_trap_p (XEXP (note, 0)) - || def_dominates_uses (regno))) + && def_dominates_uses (regno)) { rtx note_value = XEXP (note, 0); remove_note (insn, note);
C++ PATCH to make a message translatable (PR translation/79705)
This PR complains that a message is not marked for translation. Also make the pointer const for the benefit of -Wformat. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2017-02-24 Marek PolacekPR translation/79705 * decl.c (check_redeclaration_exception_specification): Mark a string for translation. Make the pointer const. diff --git gcc/cp/decl.c gcc/cp/decl.c index fa1d645..3dd1f5c 100644 --- gcc/cp/decl.c +++ gcc/cp/decl.c @@ -1273,8 +1273,8 @@ check_redeclaration_exception_specification (tree new_decl, if (! DECL_IS_BUILTIN (old_decl) && !comp_except_specs (new_exceptions, old_exceptions, ce_normal)) { - const char *msg - = "declaration of %qF has a different exception specifier"; + const char *const msg + = G_("declaration of %qF has a different exception specifier"); bool complained = true; location_t new_loc = DECL_SOURCE_LOCATION (new_decl); if (DECL_IN_SYSTEM_HEADER (old_decl)) Marek
[PATCH,MIPS] Document -mload-store-pairs
Hi Catherine, Can you review the description for -mload-store-pairs please? Thanks, Matthew gcc/ PR target/79473 * doc/invoke.texi: Document -mload-store-pairs. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 6e5fa56..f1fc449 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -879,6 +879,7 @@ Objective-C and Objective-C++ Dialects}. -mexplicit-relocs -mno-explicit-relocs @gol -mcheck-zero-division -mno-check-zero-division @gol -mdivide-traps -mdivide-breaks @gol +-mload-store-pairs -mno-load-store-pairs @gol -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol -mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp @gol -mfix-24k -mno-fix-24k @gol @@ -19495,6 +19496,16 @@ overridden at configure time using @option{--with-divide=breaks}. Divide-by-zero checks can be completely disabled using @option{-mno-check-zero-division}. +@item -mload-store-pairs +@itemx -mno-load-store-pairs +@opindex mload-store-pairs +@opindex mno-load-store-pairs +Enable (disable) an optimization that keeps consecutive load or store +instructions sequential to allow MIPS processors that perform load +and store bonding to optimize the access. This option is enabled by +default but only takes effect when the selected architecture is known +to support bonding. + @item -mmemcpy @itemx -mno-memcpy @opindex mmemcpy -- 2.2.1
Re: [PATCH PR69564]Improve vectorizer's runtime alias check for wrapping type
On Fri, Feb 24, 2017 at 11:53 AM, Bin Chengwrote: > Hi, > As analyzed in PR69564, inefficient code for runtime alias check is generated > in benchmark > scimark2. It is suspected vectorized loop doesn't run enough iterations to > cover the loss > of the inefficient code. This patch improves runtime alias check for > (unsigned) wrapping > types. > > Originally, vectorizer checks if below two ranges overlap with each other > range a: [min_a, max_a] ; abs(length_a) = max_a - min_a > range_b: [min_b, max_b] ; abs(length_b) = max_b - min_b > with condition like: > max_a <= min_b || max_b <= min_a > > With knowledge of length of the two ranges, this patch checks overlap with > condition like: > (min_b - min_a) >= abs(len_a) && (min_b - min_a) <= (- abs(len_b)) > It's better because common sub expressions in b/a can be folded. > > Note there is an implicit condition for above statements that length of range > needs to be > no larger than middle value of the unsigned type. This is always true since > object never > spans over half address space in GCC. > > As mentioned, this is only done for case with wrap type and also constant > segment length > for both a and b, which is the most common case. It is possible to improve > signed cases > or compilation time unknown segment length cases too, but may not worth the > effort. > > Unfortunately, test case is hard to create for such code optimization. > Bootstrap and test on x86)64 and AArch64. Is it OK? The patch mixes the above together with better folding (cancelling equal offset, decomposing pointer-plus). Please separate those. Note that seg_len is always positive and the abs(len_N) in the comments doesn't make much sense to me. Meanwhile the simplification (ignoring overflow issues) can go, assuming equal lenghts mina + len <= minb || minb + len <= mina -> mina - minb <= -len || minb - mina <= -len -> minb - mina >= len || mina - minb >= len and as we know len >= 0 this is the same as abs (minb - mina) >= len and thus even simpler than your variant. But maybe I'm missing something? As for the overflow issues, you do all computation in sizetype and thus guarantee unsigned compares, but I think to do these kind of "simplifications" you have to use signed quantities which opens up the possibility of objects crossing the signed-address-space wrapping point and the simplification to break apart. That is, your + tree type = TREE_TYPE (addr_base_a); + if (POINTER_TYPE_P (type)) +type = sizetype; ... + if (!TYPE_UNSIGNED (type) + || !TYPE_OVERFLOW_WRAPS (type) is useless (always false, you always get type == sizetype). Btw, the same overflow issues plague "removal" of common DR_OFFSET and friends iff the original condition, max_a <= min_b || max_b >= min_a is correct - we are using relational compares on pointers to possibly different objects here... (and all pointers are TYPE_UNSIGNED) - and you later interpret those as signed comparisons to be able to shift offsets from one side to the other. So for the "real" check you have to use abs ((ssizetype)(minb - mina)) >= len Thanks, Richard. > Thanks, > bin > > 2017-02-23 Bin Cheng > > PR tree-optimization/69564 > * tree-vect-loop-manip.c (tree-affine.h): Include. > (create_intersect_range_checks): For types with wrap behavior, check > range overlap for [min_a, max_a]/[min_b, max_b] with condition like: > "(min_b - min_a) >= abs(len_a) && (min_b - min_a) <= (-abs(len_b))". >
[PATCH] Fix regressions caused by early debug (DW_OP_GNU_variable_value extension 161109.2; PR debug/77589)
Hi! As mentioned in the PR (and other PRs related to DW_AT_string_length, for which a partial workaround has been committed already), the early debug approach regresses the debug info for VLAs and other dynamic properties of the types; when trying to emit DIEs for such types early, we don't have RTL information for the various artificial temporaries used in TYPE_SIZE_UNIT etc. and those variables don't have a DIE either and the current way of expanding that is that we drop DWARF expressions or location descriptions that need that on the floor. We have some hack to add it to VLA DW_AT_upper_bound, but it doesn't really work too well and can't cover all the various attributes. For DWARF5 DW_AT_string_length now can be newly a reference, which fixes it if we don't need to dereference it, but this PR is about DW_AT_byte_stride where the value of the artificial variable is needed in the middle of a complex expression. Especially when looking forward to GCC 8? LTO debug changes where the type DIEs ought to be imutable after being emitted early, this patch introduces a new DWARF extension (proposed for DWARF5 as http://www.dwarfstd.org/ShowIssue.php?issue=161109.2 but deferred to DWARF6, so we want to implement it as an extension for now and then codify in DWARF6 after getting implementation experience). The extension is DW_OP_GNU_variable_value, a new DWARF expression opcode, which has a single argument - a DIE reference (like DW_OP_call_ref, DW_OP_implicit_pointer or DW_OP_GNU_parameter). The intended behavior is that the debug info consumer computes the value of that referenced variable at the current PC, and if it can compute it and pushes the value as a generic type integer into the DWARF stack (it is really only meaningful when referring to integral/pointer typed variables). It doesn't have to be using DW_AT_location or DW_AT_const_value exactly on the referenced DIE, it can be from other DIE that supplies location for that DIE etc., simply the debugger should use its standard means for computing a value of something, similarly how it handles e.g. reference class (DW_FORM_ref) DW_AT_upper_bound etc. If the value of the variable can't be computed at the current PC (missing DW_AT_location/DW_AT_const_value, or no info for the current PC, whatever), then it is expected that the whole DWARF expression containing DW_OP_GNU_variable_value will be handled as something that can't be computed ( or whatever). The patch is larger than I hoped in order to avoid emitting DW_OP_GNU_variable_value everywhere, even in places where we could emit something equivalent (which of course breaks if the debugger doesn't support the extension). The patch removes some ugly hacks I've added earlier for DW_AT_string_length, and uses DW_OP_GNU_variable_value internally and then attempts to transform it to something else. Initially when it is created, the referenced decl might not have a DIE, so it is created either as a decl reference or die reference depending on lookup_decl_die. Then there is new code at the end of dwarf2out_early_finish, which looks for all DW_OP_GNU_variable_value which are still decl references and don't have corresponding dies (this is note_variable_value{,_in_expr}). For GCC8 and -flto, the intent is to create DIEs for the artificial temporaries here, otherwise we just note it in a hash table. Another step (resolve_variable_value{s,,_in_expr}) is during gen_subprogram_die during emitting assembly for a function, here we use the above prepared hash table and try to do something about all DW_OP_GNU_variable_value pointing to temporaries in the current function. Here we do have RTL for the current function, so can use loc_list_from_tree and can in certain cases (especially if it returns a single location list) replace the DW_OP_GNU_variable_value with DWARF expression computing that value. For attributes that support both exprloc and loclist classes like DW_AT_location, we can also replace a DW_FORM_exprloc with a loclist, and there is also an option to create a DIE for the artificial temporary under the current DW_TAG_subprogram. And finally there is another step during resolve_addr during dwarf2out_finish, where we optimize DW_AT_string_length (slightly adjusted from earlier, because that was adjustment for the often invalid DW_OP_call4 + optional DW_OP_deref*, while now we optimize DW_OP_GNU_variable_value + optional DW_OP_stack_value; and it now also allows for -gdwarf-5 to use DW_FORM_ref), where we also try to look up referenced DIE again, transform it for certain dynamic attributes that accept both exprloc and reference from exprloc of DW_OP_GNU_variable to just reference and for -gstrict-dwarf drop DW_OP_GNU_variable together with whole expression if we couldn't transform it to something strict DWARF compliant. For the Fortran testcase in the PR, DW_OP_GNU_variable is what remains in the debug info, so for that we'll need corresponding debugger changes. Bootstrapped/regtested successfully
[PATCH] Fix PR79690
The following fixes PR79690. Bootstrap and regtest running on x86_64-unknown-linux-gnu. Richard. 2017-02-24 Richard BienerPR tree-optimization/79690 * tree-vect-stmts.c (vectorizable_store): Use vector type built from the DR with address-space. * gcc.target/i386/pr79690.c: New testcase. Index: gcc/tree-vect-stmts.c === --- gcc/tree-vect-stmts.c (revision 245712) +++ gcc/tree-vect-stmts.c (working copy) @@ -6324,7 +6324,7 @@ vectorizable_store (gimple *stmt, gimple vect_permute_store_chain(). */ vec_oprnd = result_chain[i]; - data_ref = fold_build2 (MEM_REF, TREE_TYPE (vec_oprnd), + data_ref = fold_build2 (MEM_REF, vectype, dataref_ptr, dataref_offset ? dataref_offset Index: gcc/testsuite/gcc.target/i386/pr79690.c === --- gcc/testsuite/gcc.target/i386/pr79690.c (nonexistent) +++ gcc/testsuite/gcc.target/i386/pr79690.c (working copy) @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -msse2 -mno-avx" } */ + +void fill(unsigned char __seg_gs *arr, unsigned char c, long n) +{ + for (long i = 0; i < n; ++i) +arr[i] = c; +} + +/* { dg-final { scan-assembler "mov\[au\]p.\[ \t\]\[^,\]+, %gs:" } } */
RE: [PATCH,testsuite] Use logical_op_short_circuit to skip targets in ssa-thread-14.c.
> From: Jeff Law > > I don't think using !logical_op_short_circuit is too heavy handed here. > > We get good coverage from the x86 target, so I don't mind losing > coverage from avr/s390 as the target selector is a lot more likely to be > correct after your change for the various targets now and in the future. > > OK for the trunk. > > Thanks, > > jeff > Thank you for the prompt review. Committed as r245711. Regards, Toma
[Ada] Add another check for SSO compatibility
When removing the wrapper around a justified modular type used to implement a packed array type. This shouldn't make any difference because the front-end is supposed to filter out this case so it's for the sake of robustness. Tested on x86_64-suse-linux, applied on mainline and 6 branch. 2017-02-24 Eric Botcazou* gcc-interface/decl.c (gnat_to_gnu_field): Do not remove the wrapper around a justified modular type if it doesn't have the same scalar storage order as the enclosing record type. -- Eric Botcazou Index: gcc-interface/decl.c === --- gcc-interface/decl.c (revision 245700) +++ gcc-interface/decl.c (working copy) @@ -7031,6 +7031,7 @@ static tree gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, bool definition, bool debug_info_p) { + const Entity_Id gnat_record_type = Underlying_Type (Scope (gnat_field)); const Entity_Id gnat_field_type = Etype (gnat_field); const bool is_aliased = Is_Aliased (gnat_field); @@ -7117,8 +7118,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, if (Present (Component_Clause (gnat_field))) { Node_Id gnat_clause = Component_Clause (gnat_field); - Entity_Id gnat_parent - = Parent_Subtype (Underlying_Type (Scope (gnat_field))); + Entity_Id gnat_parent = Parent_Subtype (gnat_record_type); gnu_pos = UI_To_gnu (Component_Bit_Offset (gnat_field), bitsizetype); gnu_size = validate_size (Esize (gnat_field), gnu_field_type, @@ -7237,7 +7237,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, /* If the record has rep clauses and this is the tag field, make a rep clause for it as well. */ - else if (Has_Specified_Layout (Scope (gnat_field)) + else if (Has_Specified_Layout (gnat_record_type) && Chars (gnat_field) == Name_uTag) { gnu_pos = bitsize_zero_node; @@ -7274,11 +7274,14 @@ gnat_to_gnu_field (Entity_Id gnat_field, /* If the field's type is justified modular, we would need to remove the wrapper to (better) meet the layout requirements. However we can do so only if the field is not aliased to preserve the unique - layout and if the prescribed size is not greater than that of the - packed array to preserve the justification. */ + layout, if it has the same storage order as the enclosing record + and if the prescribed size is not greater than that of the packed + array to preserve the justification. */ if (!needs_strict_alignment && TREE_CODE (gnu_field_type) == RECORD_TYPE && TYPE_JUSTIFIED_MODULAR_P (gnu_field_type) + && TYPE_REVERSE_STORAGE_ORDER (gnu_field_type) + == Reverse_Storage_Order (gnat_record_type) && tree_int_cst_compare (gnu_size, TYPE_ADA_SIZE (gnu_field_type)) <= 0) gnu_field_type = TREE_TYPE (TYPE_FIELDS (gnu_field_type));
[committed] fix a few typos in tree-ssa-loop-niter.c
Found this while working on a PR. Committed as obvious. gcc/ * tree-ssa-loop-niter.c (number_of_iterations_exit): Update function comment to reflect reality. (loop_exits_before_overflow): Fix typo in function description. diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index efcf3ed..269a2ba 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -2345,8 +2345,8 @@ number_of_iterations_exit_assumptions (struct loop *loop, edge exit, return (!integer_zerop (niter->assumptions)); } -/* Like number_of_iterations_exit, but return TRUE only if the niter - information holds unconditionally. */ +/* Like number_of_iterations_exit_assumptions, but return TRUE only if + the niter information holds unconditionally. */ bool number_of_iterations_exit (struct loop *loop, edge exit, @@ -4194,7 +4194,7 @@ nowrap_type_p (tree type) } /* Return true if we can prove LOOP is exited before evolution of induction - variabled {BASE, STEP} overflows with respect to its type bound. */ + variable {BASE, STEP} overflows with respect to its type bound. */ static bool loop_exits_before_overflow (tree base, tree step,
[PATCH PR69564]Improve vectorizer's runtime alias check for wrapping type
Hi, As analyzed in PR69564, inefficient code for runtime alias check is generated in benchmark scimark2. It is suspected vectorized loop doesn't run enough iterations to cover the loss of the inefficient code. This patch improves runtime alias check for (unsigned) wrapping types. Originally, vectorizer checks if below two ranges overlap with each other range a: [min_a, max_a] ; abs(length_a) = max_a - min_a range_b: [min_b, max_b] ; abs(length_b) = max_b - min_b with condition like: max_a <= min_b || max_b <= min_a With knowledge of length of the two ranges, this patch checks overlap with condition like: (min_b - min_a) >= abs(len_a) && (min_b - min_a) <= (- abs(len_b)) It's better because common sub expressions in b/a can be folded. Note there is an implicit condition for above statements that length of range needs to be no larger than middle value of the unsigned type. This is always true since object never spans over half address space in GCC. As mentioned, this is only done for case with wrap type and also constant segment length for both a and b, which is the most common case. It is possible to improve signed cases or compilation time unknown segment length cases too, but may not worth the effort. Unfortunately, test case is hard to create for such code optimization. Bootstrap and test on x86)64 and AArch64. Is it OK? Thanks, bin 2017-02-23 Bin ChengPR tree-optimization/69564 * tree-vect-loop-manip.c (tree-affine.h): Include. (create_intersect_range_checks): For types with wrap behavior, check range overlap for [min_a, max_a]/[min_b, max_b] with condition like: "(min_b - min_a) >= abs(len_a) && (min_b - min_a) <= (-abs(len_b))". diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c index 5ee2c38..c787bbb 100644 --- a/gcc/tree-vect-loop-manip.c +++ b/gcc/tree-vect-loop-manip.c @@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-into-ssa.h" #include "tree-ssa.h" #include "cfgloop.h" +#include "tree-affine.h" #include "tree-scalar-evolution.h" #include "tree-vectorizer.h" #include "tree-ssa-loop-ivopts.h" @@ -2181,43 +2182,137 @@ create_intersect_range_checks (loop_vec_info loop_vinfo, tree *cond_expr, if (create_intersect_range_checks_index (loop_vinfo, cond_expr, dr_a, dr_b)) return; - tree segment_length_a = dr_a.seg_len; - tree segment_length_b = dr_b.seg_len; + tree seg_len_a = dr_a.seg_len; + tree seg_len_b = dr_b.seg_len; tree addr_base_a = DR_BASE_ADDRESS (dr_a.dr); tree addr_base_b = DR_BASE_ADDRESS (dr_b.dr); tree offset_a = DR_OFFSET (dr_a.dr), offset_b = DR_OFFSET (dr_b.dr); + tree init_a = DR_INIT (dr_a.dr), init_b = DR_INIT (dr_b.dr); + + tree type = TREE_TYPE (addr_base_a); + if (POINTER_TYPE_P (type)) +type = sizetype; + + seg_len_a = fold_convert (type, seg_len_a); + seg_len_b = fold_convert (type, seg_len_b); + offset_a = fold_convert (type, offset_a); + offset_b = fold_convert (type, offset_b); + init_a = fold_convert (type, init_a); + init_b = fold_convert (type, init_b); + /* Check if offset and init can be cancelled. */ + if (operand_equal_p (offset_a, offset_b, 0)) +{ + offset_a = fold_convert (type, integer_zero_node); + offset_b = fold_convert (type, integer_zero_node); +} + if (operand_equal_p (init_a, init_b, 0)) +{ + init_a = fold_convert (type, integer_zero_node); + init_b = fold_convert (type, integer_zero_node); +} + + offset_a = fold_build2 (PLUS_EXPR, type, offset_a, init_a); + offset_b = fold_build2 (PLUS_EXPR, type, offset_b, init_b); - offset_a = fold_build2 (PLUS_EXPR, TREE_TYPE (offset_a), - offset_a, DR_INIT (dr_a.dr)); - offset_b = fold_build2 (PLUS_EXPR, TREE_TYPE (offset_b), - offset_b, DR_INIT (dr_b.dr)); - addr_base_a = fold_build_pointer_plus (addr_base_a, offset_a); - addr_base_b = fold_build_pointer_plus (addr_base_b, offset_b); + /* Further decompose pointer plus expression. */ + if (TREE_CODE (addr_base_a) == POINTER_PLUS_EXPR) +{ + tree offset = fold_convert (type, TREE_OPERAND (addr_base_a, 1)); + offset_a = fold_build2 (PLUS_EXPR, type, offset_a, offset); + addr_base_a = TREE_OPERAND (addr_base_a, 0); +} + if (TREE_CODE (addr_base_b) == POINTER_PLUS_EXPR) +{ + tree offset = fold_convert (type, TREE_OPERAND (addr_base_b, 1)); + offset_b = fold_build2 (PLUS_EXPR, type, offset_b, offset); + addr_base_b = TREE_OPERAND (addr_base_b, 0); +} + addr_base_a = fold_convert (type, addr_base_a); + addr_base_a = fold_build2 (PLUS_EXPR, type, addr_base_a, offset_a); + addr_base_b = fold_convert (type, addr_base_b); + addr_base_b = fold_build2 (PLUS_EXPR, type, addr_base_b, offset_b); - tree seg_a_min = addr_base_a; - tree seg_a_max = fold_build_pointer_plus (addr_base_a, segment_length_a); + tree min_a = addr_base_a; +
[Ada] Fix wrong debug info for variant record
This is a regression present on the mainline and 6 branch whereby the compiler generates an incorrect GNAT encoding in the debug info for a variant record. Tested on x86_64-suse-linux, applied on mainline and 6 branch. 2017-02-24 Eric Botcazou* gcc-interface/utils.c (fold_bit_position): New function. (rest_of_record_type_compilation): Call it instead of bit_position to compute the field position and remove the call to remove_conversions. (compute_related_constant): Factor out the multiplication in both operands, if any, and streamline the final test. -- Eric Botcazou Index: gcc-interface/utils.c === --- gcc-interface/utils.c (revision 245698) +++ gcc-interface/utils.c (working copy) @@ -238,6 +238,7 @@ static GTY ((cache)) hash_table *pad_type_hash_table; static tree merge_sizes (tree, tree, tree, bool, bool); +static tree fold_bit_position (const_tree); static tree compute_related_constant (tree, tree); static tree split_plus (tree, tree *); static tree float_type_for_precision (int, machine_mode); @@ -2041,15 +2042,11 @@ rest_of_record_type_compilation (tree re { tree field_type = TREE_TYPE (old_field); tree field_name = DECL_NAME (old_field); - tree curpos = bit_position (old_field); + tree curpos = fold_bit_position (old_field); tree pos, new_field; bool var = false; unsigned int align = 0; - /* We're going to do some pattern matching below so remove as many - conversions as possible. */ - curpos = remove_conversions (curpos, true); - /* See how the position was modified from the last position. There are two basic cases we support: a value was added @@ -2146,7 +2143,7 @@ rest_of_record_type_compilation (tree re is when there are other components at fixed positions after it (meaning there was a rep clause for every field) and we want to be able to encode them. */ - last_pos = size_binop (PLUS_EXPR, bit_position (old_field), + last_pos = size_binop (PLUS_EXPR, curpos, (TREE_CODE (TREE_TYPE (old_field)) == QUAL_UNION_TYPE) ? bitsize_zero_node @@ -2201,23 +2198,51 @@ merge_sizes (tree last_size, tree first_ return new_size; } +/* Return the bit position of FIELD, in bits from the start of the record, + and fold it as much as possible. This is a tree of type bitsizetype. */ + +static tree +fold_bit_position (const_tree field) +{ + tree offset = DECL_FIELD_OFFSET (field); + if (TREE_CODE (offset) == MULT_EXPR || TREE_CODE (offset) == PLUS_EXPR) +offset = size_binop (TREE_CODE (offset), + fold_convert (bitsizetype, TREE_OPERAND (offset, 0)), + fold_convert (bitsizetype, TREE_OPERAND (offset, 1))); + else +offset = fold_convert (bitsizetype, offset); + return size_binop (PLUS_EXPR, DECL_FIELD_BIT_OFFSET (field), + size_binop (MULT_EXPR, offset, bitsize_unit_node)); +} + /* Utility function of above to see if OP0 and OP1, both of SIZETYPE, are related by the addition of a constant. Return that constant if so. */ static tree compute_related_constant (tree op0, tree op1) { - tree op0_var, op1_var; - tree op0_con = split_plus (op0, _var); - tree op1_con = split_plus (op1, _var); - tree result = size_binop (MINUS_EXPR, op0_con, op1_con); + tree factor, op0_var, op1_var, op0_cst, op1_cst, result; - if (operand_equal_p (op0_var, op1_var, 0)) -return result; - else if (operand_equal_p (op0, size_binop (PLUS_EXPR, op1_var, result), 0)) -return result; + if (TREE_CODE (op0) == MULT_EXPR + && TREE_CODE (op1) == MULT_EXPR + && TREE_CODE (TREE_OPERAND (op0, 1)) == INTEGER_CST + && TREE_OPERAND (op1, 1) == TREE_OPERAND (op0, 1)) +{ + factor = TREE_OPERAND (op0, 1); + op0 = TREE_OPERAND (op0, 0); + op1 = TREE_OPERAND (op1, 0); +} else -return 0; +factor = NULL_TREE; + + op0_cst = split_plus (op0, _var); + op1_cst = split_plus (op1, _var); + result = size_binop (MINUS_EXPR, op0_cst, op1_cst); + + if (operand_equal_p (op0_var, op1_var, 0)) +return factor ? size_binop (MULT_EXPR, factor, result) : result; + + return NULL_TREE; } /* Utility function of above to split a tree OP which may be a sum, into a
[Ada] Fix segfault in NRV on pathological case
This is a regression present on all active branches where the NRV pass implemented in gigi segfaults on a pathological case. Tested on x86_64-suse-linux, applied on all active branches. 2017-02-24 Eric Botcazou* gcc-interface/trans.c (return_value_ok_for_nrv_p): Add sanity check 2017-02-24 Eric Botcazou * gnat.dg/opt63.adb: New test. -- Eric Botcazou Index: gcc-interface/trans.c === --- gcc-interface/trans.c (revision 245699) +++ gcc-interface/trans.c (working copy) @@ -3614,9 +3614,16 @@ return_value_ok_for_nrv_p (tree ret_obj, if (TREE_ADDRESSABLE (ret_val)) return false; + /* For the constrained case, test for overalignment. */ if (ret_obj && DECL_ALIGN (ret_val) > DECL_ALIGN (ret_obj)) return false; + /* For the unconstrained case, test for bogus initialization. */ + if (!ret_obj + && DECL_INITIAL (ret_val) + && TREE_CODE (DECL_INITIAL (ret_val)) == NULL_EXPR) +return false; + return true; } -- { dg-do compile } -- { dg-options "-O -gnatws" } procedure Opt63 is type T_MOD is mod 2**32; subtype T_INDEX is T_MOD range 3_000_000_000 .. 4_000_000_000; type T_ARRAY is array(T_INDEX range <>) of INTEGER; function Build_Crash(First : T_INDEX; Length : NATURAL) return T_ARRAY is R : T_ARRAY(First .. T_Index'Val (T_Index'Pos (First) + Length)) := (others => -1); -- Crash here begin return R; end; begin null; end;
[PATCH] Fix PR45397
The following fixes the missing staturating op pattern detection by teaching FRE to CSE a narrower (or sign-changed) add/sub/mul with a wider one and compensating with a cast (for sign-changing) or a bit-and (for narrowing and zero-extending). This is a bit awkward (and it doesn't handle all of the testcases that queued up in the comments of PR45397) but apart from doing even more complicated pattern matching inside phiopt I don't see a good way of dealing with this. I didn't try to address the non-regression testcases, but the code can serve as a recipie for adding more "hacks" as needed. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Ok? Thanks, Richard. 2017-02-24 Richard BienerPR tree-optimization/45397 * tree-ssa-pre.c (eliminate_insert): Handle BIT_AND_EXPR. * tree-ssa-sccvn.c (valueized_wider_op): New helper. (visit_nary_op): Add pattern matching for CSEing sign-changed or truncated operations with wider ones. * gcc.dg/tree-ssa/pr45397.c: New testcase. Index: gcc/tree-ssa-pre.c === *** gcc/tree-ssa-pre.c (revision 245696) --- gcc/tree-ssa-pre.c (working copy) *** eliminate_insert (gimple_stmt_iterator * *** 4103,4109 if (!is_gimple_assign (stmt) || (!CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt)) && gimple_assign_rhs_code (stmt) != VIEW_CONVERT_EXPR ! && gimple_assign_rhs_code (stmt) != BIT_FIELD_REF)) return NULL_TREE; tree op = gimple_assign_rhs1 (stmt); --- 4103,4111 if (!is_gimple_assign (stmt) || (!CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt)) && gimple_assign_rhs_code (stmt) != VIEW_CONVERT_EXPR ! && gimple_assign_rhs_code (stmt) != BIT_FIELD_REF ! && (gimple_assign_rhs_code (stmt) != BIT_AND_EXPR ! || TREE_CODE (gimple_assign_rhs2 (stmt)) != INTEGER_CST))) return NULL_TREE; tree op = gimple_assign_rhs1 (stmt); *** eliminate_insert (gimple_stmt_iterator * *** 4121,4126 --- 4123,4131 TREE_TYPE (val), leader, TREE_OPERAND (gimple_assign_rhs1 (stmt), 1), TREE_OPERAND (gimple_assign_rhs1 (stmt), 2)); + else if (gimple_assign_rhs_code (stmt) == BIT_AND_EXPR) + res = gimple_build (, BIT_AND_EXPR, + TREE_TYPE (val), leader, gimple_assign_rhs2 (stmt)); else res = gimple_build (, gimple_assign_rhs_code (stmt), TREE_TYPE (val), leader); Index: gcc/tree-ssa-sccvn.c === *** gcc/tree-ssa-sccvn.c(revision 245696) --- gcc/tree-ssa-sccvn.c(working copy) *** visit_copy (tree lhs, tree rhs) *** 3447,3469 return set_ssa_val_to (lhs, rhs); } /* Visit a nary operator RHS, value number it, and return true if the value number of LHS has changed as a result. */ static bool ! visit_nary_op (tree lhs, gimple *stmt) { - bool changed = false; tree result = vn_nary_op_lookup_stmt (stmt, NULL); - if (result) ! changed = set_ssa_val_to (lhs, result); ! else { ! changed = set_ssa_val_to (lhs, lhs); ! vn_nary_op_insert_stmt (stmt, lhs); } return changed; } --- 3447,3571 return set_ssa_val_to (lhs, rhs); } + /* Lookup a value for OP in type WIDE_TYPE where the value in type of OP +is the same. */ + + static tree + valueized_wider_op (tree wide_type, tree op) + { + if (TREE_CODE (op) == SSA_NAME) + op = SSA_VAL (op); + + /* Either we have the op widened available. */ + tree ops[3] = {}; + ops[0] = op; + tree tem = vn_nary_op_lookup_pieces (1, NOP_EXPR, + wide_type, ops, NULL); + if (tem) + return tem; + + /* Or the op is truncated from some existing value. */ + if (TREE_CODE (op) == SSA_NAME) + { + gimple *def = SSA_NAME_DEF_STMT (op); + if (is_gimple_assign (def) + && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def))) + { + tem = gimple_assign_rhs1 (def); + if (useless_type_conversion_p (wide_type, TREE_TYPE (tem))) + { + if (TREE_CODE (tem) == SSA_NAME) + tem = SSA_VAL (tem); + return tem; + } + } + } + + /* For constants simply extend it. */ + if (TREE_CODE (op) == INTEGER_CST) + return wide_int_to_tree (wide_type, op); + + return NULL_TREE; + } + /* Visit a nary operator RHS, value number it, and return true if the value number of LHS has changed as a result. */ static bool ! visit_nary_op (tree lhs, gassign *stmt) { tree result = vn_nary_op_lookup_stmt (stmt, NULL); if (result) ! return set_ssa_val_to (lhs, result); ! ! /* Do some special pattern matching for
Re: [PATCH] PR79389, path-splitting
On Thu, 23 Feb 2017, Richard Biener wrote: > > This PR shows another defect in path-splittings cost model which the > following patch tries to improve further. > > Bootstrap and regtest running on x86_64-unknown-linux-gnu. It has been pointed out this causes compare-debug issues. Whoops. Fixed as follows, bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2017-02-24 Richard BienerPR tree-optimization/79389 * gimple-ssa-split-paths.c (is_feasible_trace): Properly skip debug insns. Index: gcc/gimple-ssa-split-paths.c === --- gcc/gimple-ssa-split-paths.c(revision 245696) +++ gcc/gimple-ssa-split-paths.c(working copy) @@ -249,6 +249,8 @@ is_feasible_trace (basic_block bb) imm_use_iterator iter2; FOR_EACH_IMM_USE_FAST (use2_p, iter2, gimple_phi_result (stmt)) { + if (is_gimple_debug (USE_STMT (use2_p))) + continue; basic_block use_bb = gimple_bb (USE_STMT (use2_p)); if (use_bb != bb && dominated_by_p (CDI_DOMINATORS, bb, use_bb)) @@ -280,11 +282,15 @@ is_feasible_trace (basic_block bb) use_operand_p use_p; imm_use_iterator iter; FOR_EACH_IMM_USE_FAST (use_p, iter, op) - if (gimple_bb (USE_STMT (use_p)) == bb) - { - found_cprop_opportunity = true; - break; - } + { + if (is_gimple_debug (USE_STMT (use_p))) + continue; + if (gimple_bb (USE_STMT (use_p)) == bb) + { + found_cprop_opportunity = true; + break; + } + } } if (found_cprop_opportunity) break;
[Ada] Fix calling convention mistmatch with C++ on Windows
This is a long-standing regression present on 32-bit Windows when you try to interface a C++ class which contains both virtual and non-virtual methods. In both cases the C++ side uses the 'thiscall' calling convention, whereas the Ada side only uses it for the former methods in this case. Tested on x86_64-suse-linux and i686-pc-mingw32, applied on the mainline. 2017-02-24 Eric Botcazouc-family/ * c-ada-spec.c (dump_ada_function_declaration): Add comment about the treatment of parameters with pointer-to-tagged type and tidy up. (print_ada_methods): Remove the special treatment of C++ staticmember functions. ada/ * gcc-interface/decl.c: Include demangle.h. (is_cplusplus_method): Return again true for a primitive operation only if it is dispatching. For a subprogram with an interface name, call the demangler to get the number of C++ parameters and compare it with the number of Ada parameters. -- Eric BotcazouIndex: ada/gcc-interface/decl.c === --- ada/gcc-interface/decl.c (revision 245625) +++ ada/gcc-interface/decl.c (working copy) @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2016, Free Software Foundation, Inc. * + * Copyright (C) 1992-2017, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -34,6 +34,7 @@ #include "fold-const.h" #include "stor-layout.h" #include "tree-inline.h" +#include "demangle.h" #include "ada.h" #include "types.h" @@ -5093,10 +5094,6 @@ get_unpadded_type (Entity_Id gnat_entity bool is_cplusplus_method (Entity_Id gnat_entity) { - /* Check that the subprogram has C++ convention. */ - if (Convention (gnat_entity) != Convention_CPP) -return false; - /* A constructor is a method on the C++ side. We deal with it now because it is declared without the 'this' parameter in the sources and, although the front-end will create a version with the 'this' parameter for code @@ -5104,6 +5101,10 @@ is_cplusplus_method (Entity_Id gnat_enti if (Is_Constructor (gnat_entity)) return true; + /* Check that the subprogram has C++ convention. */ + if (Convention (gnat_entity) != Convention_CPP) +return false; + /* And that the type of the first parameter (indirectly) has it too. */ Entity_Id gnat_first = First_Formal (gnat_entity); if (No (gnat_first)) @@ -5115,19 +5116,75 @@ is_cplusplus_method (Entity_Id gnat_enti if (Convention (gnat_type) != Convention_CPP) return false; - /* This is the main case: C++ method imported as a primitive operation. - Note that a C++ class with no virtual functions can be imported as a - limited record type so the operation is not necessarily dispatching. */ - if (Is_Primitive (gnat_entity)) + /* This is the main case: a C++ virtual method imported as a primitive + operation of a tagged type. */ + if (Is_Dispatching_Operation (gnat_entity)) +return true; + + /* This is set on the E_Subprogram_Type built for a dispatching call. */ + if (Is_Dispatch_Table_Entity (gnat_entity)) return true; /* A thunk needs to be handled like its associated primitive operation. */ if (Is_Subprogram (gnat_entity) && Is_Thunk (gnat_entity)) return true; - /* This is set on the E_Subprogram_Type built for a dispatching call. */ - if (Is_Dispatch_Table_Entity (gnat_entity)) -return true; + /* Now on to the annoying case: a C++ non-virtual method, imported either + as a non-primitive operation of a tagged type or as a primitive operation + of an untagged type. We cannot reliably differentiate these cases from + their static member or regular function equivalents in Ada, so we ask + the C++ side through the mangled name of the function, as the implicit + 'this' parameter is not encoded in the mangled name of a method. */ + if (Is_Subprogram (gnat_entity) && Present (Interface_Name (gnat_entity))) +{ + String_Pointer sp = { NULL, NULL }; + Get_External_Name (gnat_entity, false, sp); + + void *mem; + struct demangle_component *cmp + = cplus_demangle_v3_components (Name_Buffer, + DMGL_GNU_V3 + | DMGL_TYPES + | DMGL_PARAMS + | DMGL_RET_DROP, + ); + if (!cmp) + return false; + + /* We need to release MEM once we have a successful demangling. */ + bool ret = false; + + if (cmp->type == DEMANGLE_COMPONENT_TYPED_NAME + && cmp->u.s_binary.right->type ==
Re: enable -Wformat-truncation with -Og (PR 79691)
On Fri, Feb 24, 2017 at 11:10:51AM +0100, Richard Biener wrote: > On Fri, Feb 24, 2017 at 1:35 AM, Martin Seborwrote: > > Bug 79691 - -Wformat-truncation suppressed by (and only by) -Og > > points out that the gimple-ssa-sprintf pass doesn't run when > > this optimization option is used. That's because I forgot to > > add it to the set of optimization passes that run with that > > option. The attached trivial patch tested on x86_64 corrects > > the oversight. > > > > Is this okay for 7.0? > > Any reason for the placement before copy-prop? I'd have done it > after pass_late_warn_uninitialized for example. > > Also doesn't pass_sprintf_length rely on get_range_info ()? With -Og > nothing populates those so you'll always get effectively VARYING ranges. -O0 and -O1 are the same case with that though. Jakub
Re: enable -Wformat-truncation with -Og (PR 79691)
On Fri, Feb 24, 2017 at 1:35 AM, Martin Seborwrote: > Bug 79691 - -Wformat-truncation suppressed by (and only by) -Og > points out that the gimple-ssa-sprintf pass doesn't run when > this optimization option is used. That's because I forgot to > add it to the set of optimization passes that run with that > option. The attached trivial patch tested on x86_64 corrects > the oversight. > > Is this okay for 7.0? Any reason for the placement before copy-prop? I'd have done it after pass_late_warn_uninitialized for example. Also doesn't pass_sprintf_length rely on get_range_info ()? With -Og nothing populates those so you'll always get effectively VARYING ranges. Richard. > Martin
[Ada] Fix back-and-forth issue in debugger
This is a small regression present on the mainline: under some circumstances, the debugger may go back and forth when stepping over a call, if the arguments contain string concatenations. Tested on x86_64-suse-linux, applied on the mainline. 2017-02-24 Eric Botcazou* gcc-interface/trans.c (Handled_Sequence_Of_Statements_to_gnu): If there is no end label, put the location of the At_End procedure on the call to the procedure. -- Eric Botcazo Index: gcc-interface/trans.c === --- gcc-interface/trans.c (revision 245625) +++ gcc-interface/trans.c (working copy) @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2016, Free Software Foundation, Inc. * + * Copyright (C) 1992-2017, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -4965,10 +4965,6 @@ Handled_Sequence_Of_Statements_to_gnu (N tree gnu_result; tree gnu_expr; Node_Id gnat_temp; - /* Node providing the sloc for the cleanup actions. */ - Node_Id gnat_cleanup_loc_node = (Present (End_Label (gnat_node)) ? - End_Label (gnat_node) : - gnat_node); /* The GCC exception handling mechanism can handle both ZCX and SJLJ schemes and we have our own SJLJ mechanism. To call the GCC mechanism, we call @@ -5018,7 +5014,8 @@ Handled_Sequence_Of_Statements_to_gnu (N /* When we exit this block, restore the saved value. */ add_cleanup (build_call_n_expr (set_jmpbuf_decl, 1, gnu_jmpsave_decl), - gnat_cleanup_loc_node); + Present (End_Label (gnat_node)) + ? End_Label (gnat_node) : gnat_node); } /* If we are to call a function when exiting this block, add a cleanup @@ -5027,11 +5024,18 @@ Handled_Sequence_Of_Statements_to_gnu (N if (at_end) { tree proc_decl = gnat_to_gnu (At_End_Proc (gnat_node)); + /* When not optimizing, disable inlining of finalizers as this can create a more complex CFG in the parent function. */ if (!optimize) DECL_DECLARED_INLINE_P (proc_decl) = 0; - add_cleanup (build_call_n_expr (proc_decl, 0), gnat_cleanup_loc_node); + + /* If there is no end label attached, we use the location of the At_End + procedure because Expand_Cleanup_Actions might reset the location of + the enclosing construct to that of an inner statement. */ + add_cleanup (build_call_n_expr (proc_decl, 0), + Present (End_Label (gnat_node)) + ? End_Label (gnat_node) : At_End_Proc (gnat_node)); } /* Now build the tree for the declarations and statements inside this block.
Re: fwprop fix for PR79405
On Thu, Feb 23, 2017 at 11:17 PM, Jeff Lawwrote: > On 02/23/2017 01:57 AM, Richard Biener wrote: >> >> On Wed, Feb 22, 2017 at 6:19 PM, Jeff Law wrote: >>> >>> On 02/16/2017 12:41 PM, Bernd Schmidt wrote: We have two registers being assigned to each other: (set (reg 213) (reg 209)) (set (reg 209) (reg 213)) These being the only definitions, we are happy to forward propagate reg 209 for reg 213 into a third insn, making a new use for reg 209. We are then happy to forward propagate reg 213 for it in the same insn... ending up in an infinite loop. I don't really see an elegant way to prevent this, so the following just tries to detect the situation (and more general ones) by brute force. Bootstrapped and tested on x86_64-linux, verified that the test passes with a ppc cross, ok? Bernd 79405.diff PR rtl-optimization/79405 * fwprop.c (forward_propagate_into): Detect potentially cyclic replacements and bail out for them. PR rtl-optimization/79405 * gcc.dg/torture/pr79405.c: New test. >>> >>> >>> OK. >> >> >> Err - this looks quite costly done for each fwprop. And placing it before >> less costly bailouts even... >> >> See my discussion with Bernd anyway. > > I read your last message as being OK with Bernd's approach? Did I > mis-understand? No, I was refering to the following with "walking stmts" --- But isn't the issue that we are walking "all uses" (in random order) rather than only processing each stmt once? That is, /* Go through all the uses. df_uses_create will create new ones at the end, and we'll go through them as well. Do not forward propagate addresses into loops until after unrolling. CSE did so because it was able to fix its own mess, but we are not. */ for (i = 0; i < DF_USES_TABLE_SIZE (); i++) { df_ref use = DF_USES_GET (i); if (use) if (DF_REF_TYPE (use) == DF_REF_REG_USE || DF_REF_BB (use)->loop_father == NULL /* The outer most loop is not really a loop. */ || loop_outer (DF_REF_BB (use)->loop_father) == NULL) forward_propagate_into (use); } if that were simply walking all instructions, doing forward_propagat_into on each use on an instruction we'd avoid the cycle (because we stop propagating). Because when propagating DF_USES_TABLE changes. --- Richard. > jeff >
Re: [PATCH][PR tree-optimization/79578] Use operand_equal_p rather than pointer equality for base test
On Thu, Feb 23, 2017 at 10:06 PM, Jeff Lawwrote: > On 02/23/2017 02:02 AM, Richard Biener wrote: > >>> diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c >>> index 84c0b11..a82e164 100644 >>> --- a/gcc/tree-ssa-dse.c >>> +++ b/gcc/tree-ssa-dse.c >>> @@ -176,7 +176,7 @@ clear_bytes_written_by (sbitmap live_bytes, gimple >>> *stmt, ao_ref *ref) >>>/* Verify we have the same base memory address, the write >>> has a known size and overlaps with REF. */ >>>if (valid_ao_ref_for_dse () >>> - && write.base == ref->base >>> + && operand_equal_p (write.base, ref->base, 0) >> >> >> As you've identified size and offset match you are really interested >> in comparing the base addresses and thus should use OEP_ADDRESS_OF. > > I pondered that, but (perhaps incorrectly) thought that OEP_ADDRESS_OF was > an optimization and that a more simple o_e_p with no flags was safer. > > I'm happy to change it, particularly if it's a correctness issue (in which > case I think we've designed a horrible API for o_e_p, but such is life). In > fact, I've already bootstrapped and regression tested that change. It's indeed an optimization to use OEP_ADDRESS_OF and 0 is more conservative. Richard. > jeff >
[Ada] Fix wrong size computation with boolean discriminant
This is a regression present on the mainline and caused by the wrong handling of TRUTH_NOT_EXPR by the max_size function. Tested on x86_64-suse-linux, applied on the mainline. 2017-02-24 Eric Botcazou* gcc-interface/utils.c (max_size) : Flip the second argument when recursing on TRUTH_NOT_EXPR. 2017-02-24 Eric Botcazou * gnat.dg/discr47.adb: New test. -- Eric BotcazouIndex: gcc-interface/utils.c === --- gcc-interface/utils.c (revision 245625) +++ gcc-interface/utils.c (working copy) @@ -3635,7 +3635,8 @@ max_size (tree exp, bool max_p) return exp; return fold_build1 (code, type, - max_size (TREE_OPERAND (exp, 0), max_p)); + max_size (TREE_OPERAND (exp, 0), + code == TRUTH_NOT_EXPR ? !max_p : max_p)); case 2: if (code == COMPOUND_EXPR) -- { dg-do run } -- { dg-options "-O -gnatws" } procedure Discr47 is type Rec (D : Boolean := False) is record case D is when True => null; when False => C : Character; end case; end record; R : Rec; begin if R'Size /= 16 then raise Program_Error; end if; end;