Re: Pre-Patch RFC: proposed changes to option-lookup
On Thu, Oct 31, 2013 at 12:15:41AM -0600, Jeff Law wrote: > On 10/30/13 14:39, David Malcolm wrote: > >[Sending this to gcc-patches to double-check that the idea is sound > >before continuing to work on this large patch. [1] ] > > > >I want to eliminate hidden use of the preprocessor in our code, in favor > >of using block caps to signal to people reading the code that macro > >magic is happening. > > > >As a specific example, consider this supposedly-simple code: > > > > static bool > > gate_vrp (void) > > { > > return flag_tree_vrp != 0; > > } > > > >where "flag_tree_vrp" is actually an autogenerated macro to > >"global_options.x_flag_tree_vrp" > > > >This is deeply confusing to a newbie - and indeed still to me after two > >years of working with GCC's internals, for example, when stepping > >through code and trying to query values in gdb. > > > >My idea is to introduce a GCC_OPTION macro, and replace the above with: > > > > static bool > > gate_vrp (void) > > { > > return GCC_OPTION (flag_tree_vrp) != 0; > > } > > > >thus signaling to humans that macros are present. > > > >Is such a patch likely to be accepted? Should I try to break the > >options up into logical groups e.g. with separate macros for warnings vs > >optimizations, or some other scheme? > So what's the advantage of GCC_OPTION over just explicitly > referencing it via global_options? (I would agree that GCC_OPTION > or an explicit reference are better than the magic that happens > behind our back with the flags right now) > > I'm definitely in favor of removing hidden macro magic, so I think > we want to go forward with something here. I just want to know why > GCC_OPTION over the fully explicit version. If we'd go with GCC_OPTION, could we drop then the flag_ prefix? That is, GCC_OPTION (tree_vrp) instead of GCC_OPTION (flag_tree_vrp). Marek
Re: [RFC/CFT] auto-wipe dump files [was: Re: [committed] Fix up bb-slp-31.c testcase]
On 31 October 2013 01:01, Mike Stump wrote: > On Oct 30, 2013, at 2:41 AM, Bernhard Reutner-Fischer > wrote: >>> I've noticed that this testcase doesn't clean up after itself. > >> This was nagging me last weekend.. ;) >> What about automating this? > > So, the idea sounds very nice. > > One thing that I worry about is the testing speed hit for people (test cases) > that don't need cleanups. I don't know the speed hit of the code, so, don't > know how necessary it is to try and go faster. > > I was thinking the presence of a scan-tree-dump, would set a bit that said, > do a scan-tree-dump style cleanup. Well, since the -fdump-* are the one to produce the dumps, i keyed the cleanup off that. Initially i had the idea to use an exact per-pass wiper but that turned out to be too complicated for no real benefit. > > The common code then does, if cleanups needed, do cleanups > > The idea, most test cases don't do this, and don't need the big cleanup > routine to fire. A scan-tree-dump would setup a cleanup tree dumps flags, > and then in the big cleanup routine, you have: The cleanup routine would currently run 7 regexes on the incoming compiler-flags which is supposedly pretty fast. But yes, we could as well key off scan-dump. If we do that, i'd suggest to simply wipe all potential dumps, regardless of the "family" etc, like: "$ltrans\[0-9\]\[0-9\]\[0-9\][itr].*" What do you think? > > do cleanups() > { > if (need tree cleanups) do tree cleanups(); > if (need rtl cleanups) do rtl cleanups(); > } > > this way, we avoid randomly doing cleanups for things we don't need them for, > and avoid even asking if we need any cleanups, as we can have a global flag > that says if we need any extra, special cleanups. > > So, all that would be bad to do, if the speed hit is small… Can you collect > with/without numbers and post them? If you can, include user, sys and > elapsed. You can run a subset of one testsuite, say, dg.exp, as > representative. The pristine trunk, i.e. with manual cleanup was a couple of seconds slower than with the patch (10s or 20s IIRC, let me measure this on an idle box again now). As you can see, the number of globs before and after the patch decreases quite a lot, i guess the fact that we glob less is responsible for the improved runtime. Let me double-check that, though. thanks,
Re: [RFC/CFT] auto-wipe dump files [was: Re: [committed] Fix up bb-slp-31.c testcase]
On Thu, Oct 31, 2013 at 09:34:41AM +0100, Bernhard Reutner-Fischer wrote: > The cleanup routine would currently run 7 regexes on the incoming > compiler-flags which is supposedly pretty fast. > But yes, we could as well key off scan-dump. If we do that, i'd > suggest to simply wipe all potential dumps, regardless of the "family" > etc, like: > "$ltrans\[0-9\]\[0-9\]\[0-9\][itr].*" > What do you think? Many tests (e.g. in gcc.dg/vect/) pass -fdump-* flags and require cleanups, even if they don't have any scan directives. Jakub
Re: [PATCH C++/testsuite] Remove pchtest check objects and compile with current tool
On 30 October 2013 23:22, Mike Stump wrote: > On Oct 30, 2013, at 3:14 PM, Bernhard Reutner-Fischer > wrote: >> On 30 October 2013 22:47, Mike Stump wrote: >>> >>> Was there a significant purpose for the added C++ comment? If not, can you >>> remove that? If so, can you explain? >> >> grep -A9 "CONTENTS is" gcc/testsuite/lib/target-supports.exp >> # Assume by default that CONTENTS is C code. >> # Otherwise, code should contain: >> # "// C++" for c++, >> # "! Fortran" for Fortran code, >> # "/* ObjC", for ObjC >> # "// ObjC++" for ObjC++ >> # and "// Go" for Go >> # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to >> # allow for ObjC/ObjC++ specific flags. >> proc check_compile {basename type contents args} { > > Ah, but this is why I asked for a significant purpose? The language of the > file selects the options (flags) allowed. The language is set in your code. > I think it was part of trying different ways to fix it, but, it turned out to > be neither necessary or sufficient in the end. Not sure about any significant purpose, no. I found it odd that the check did not attempt to obtain a result without knowingly provoking an odd warning, hence these chk_ stuff. So, what do you want me to do? I want to delete the test objects and i don't really care if remove-build-file overdoes it or not.. pch usually fails for my crosses anyway so is disabled in the first place :P Are you saying that these CONTENT stuff should be nuked altogether and/or the pchtest stanza be kept as is and/or the stanza be cut to only fire for tool==g++ ? thanks,
[wide-int] Fix ada builds
I applied this obvious patch to get the ada frontend building. Richard Index: gcc/ada/gcc-interface/decl.c === --- gcc/ada/gcc-interface/decl.c(revision 204174) +++ gcc/ada/gcc-interface/decl.c(working copy) @@ -1658,7 +1658,7 @@ TYPE_PRECISION (gnu_type) = esize; TYPE_UNSIGNED (gnu_type) = is_unsigned; set_min_and_max_values_for_integral_type (gnu_type, esize, - is_unsigned); + TYPE_SIGN (gnu_type)); process_attributes (&gnu_type, &attr_list, true, gnat_entity); layout_type (gnu_type); @@ -7492,11 +7492,9 @@ if (TREE_CODE (TREE_OPERAND (gnu_size, 1)) == INTEGER_CST) { tree op1 = TREE_OPERAND (gnu_size, 1); - wide_int signed_op1 - = wide_int::from_tree (op1).sforce_to_size (TYPE_PRECISION (sizetype)); - if (signed_op1.neg_p ()) + if (wi::neg_p (op1)) { - op1 = wide_int_to_tree (sizetype, -signed_op1); + op1 = wide_int_to_tree (sizetype, wi::neg (op1)); pre_op1 = annotate_value (build1 (NEGATE_EXPR, sizetype, op1)); } }
[wide-int] Various division fixes
There are several Ada failures on the branch, all related to division and modulus: - div_floor adjusted truncated negative quotients in the wrong direction (up instead of down). E.g. -5 /[fl] 2 gave -1 rather than -3. - {div,mod}_round used the wrong condition to check when rounding was needed. - The routines checked for negative results by testing the sign of the (truncated) quotient directly. That doesn't work when the true quotient is in the range (-1, 0) and gets truncated to zero. Tested on x86_64-linux-gnu and powerpc64-linux-gnu. OK to install? Thanks, Richard Index: gcc/wide-int.h === --- gcc/wide-int.h 2013-10-31 08:46:18.081178550 + +++ gcc/wide-int.h 2013-10-31 08:53:50.741900740 + @@ -2250,8 +2250,8 @@ wi::div_floor (const T1 &x, const T2 &y, yi.val, yi.len, yi.precision, sgn, overflow)); remainder.set_len (remainder_len); - if (wi::neg_p (quotient, sgn) && remainder != 0) -return quotient + 1; + if (wi::neg_p (x, sgn) != wi::neg_p (y, sgn) && remainder != 0) +return quotient - 1; return quotient; } @@ -2292,7 +2292,7 @@ wi::div_ceil (const T1 &x, const T2 &y, yi.val, yi.len, yi.precision, sgn, overflow)); remainder.set_len (remainder_len); - if (!wi::neg_p (quotient, sgn) && remainder != 0) + if (wi::neg_p (x, sgn) == wi::neg_p (y, sgn) && remainder != 0) return quotient + 1; return quotient; } @@ -2322,10 +2322,10 @@ wi::div_round (const T1 &x, const T2 &y, { if (sgn == SIGNED) { - if (wi::gts_p (wi::lrshift (wi::abs (y), 1), -wi::abs (remainder))) + if (wi::ges_p (wi::abs (remainder), +wi::lrshift (wi::abs (y), 1))) { - if (wi::neg_p (quotient)) + if (wi::neg_p (x, sgn) != wi::neg_p (y, sgn)) return quotient - 1; else return quotient + 1; @@ -2333,16 +2333,15 @@ wi::div_round (const T1 &x, const T2 &y, } else { - if (wi::gtu_p (wi::lrshift (y, 1), remainder)) + if (wi::geu_p (remainder, wi::lrshift (y, 1))) return quotient + 1; } } return quotient; } -/* Return X / Y, rouding towards nearest with ties away from zero. - Treat X and Y as having the signedness given by SGN. Store the - remainder in *REMAINDER_PTR. */ +/* Return X / Y, rouding towards 0. Treat X and Y as having the + signedness given by SGN. Store the remainder in *REMAINDER_PTR. */ template inline WI_BINARY_RESULT (T1, T2) wi::divmod_trunc (const T1 &x, const T2 &y, signop sgn, @@ -2425,7 +2424,7 @@ wi::mod_floor (const T1 &x, const T2 &y, overflow)); remainder.set_len (remainder_len); - if (wi::neg_p (quotient, sgn) && remainder != 0) + if (wi::neg_p (x, sgn) != wi::neg_p (y, sgn) && remainder != 0) return remainder + y; return remainder; } @@ -2461,7 +2460,7 @@ wi::mod_ceil (const T1 &x, const T2 &y, overflow)); remainder.set_len (remainder_len); - if (!wi::neg_p (quotient, sgn) && remainder != 0) + if (wi::neg_p (x, sgn) == wi::neg_p (y, sgn) && remainder != 0) return remainder - y; return remainder; } @@ -2491,10 +2490,10 @@ wi::mod_round (const T1 &x, const T2 &y, { if (sgn == SIGNED) { - if (wi::gts_p (wi::lrshift (wi::abs (y), 1), -wi::abs (remainder))) + if (wi::ges_p (wi::abs (remainder), +wi::lrshift (wi::abs (y), 1))) { - if (wi::neg_p (quotient)) + if (wi::neg_p (x, sgn) != wi::neg_p (y, sgn)) return remainder + y; else return remainder - y; @@ -2502,7 +2501,7 @@ wi::mod_round (const T1 &x, const T2 &y, } else { - if (wi::gtu_p (wi::lrshift (y, 1), remainder)) + if (wi::geu_p (remainder, wi::lrshift (y, 1))) return remainder - y; } }
[PATCH, MPX, 2/X] Pointers Checker [7/25] Suppress BUILT_IN_CHKP_ARG_BND optimizations.
Hi, Here is a patch which hadles the problem with optimization of BUILT_IN_CHKP_ARG_BND calls. Pointer Bounds Checker expects that argument of this call is a default SSA_NAME of the PARM_DECL whose bounds we want to get. The problem is in optimizations which may replace arg with it's copy or a known value. This patch suppress such modifications. Thanks, Ilya -- gcc/ 2013-10-28 Ilya Enkovich * tree-into-ssa.c: Include "target.h" (rewrite_update_stmt): Skip BUILT_IN_CHKP_ARG_BND calls. * tree-ssa-dom.c: Include "target.h" (cprop_into_stmt): Skip BUILT_IN_CHKP_ARG_BND calls. diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index 981e9f4..8d48f6d 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see #include "params.h" #include "diagnostic-core.h" #include "tree-into-ssa.h" +#include "target.h" /* This file builds the SSA form for a function as described in: @@ -1921,8 +1922,14 @@ rewrite_update_stmt (gimple stmt, gimple_stmt_iterator gsi) } /* Rewrite USES included in OLD_SSA_NAMES and USES whose underlying - symbol is marked for renaming. */ - if (rewrite_uses_p (stmt)) + symbol is marked for renaming. + Skip calls to BUILT_IN_CHKP_ARG_BND whose arg should never be + renamed. */ + if (rewrite_uses_p (stmt) + && !(flag_check_pointer_bounds + && (gimple_code (stmt) == GIMPLE_CALL) + && gimple_call_fndecl (stmt) + == targetm.builtin_chkp_function (BUILT_IN_CHKP_ARG_BND))) { if (is_gimple_debug (stmt)) { diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 211bfcf..445278a 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -45,6 +45,7 @@ along with GCC; see the file COPYING3. If not see #include "params.h" #include "tree-ssa-threadedge.h" #include "tree-ssa-dom.h" +#include "target.h" /* This file implements optimizations on the dominator tree. */ @@ -2266,6 +2267,16 @@ cprop_into_stmt (gimple stmt) use_operand_p op_p; ssa_op_iter iter; + /* Call used to obtain bounds of input arg by Pointer Bounds Checker + should not be optimized. Argument of the call is a default + SSA_NAME of PARM_DECL. It should never be replaced by value. */ + if (flag_check_pointer_bounds && gimple_code (stmt) == GIMPLE_CALL) +{ + tree fndecl = gimple_call_fndecl (stmt); + if (fndecl == targetm.builtin_chkp_function (BUILT_IN_CHKP_ARG_BND)) + return; +} + FOR_EACH_SSA_USE_OPERAND (op_p, stmt, iter, SSA_OP_USE) cprop_operand (stmt, op_p); }
RE: [PATCH 1/n] Add conditional compare support
> -Original Message- > From: Richard Henderson [mailto:r...@redhat.com] > Sent: Thursday, October 31, 2013 4:14 AM > To: Zhenqiang Chen > Cc: Richard Earnshaw; 'Richard Biener'; GCC Patches > Subject: Re: [PATCH 1/n] Add conditional compare support > > > +/* RCODE0, RCODE1 and a valid return value should be enum rtx_code. > > + TCODE should be enum tree_code. > > + Check whether two compares are a valid combination in the target to > generate > > + a conditional compare. If valid, return the new compare after > combination. > > + */ > > +DEFHOOK > > +(legitimize_cmp_combination, > > + "This target hook returns the dominance compare if the two compares > > +are\n\ a valid combination. This target hook is required only when > > +the target\n\ supports conditional compare, such as ARM.", int, (int > > +rcode0, int rcode1, int tcode), > > + default_legitimize_cmp_combination) > > + > > +/* RCODE0, RCODE1 and a valid return value should be enum rtx_code. > > + TCODE should be enum tree_code. > > + Check whether two compares are a valid combination in the target to > generate > > + a conditional compare. If valid, return the new compare after > combination. > > + The difference from legitimize_cmp_combination is that its first > compare is > > + the result of a previous conditional compare, which leads to more > constrain > > + on it, since no way to swap the two compares. */ DEFHOOK > > +(legitimize_ccmp_combination, "This target hook returns the > > +dominance compare if the two compares are\n\ a valid combination. > > +This target hook is required only when the target\n\ supports > > +conditional compare, such as ARM.", int, (int rcode0, int rcode1, > > +int tcode), > > + default_legitimize_ccmp_combination) > > + > > Why do these hooks still exist? They should be redundant with ... They are not necessary. Will remove them. > > +/* CMP0 and CMP1 are two compares. USED_AS_CC_P indicates whether > the target > > + is used as CC or not. TCODE should be enum tree_code. > > + The hook will return a condtional compare RTX if all checkes are > > +OK. */ DEFHOOK (gen_ccmp_with_cmp_cmp, "This target hook returns a > > +condtional compare RTX if the two compares are\n\ a valid > > +combination. This target hook is required only when the target\n\ > > +supports conditional compare, such as ARM.", rtx, (gimple cmp0, > > +gimple cmp1, int tcode, bool used_as_cc_p), > > + default_gen_ccmp_with_cmp_cmp) > > + > > +/* CC is the result of a previous conditional compare. CMP1 is a compare. > > + USED_AS_CC_P indicates whether the target is used as CC or not. > > + TCODE should be enum tree_code. > > + The hook will return a condtional compare rtx if all checkes are > > +OK. */ DEFHOOK (gen_ccmp_with_ccmp_cmp, "This target hook returns > a > > +condtional compare RTX if the CC and CMP1 are\n\ a valid combination. > > +This target hook is required only when the target\n\ supports > > +conditional compare, such as ARM.", rtx, (rtx cc, gimple cmp1, int > > +tcode, bool used_as_cc_p), > > + default_gen_ccmp_with_ccmp_cmp) > > + > > ... these. > > Why in the world are you passing down gimple to the backends? The > expand_operands done therein should have been done in expr.c. > The hooks are still not what I suggested, particularly > gen_ccmp_with_cmp_cmp is what I was trying to avoid, passing down two > initial compares like that. > > To be 100% explicit this time, I think the hooks should be Thank you very much! > DEFHOOK > (gen_ccmp_first, > "This function emits a comparison insn for the first of a sequence of\n\ > conditional comparisions. It returns a comparison expression appropriate\n\ > for passing to @code{gen_ccmp_next} or to @code{cbranch_optab}.", rtx, > (int code, rtx op0, rtx op1), > NULL) > DEFHOOK > (gen_ccmp_next, > "This function emits a conditional comparison within a sequence of\n\ > conditional comparisons. The @code{prev} expression is the result of a\n\ > prior call to @code{gen_ccmp_first} or @code{gen_ccmp_next}. It may > return\n\ @code{NULL} if the combination of @code{prev} and this > comparison is\n\ not supported, otherwise the result must be appropriate > for passing to @code{gen_ccmp_next} or @code{cbranch_optab}.", rtx, (rtx > prev, int code, rtx op0, rtx op1), > NULL) gen_ccmp_first and gen_ccmp_next are better. But need some improvement. With two compares, we might swap the order of the two compares to get a valid combination. This is what current ARM does (Please refer arm_select_dominace_cc_mode, cmp_and, cmp_ior, and_scc_scc and ior_scc_scc). To improve gen_ccmp_first, we need another function/hook to determine which compare is done first. I will double check ARM backend to avoid hook. Hook gen_ccmp_next needs one more parameter to indicate AND/IOR since they will generate different instructions. I will update the patch. > All of your existing tests for HAVE_ccmp should be replaced with > > if (targetm.ge
[PATCH, MPX, 2/X] Pointers Checker [8/25] Languages support
Hi, This patch adds support Pointer Bounds Checker into c-family and LTO front-ends. The main purpose of changes in front-end is to register all statically initialized objects for checker. We also need to register such objects created by compiler. Thanks, Ilya -- gcc/ 2013-10-29 Ilya Enkovich * c/c-lang.c (LANG_HOOKS_CHKP_SUPPORTED): New. * cp/cp-lang.c (LANG_HOOKS_CHKP_SUPPORTED): New. * objc/objc-lang.c (LANG_HOOKS_CHKP_SUPPORTED): New. * objcp/objcp-lang.c (LANG_HOOKS_CHKP_SUPPORTED): New. * lto/lto-lang.c (LANG_HOOKS_CHKP_SUPPORTED): New. * c/c-parser.c (c_parser_declaration_or_fndef): Register statically initialized decls in Pointer Bounds Checker. * cp/decl.c (cp_finish_decl): Likewise. * gimplify.c (gimplify_init_constructor): Likewise. diff --git a/gcc/c/c-lang.c b/gcc/c/c-lang.c index 614c46d..a32bc6b 100644 --- a/gcc/c/c-lang.c +++ b/gcc/c/c-lang.c @@ -43,6 +43,8 @@ enum c_language_kind c_language = clk_c; #define LANG_HOOKS_INIT c_objc_common_init #undef LANG_HOOKS_INIT_TS #define LANG_HOOKS_INIT_TS c_common_init_ts +#undef LANG_HOOKS_CHKP_SUPPORTED +#define LANG_HOOKS_CHKP_SUPPORTED true /* Each front end provides its own lang hook initializer. */ struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 9ccae3b..65d83c8 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1682,6 +1682,12 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, maybe_warn_string_init (TREE_TYPE (d), init); finish_decl (d, init_loc, init.value, init.original_type, asm_name); + + /* Register all decls with initializers in Pointer +Bounds Checker to generate required static bounds +initializers. */ + if (DECL_INITIAL (d) != error_mark_node) + chkp_register_var_initializer (d); } } else diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c index a7fa8e4..6d138bd 100644 --- a/gcc/cp/cp-lang.c +++ b/gcc/cp/cp-lang.c @@ -81,6 +81,8 @@ static tree get_template_argument_pack_elems_folded (const_tree); #define LANG_HOOKS_EH_PERSONALITY cp_eh_personality #undef LANG_HOOKS_EH_RUNTIME_TYPE #define LANG_HOOKS_EH_RUNTIME_TYPE build_eh_type_type +#undef LANG_HOOKS_CHKP_SUPPORTED +#define LANG_HOOKS_CHKP_SUPPORTED true /* Each front end provides its own lang hook initializer. */ struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 1e92f2a..db40e75 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6379,6 +6379,12 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, the class specifier. */ if (!DECL_EXTERNAL (decl)) var_definition_p = true; + + /* If var has initilizer then we need to register it in +Pointer Bounds Checker to generate static bounds initilizer +if required. */ + if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node) + chkp_register_var_initializer (decl); } /* If the variable has an array type, lay out the type, even if there is no initializer. It is valid to index through the diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 4f52c27..503450f 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -4111,6 +4111,11 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, walk_tree (&ctor, force_labels_r, NULL, NULL); ctor = tree_output_constant_def (ctor); + + /* We need to register created constant object to + initialize bounds for pointers in it. */ + chkp_register_var_initializer (ctor); + if (!useless_type_conversion_p (type, TREE_TYPE (ctor))) ctor = build1 (VIEW_CONVERT_EXPR, type, ctor); TREE_OPERAND (*expr_p, 1) = ctor; diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c index 0fa0fc9..b6073d9 100644 --- a/gcc/lto/lto-lang.c +++ b/gcc/lto/lto-lang.c @@ -1278,6 +1278,8 @@ static void lto_init_ts (void) #undef LANG_HOOKS_INIT_TS #define LANG_HOOKS_INIT_TS lto_init_ts +#undef LANG_HOOKS_CHKP_SUPPORTED +#define LANG_HOOKS_CHKP_SUPPORTED true struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; diff --git a/gcc/objc/objc-lang.c b/gcc/objc/objc-lang.c index bc0008b..5e7e43b 100644 --- a/gcc/objc/objc-lang.c +++ b/gcc/objc/objc-lang.c @@ -49,6 +49,8 @@ enum c_language_kind c_language = clk_objc; #define LANG_HOOKS_GIMPLIFY_EXPR objc_gimplify_expr #undef LANG_HOOKS_INIT_TS #define LANG_HOOKS_INIT_TS objc_common_init_ts +#undef LANG_HOOKS_CHKP_SUPPORTED +#define LANG_HOOKS_CHKP_SUPPORTED true /* Each front end provides its own lang hook initializer. */ struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER
[PATCH, MPX, 2/X] Pointers Checker [9/25] Bound constants
Hi, Here is a patch which adds support for bound constant to be used as DECL_INITIAL for constant static bounds generated by compiler. Thanks, Ilya -- gcc/ 2013-10-23 Ilya Enkovich * emit-rtl.c (immed_double_const): Support MODE_POINTER_BOUNDS. * explow.c (trunc_int_for_mode): Likewise. * varpool.c (ctor_for_folding): Do not fold constant bounds vars. diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index b0fc846..5d13b69 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -538,7 +538,8 @@ immed_double_const (HOST_WIDE_INT i0, HOST_WIDE_INT i1, enum machine_mode mode) || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT /* We can get a 0 for an error mark. */ || GET_MODE_CLASS (mode) == MODE_VECTOR_INT - || GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT); + || GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT + || GET_MODE_CLASS (mode) == MODE_POINTER_BOUNDS); if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT) return gen_int_mode (i0, mode); diff --git a/gcc/explow.c b/gcc/explow.c index f278e29..095434f 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -52,7 +52,8 @@ trunc_int_for_mode (HOST_WIDE_INT c, enum machine_mode mode) int width = GET_MODE_PRECISION (mode); /* You want to truncate to a _what_? */ - gcc_assert (SCALAR_INT_MODE_P (mode)); + gcc_assert (SCALAR_INT_MODE_P (mode) + || POINTER_BOUNDS_MODE_P (mode)); /* Canonicalize BImode to 0 and STORE_FLAG_VALUE. */ if (mode == BImode) diff --git a/gcc/varpool.c b/gcc/varpool.c index 2eb1fc1..d9c08c1 100644 --- a/gcc/varpool.c +++ b/gcc/varpool.c @@ -254,6 +254,12 @@ ctor_for_folding (tree decl) && TREE_CODE (decl) != CONST_DECL) return error_mark_node; + /* Static constant bounds are created to be + used instead of constants and therefore + do not let folding it. */ + if (POINTER_BOUNDS_P (decl)) +return error_mark_node; + if (TREE_CODE (decl) == CONST_DECL || DECL_IN_CONSTANT_POOL (decl)) return DECL_INITIAL (decl);
[PATCH, MPX, 2/X] Pointers Checker [10/25] Calls copy and verification
Hi, Here is a patch to support of instrumented code in calls verifiers and calls copy with skipped args. Thanks, Ilya -- gcc/ 2013-10-29 Ilya Enkovich * cgraph.c (gimple_check_call_args): Handle bound args. * gimple.c (gimple_call_copy_skip_args): Likewise. (validate_call): Likewise. diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 52d9ab0..9d7ae85 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -3030,40 +3030,54 @@ gimple_check_call_args (gimple stmt, tree fndecl, bool args_count_match) { for (i = 0, p = DECL_ARGUMENTS (fndecl); i < nargs; - i++, p = DECL_CHAIN (p)) + i++) { - tree arg; + tree arg = gimple_call_arg (stmt, i); + + /* Skip bound args inserted by Pointer Bounds Checker. */ + if (POINTER_BOUNDS_P (arg)) + continue; + /* We cannot distinguish a varargs function from the case of excess parameters, still deferring the inlining decision to the callee is possible. */ if (!p) break; - arg = gimple_call_arg (stmt, i); + if (p == error_mark_node || arg == error_mark_node || (!types_compatible_p (DECL_ARG_TYPE (p), TREE_TYPE (arg)) && !fold_convertible_p (DECL_ARG_TYPE (p), arg))) return false; + + p = DECL_CHAIN (p); } if (args_count_match && p) return false; } else if (parms) { - for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p)) + for (i = 0, p = parms; i < nargs; i++) { - tree arg; + tree arg = gimple_call_arg (stmt, i); + + /* Skip bound args inserted by Pointer Bounds Checker. */ + if (POINTER_BOUNDS_P (arg)) + continue; + /* If this is a varargs function defer inlining decision to callee. */ if (!p) break; - arg = gimple_call_arg (stmt, i); + if (TREE_VALUE (p) == error_mark_node || arg == error_mark_node || TREE_CODE (TREE_VALUE (p)) == VOID_TYPE || (!types_compatible_p (TREE_VALUE (p), TREE_TYPE (arg)) && !fold_convertible_p (TREE_VALUE (p), arg))) return false; + + p = TREE_CHAIN (p); } } else diff --git a/gcc/gimple.c b/gcc/gimple.c index 20f6010..dc85bf8 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -3048,15 +3048,20 @@ canonicalize_cond_expr_cond (tree t) gimple gimple_call_copy_skip_args (gimple stmt, bitmap args_to_skip) { - int i; + int i, bit; int nargs = gimple_call_num_args (stmt); vec vargs; vargs.create (nargs); gimple new_stmt; - for (i = 0; i < nargs; i++) -if (!bitmap_bit_p (args_to_skip, i)) - vargs.quick_push (gimple_call_arg (stmt, i)); + for (i = 0, bit = 0; i < nargs; i++, bit++) + if (POINTER_BOUNDS_P (gimple_call_arg (stmt, i))) + { + if (!bitmap_bit_p (args_to_skip, --bit)) + vargs.quick_push (gimple_call_arg (stmt, i)); + } + else if (!bitmap_bit_p (args_to_skip, bit)) + vargs.quick_push (gimple_call_arg (stmt, i)); if (gimple_call_internal_p (stmt)) new_stmt = gimple_build_call_internal_vec (gimple_call_internal_fn (stmt), @@ -3702,6 +3707,9 @@ validate_call (gimple stmt, tree fndecl) if (!targs) return true; tree arg = gimple_call_arg (stmt, i); + /* Skip bounds. */ + if (flag_check_pointer_bounds && POINTER_BOUNDS_P (arg)) + continue; if (INTEGRAL_TYPE_P (TREE_TYPE (arg)) && INTEGRAL_TYPE_P (TREE_VALUE (targs))) ;
Re: [PATCH][ubsan] Add VLA bound instrumentation
On Wed, Oct 30, 2013 at 03:41:53PM -0700, Mike Stump wrote: > The dtors only run, after the ctors run. We mark where the ctors finish > spot, as the _start_ of the region for which we have to clean up. Really, > the cleanup has nothing to do with ctors. You can have dtors, without any > ctors, or ctors, without any dtors. > > { > decl d; > s; > } > > transforms into: > > <- start of lifetime of the storage for d > ctor(d) > <- start of lifetime of the fully constructed object d > s; > <- end of lifetime of fully constructed object d > dtor(d) > <- end of the storage of d > > CLEANUP_STMT documents when the region protected by the cleanup starts. One > want to describe that region is, the end of the ctors, if any, else after the > storage is allocated. In the above, that is the second < spot. > > Now, in the trees, the above is decl d; ctors; CLEANUP_STMT (s, dtors, d). > > s is the region for which the cleanups are active for. dtors is the cleanup > to perform on transfer out of that region, and d is the decl related to the > actions in dtors. I see now. Thanks very much, Mike. Marek
RE: [PATCH] Fix C++0x memory model for -fno-strict-volatile-bitfields on ARM
Hello, meanwhile, I have added a test case to that patch. Boot-strapped and regression-tested as usual. OK for trunk? Bernd. > Hi, > > On Fri, 25 Oct 2013 11:26:20, Richard Biener wrote: >> >> On Fri, Oct 25, 2013 at 10:40 AM, Bernd Edlinger >> wrote: >>> Hello, >>> >>> this patch fixes the recently discovered data store race on arm-eabi-gcc >>> with -fno-strict-volatile-bitfields >>> for structures like this: >>> >>> #define test_type unsigned short >>> >>> typedef struct s{ >>> unsigned char Prefix[1]; >>> test_type Type; >>> }__attribute((__packed__,__aligned__(4))) ss; >>> >>> volatile ss v; >>> >>> void __attribute__((noinline)) >>> foo (test_type u) >>> { >>> v.Type = u; >>> } >>> >>> test_type __attribute__((noinline)) >>> bar (void) >>> { >>> return v.Type; >>> } >>> >>> >>> I've manually confirmed the correct code generation using variations of the >>> example above on an ARM cross-compiler for -fno-strict-volatile-bitfields. >>> >>> Note, that this example is still causes ICE's for >>> -fstrict-volatile-bitfields, >>> but I'd like to fix that separately. >>> >>> Boot-strapped and regression-tested on x86_64-linux-gnu. >>> >>> Ok for trunk? >> >> Isn't it more appropriate to fix it here: >> >> if (TREE_CODE (to) == COMPONENT_REF >> && DECL_BIT_FIELD_TYPE (TREE_OPERAND (to, 1))) >> get_bit_range (&bitregion_start, &bitregion_end, to, &bitpos, &offset); >> >> ? >> > > Honestly, I'd call this is a work-around, not a design. > > Therefore I would not move that workaround to expr.c. > > Also the block below is only a work-around IMHO. > > if (MEM_P (str_rtx) && bitregion_start> 0) > { > enum machine_mode bestmode; > HOST_WIDE_INT offset, size; > > gcc_assert ((bitregion_start % BITS_PER_UNIT) == 0); > > offset = bitregion_start / BITS_PER_UNIT; > bitnum -= bitregion_start; > size = (bitnum + bitsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT; > bitregion_end -= bitregion_start; > bitregion_start = 0; > bestmode = get_best_mode (bitsize, bitnum, > bitregion_start, bitregion_end, > MEM_ALIGN (str_rtx), VOIDmode, > MEM_VOLATILE_P (str_rtx)); > str_rtx = adjust_bitfield_address_size (str_rtx, bestmode, offset, > size); > } > > Here, if bitregion_start = 8, we have a 4 byte aligned memory context, > and whoops, now it is only 1 byte aligned. > > this example: > > struct s > { > char a; > int b:24; > }; > > struct s ss; > > void foo(int b) > { > ss.b = b; > } > > > gets compiled (at -O3) to: > > foo: > @ Function supports interworking. > @ args = 0, pretend = 0, frame = 0 > @ frame_needed = 0, uses_anonymous_args = 0 > @ link register save eliminated. > ldrr3, .L2 > movr1, r0, lsr #8 > movr2, r0, lsr #16 > strbr1, [r3, #2] > strbr0, [r3, #1] > strbr2, [r3, #3] > bxlr > > while... > > struct s > { > char a; > int b:24; > }; > > struct s ss; > > void foo(int b) > { > ss.b = b; > } > > > gets compiled (at -O3) to > > foo: > @ Function supports interworking. > @ args = 0, pretend = 0, frame = 0 > @ frame_needed = 0, uses_anonymous_args = 0 > @ link register save eliminated. > ldrr3, .L2 > movr2, r0, lsr #16 > strbr2, [r3, #2] > strhr0, [r3]@ movhi > bxlr > > which is more efficient, but only because the memory context is still > aligned in this case. > >> Btw, the C++ standard doesn't cover packed or aligned attributes so >> we could declare this a non-issue. Any opinion on that? >> >> Thanks, >> Richard. >> >>> Thanks >>> Bernd.2013-10-31 Bernd Edlinger Fix C++0x memory model for unaligned fields in packed, aligned(4) structures with -fno-strict-volatile-bitfields on STRICT_ALIGNMENT targets like arm-none-eabi. * expmed.c (store_bit_field): Handle unaligned fields like bit regions. testsuite: 2013-10-31 Bernd Edlinger * gcc.dg/pr56997-4.c: New testcase. patch-unaligned-data.diff Description: Binary data
Re: Honnor ix86_accumulate_outgoing_args again
On 10/10/2013 08:40 PM, Jan Hubicka wrote: + In 32bit mode enabling argument accumulation results in about 5% code size + growth becuase move instructions are less compact than push. In 64bit + mode the difference is less drastic but visible. + + FIXME: Unlike earlier implementations, the size of unwind info seems to + actually grouw with accumulation. Is that because accumulated args + unwind info became unnecesarily bloated? Several typos: "32bit" "64bit", "becuase", "grouw". "push." should be "pushes.", I think. I can't parse the question at the end. Sorry, no comments on the actual code changes. :-/ -- Florian Weimer / Red Hat Product Security Team
Re: [PATCH] Introducing SAD (Sum of Absolute Differences) operation to GCC vectorizer.
Hello! > SAD (Sum of Absolute Differences) is a common and important algorithm > in image processing and other areas. SSE2 even introduced a new > instruction PSADBW for it. A SAD loop can be greatly accelerated by > this instruction after being vectorized. This patch introduced a new > operation SAD_EXPR and a SAD pattern recognizer in vectorizer. > > In order to express this new operation, a new expression SAD_EXPR is > introduced in tree.def, and the corresponding entry in optabs is > added. The patch also added the "define_expand" for SSE2 and AVX2 > platforms for i386. +(define_expand "sadv16qi" + [(match_operand:V4SI 0 "register_operand") + (match_operand:V16QI 1 "register_operand") + (match_operand:V16QI 2 "register_operand") + (match_operand:V4SI 3 "register_operand")] + "TARGET_SSE2" +{ + rtx t1 = gen_reg_rtx (V2DImode); + rtx t2 = gen_reg_rtx (V4SImode); + emit_insn (gen_sse2_psadbw (t1, operands[1], operands[2])); + convert_move (t2, t1, 0); + emit_insn (gen_rtx_SET (VOIDmode, operands[0], + gen_rtx_PLUS (V4SImode, + operands[3], t2))); + DONE; +}) Please use generic expanders (expand_simple_binop) to generate plus expression. Also, please use nonimmediate_operand predicate for operand 2 and operand 3. Please note, that nonimmediate operands should be passed as the second input operand to commutative operators, to match their insn pattern layout. Uros.
Re: patch to fix PR58784 (ARM LRA crash)
On Wed, Oct 30, 2013 at 3:03 PM, Vladimir Makarov wrote: > The following patch fixes > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58784 > > LRA has an old check of legitimate addresses. It was written before a newer > address decomposition code which makes more correct checks of addresses. > > So I removed the old check. > > Committed as rev. 204215. > > 2013-10-30 Vladimir Makarov > > PR target/58784 > * lra.c (check_rtl): Remove address check before LRA work. > > 2013-10-30 Vladimir Makarov > > PR target/58784 > * gcc.target/arm/pr58784.c: New. >
Re: patch to fix PR58784 (ARM LRA crash)
On Wed, Oct 30, 2013 at 3:03 PM, Vladimir Makarov wrote: > The following patch fixes > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58784 > > LRA has an old check of legitimate addresses. It was written before a newer > address decomposition code which makes more correct checks of addresses. > > So I removed the old check. > > Committed as rev. 204215. > Yvan, Does this mean we can now turn on LRA for ARM state by default and start looking at performance issues if any ? Ramana > 2013-10-30 Vladimir Makarov > > PR target/58784 > * lra.c (check_rtl): Remove address check before LRA work. > > 2013-10-30 Vladimir Makarov > > PR target/58784 > * gcc.target/arm/pr58784.c: New. >
Re: [wide-int] Various division fixes
On 10/31/2013 05:01 AM, Richard Sandiford wrote: There are several Ada failures on the branch, all related to division and modulus: - div_floor adjusted truncated negative quotients in the wrong direction (up instead of down). E.g. -5 /[fl] 2 gave -1 rather than -3. - {div,mod}_round used the wrong condition to check when rounding was needed. - The routines checked for negative results by testing the sign of the (truncated) quotient directly. That doesn't work when the true quotient is in the range (-1, 0) and gets truncated to zero. Tested on x86_64-linux-gnu and powerpc64-linux-gnu. OK to install? Thanks, Richard yes, these look fine. kenny Index: gcc/wide-int.h === --- gcc/wide-int.h 2013-10-31 08:46:18.081178550 + +++ gcc/wide-int.h 2013-10-31 08:53:50.741900740 + @@ -2250,8 +2250,8 @@ wi::div_floor (const T1 &x, const T2 &y, yi.val, yi.len, yi.precision, sgn, overflow)); remainder.set_len (remainder_len); - if (wi::neg_p (quotient, sgn) && remainder != 0) -return quotient + 1; + if (wi::neg_p (x, sgn) != wi::neg_p (y, sgn) && remainder != 0) +return quotient - 1; return quotient; } @@ -2292,7 +2292,7 @@ wi::div_ceil (const T1 &x, const T2 &y, yi.val, yi.len, yi.precision, sgn, overflow)); remainder.set_len (remainder_len); - if (!wi::neg_p (quotient, sgn) && remainder != 0) + if (wi::neg_p (x, sgn) == wi::neg_p (y, sgn) && remainder != 0) return quotient + 1; return quotient; } @@ -2322,10 +2322,10 @@ wi::div_round (const T1 &x, const T2 &y, { if (sgn == SIGNED) { - if (wi::gts_p (wi::lrshift (wi::abs (y), 1), -wi::abs (remainder))) + if (wi::ges_p (wi::abs (remainder), +wi::lrshift (wi::abs (y), 1))) { - if (wi::neg_p (quotient)) + if (wi::neg_p (x, sgn) != wi::neg_p (y, sgn)) return quotient - 1; else return quotient + 1; @@ -2333,16 +2333,15 @@ wi::div_round (const T1 &x, const T2 &y, } else { - if (wi::gtu_p (wi::lrshift (y, 1), remainder)) + if (wi::geu_p (remainder, wi::lrshift (y, 1))) return quotient + 1; } } return quotient; } -/* Return X / Y, rouding towards nearest with ties away from zero. - Treat X and Y as having the signedness given by SGN. Store the - remainder in *REMAINDER_PTR. */ +/* Return X / Y, rouding towards 0. Treat X and Y as having the + signedness given by SGN. Store the remainder in *REMAINDER_PTR. */ template inline WI_BINARY_RESULT (T1, T2) wi::divmod_trunc (const T1 &x, const T2 &y, signop sgn, @@ -2425,7 +2424,7 @@ wi::mod_floor (const T1 &x, const T2 &y, overflow)); remainder.set_len (remainder_len); - if (wi::neg_p (quotient, sgn) && remainder != 0) + if (wi::neg_p (x, sgn) != wi::neg_p (y, sgn) && remainder != 0) return remainder + y; return remainder; } @@ -2461,7 +2460,7 @@ wi::mod_ceil (const T1 &x, const T2 &y, overflow)); remainder.set_len (remainder_len); - if (!wi::neg_p (quotient, sgn) && remainder != 0) + if (wi::neg_p (x, sgn) == wi::neg_p (y, sgn) && remainder != 0) return remainder - y; return remainder; } @@ -2491,10 +2490,10 @@ wi::mod_round (const T1 &x, const T2 &y, { if (sgn == SIGNED) { - if (wi::gts_p (wi::lrshift (wi::abs (y), 1), -wi::abs (remainder))) + if (wi::ges_p (wi::abs (remainder), +wi::lrshift (wi::abs (y), 1))) { - if (wi::neg_p (quotient)) + if (wi::neg_p (x, sgn) != wi::neg_p (y, sgn)) return remainder + y; else return remainder - y; @@ -2502,7 +2501,7 @@ wi::mod_round (const T1 &x, const T2 &y, } else { - if (wi::gtu_p (wi::lrshift (y, 1), remainder)) + if (wi::geu_p (remainder, wi::lrshift (y, 1))) return remainder - y; } }
Re: [wide-int] Update main comment
On 10/30/2013 02:34 PM, Richard Sandiford wrote: Kenneth Zadeck writes: On 10/30/2013 07:01 AM, Richard Sandiford wrote: Kenneth Zadeck writes: On 10/29/2013 06:37 PM, Richard Sandiford wrote: This patch tries to update the main wide_int comment to reflect the current implementation. - bitsizetype is TImode on x86_64 and others, so I don't think it's necessarily true that all offset_ints are signed. (widest_int are though.) i am wondering if this is too conservative an interpretation.I believe that they are ti mode because that is the next thing after di mode and so they wanted to accommodate the 3 extra bits. Certainly there is no x86 that is able to address more than 64 bits. Right, but my point is that it's a different case from widest_int. It'd be just as valid to do bitsizetype arithmetic using wide_int rather than offset_int, and those wide_ints would have precision 128, just like the offset_ints. And I wouldn't really say that those wide_ints were fundamentally signed in any way. Although the tree layer might "know" that X upper bits of the bitsizetype are always signs, the tree-wide_int interface treats them in the same way as any other 128-bit type. Maybe I'm just being pedantic, but I think offset_int would only be like widest_int if bitsizetype had precision 67 or whatever. Then we could say that both offset_int and widest_int must be wider than any inputs, meaning that there's at least one leading sign bit. this was of course what mike and i wanted, but we could not really figure out how to pull it off. in particular, we could not find any existing reliable marker in the targets to say what the width of the widest pointer on any implementation. We actually used the number 68 rather than 67 because we assumed 64 for the widest pointer on any existing platform, 3 bits for the bits and 1 bit for the sign. Ah yeah, 68 would be better for signed types. Is the patch OK while we still have 128-bit bitsizetypes though? I agree the current comment would be right if we ever did switch to sub-128 bitsizes. Thanks, Richard yes this is fine. Note that 68 is documented at the top of wide-int.h kenny
Re: changing a collision resolution strategy of the symbol table of identifiers
On 10/20/2013 02:55 PM, Roman Gareev wrote: During testing of the linux kernel (3.8.8) compilation time, the acquired results were the following: increasing by 0.17% for the version 4.8.0, increasing by 1.12% for the version 4.8.1, decreasing by 0.598% for trunk (this are average values). Can you share the raw numbers? Are the differences statistically significant? -- Florian Weimer / Red Hat Product Security Team
Re: [C++ Patch] PR 58466
... for now I'm reverting this commit. The issue is just an ICE on invalid and the fix is causing problems, per c++/58932 - sorry about that. Thanks, Paolo. /// /cp 2013-10-31 Paolo Carlini PR c++/58932 Revert: 2013-10-18 Paolo Carlini PR c++/58466 * pt.c (most_specialized_class): Bump processing_template_decl for get_class_bindings. /testsuite 2013-10-31 Paolo Carlini PR c++/58932 Revert: 2013-10-18 Paolo Carlini PR c++/58466 * g++.dg/cpp0x/variadic145.C: New. * g++.dg/cpp0x/sfinae49.C: New. Index: cp/pt.c === --- cp/pt.c (revision 204249) +++ cp/pt.c (working copy) @@ -18616,15 +18616,10 @@ most_specialized_class (tree type, tree tmpl, tsub if (spec_tmpl == error_mark_node) return error_mark_node; - ++processing_template_decl; - tree parms = DECL_INNERMOST_TEMPLATE_PARMS (spec_tmpl); spec_args = get_class_bindings (tmpl, parms, partial_spec_args, args); - - --processing_template_decl; - if (spec_args) { if (outer_args) Index: testsuite/g++.dg/cpp0x/sfinae49.C === --- testsuite/g++.dg/cpp0x/sfinae49.C (revision 0) +++ testsuite/g++.dg/cpp0x/sfinae49.C (working copy) @@ -0,0 +1,29 @@ +// PR c++/58932 +// { dg-do compile { target c++11 } } + +using nullptr_t = decltype(nullptr); + +template +struct B { +static float& int_if_addable(); +}; + +template +struct B { +static int& int_if_addable(); +}; + +struct X { }; + +struct Y { }; +Y operator+(Y, Y); + +struct Z { }; +Z operator+(Z, Z) = delete; + +int main() +{ + float& a = B::int_if_addable(); + int& b = B::int_if_addable(); + float& c = B::int_if_addable(); +} Index: testsuite/g++.dg/cpp0x/variadic145.C === --- testsuite/g++.dg/cpp0x/variadic145.C(revision 204249) +++ testsuite/g++.dg/cpp0x/variadic145.C(working copy) @@ -1,10 +0,0 @@ -// PR c++/58466 -// { dg-do compile { target c++11 } } - -template struct A; - -template struct B; - -template struct B> {}; - -B> b;// { dg-error "incomplete type" }
Re: [PATCH] Invalid unpoisoning of stack redzones on ARM
>> So ok to commit? > Ok with the change suggested by Richard, I think it was: addr = copy_to_mode_reg (Pmode, XEXP (shadow_mem, 0)); Done, r204251. Tested against x64 and ARM. -Y
Re: PR C++/58708 - string literal operator templates broken
On 10/25/2013 10:40 AM, Jakub Jelinek wrote: On Fri, Oct 25, 2013 at 10:29:41AM -0400, Ed Smith-Rowland wrote: 2013-10-25 Edward Smith-Rowland <3dw...@verizon.net> PR c++/58708 * parser.c (make_string_pack): Discover non-const type and size of character and build parm pack with correct type and chars. gcc/testsuite: 2013-10-25 Edward Smith-Rowland <3dw...@verizon.net> PR c++/58708 *g++.dg/cpp1y/pr58708.C : New. --- testsuite/g++.dg/cpp1y/pr58708.C(revision 0) +++ testsuite/g++.dg/cpp1y/pr58708.C(working copy) @@ -0,0 +1,91 @@ +// { dg-options -std=c++1y } +// { dg-do run } + +template + struct integral_constant + { +static constexpr _Tp value = __v; +typedef _Tp value_type; +typedef integral_constant<_Tp, __v> type; +constexpr operator value_type() const { return value; } +constexpr value_type operator()() const { return value; } + }; + +template + constexpr _Tp integral_constant<_Tp, __v>::value; + +typedef integral_constant true_type; + +typedef integral_constantfalse_type; + +template + struct is_same + : public false_type { }; + +template + struct is_same<_Tp, _Tp> + : public true_type { }; Why not just the minimal: template< class T, class U > struct is_same { static constexpr bool value = false; }; template< class T > struct is_same { static constexpr bool value = true; }; other tests are using? Jakub All, Here is a new patch. It's the same patch but a lighter testcase. Built and tested on x86_64-linux. OK? Ed gcc/cp: 2013-10-31 Edward Smith-Rowland <3dw...@verizon.net> PR c++/58708 * parser.c (make_string_pack): Discover non-const type and size of character and build parm pack with correct type and chars. gcc/testsuite: 2013-10-31 Edward Smith-Rowland <3dw...@verizon.net> PR c++/58708 *g++.dg/cpp1y/pr58708.C : New. Index: cp/parser.c === --- cp/parser.c (revision 203997) +++ cp/parser.c (working copy) @@ -3793,22 +3793,39 @@ tree charvec; tree argpack = make_node (NONTYPE_ARGUMENT_PACK); const char *str = TREE_STRING_POINTER (value); - int i, len = TREE_STRING_LENGTH (value) - 1; + int sz = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (value; + int len = TREE_STRING_LENGTH (value) / sz - 1; tree argvec = make_tree_vec (2); - tree string_char_type_node = TREE_TYPE (TREE_TYPE (value)); + tree str_char_type_node = TREE_TYPE (TREE_TYPE (value)); + str_char_type_node = TYPE_MAIN_VARIANT (str_char_type_node); /* First template parm is character type. */ - TREE_VEC_ELT (argvec, 0) = string_char_type_node; + TREE_VEC_ELT (argvec, 0) = str_char_type_node; /* Fill in CHARVEC with all of the parameters. */ charvec = make_tree_vec (len); - for (i = 0; i < len; ++i) -TREE_VEC_ELT (charvec, i) = build_int_cst (string_char_type_node, str[i]); + if (sz == 1) +{ + for (int i = 0; i < len; ++i) + TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, str[i]); +} + else if (sz == 2) +{ + const uint16_t *num = (const uint16_t *)str; + for (int i = 0; i < len; ++i) + TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, num[i]); +} + else if (sz == 4) +{ + const uint32_t *num = (const uint32_t *)str; + for (int i = 0; i < len; ++i) + TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, num[i]); +} /* Build the argument packs. */ SET_ARGUMENT_PACK_ARGS (argpack, charvec); - TREE_TYPE (argpack) = string_char_type_node; + TREE_TYPE (argpack) = str_char_type_node; TREE_VEC_ELT (argvec, 1) = argpack; Index: testsuite/g++.dg/cpp1y/pr58708.C === --- testsuite/g++.dg/cpp1y/pr58708.C(revision 0) +++ testsuite/g++.dg/cpp1y/pr58708.C(working copy) @@ -0,0 +1,60 @@ +// { dg-options -std=c++1y } +// { dg-do run } + +template + struct is_same + { +static constexpr bool value = false; + }; + +template + struct is_same<_Tp, _Tp> + { +static constexpr bool value = true; + }; + +template + struct Foo + { +using char_type = CharT; +char_type chars[sizeof...(Str)]{Str...}; + }; + +template + Foo + operator""_foo() + { +return Foo(); + } + +int +main() +{ + auto fooU = U"\x1\x10001\x10002"_foo; + if (is_same::value != true) __builtin_abort(); + if (sizeof(fooU.chars)/sizeof(char32_t) != 3) __builtin_abort(); + if (fooU.chars[0] != 65536) __builtin_abort(); + if (fooU.chars[1] != 65537) __builtin_abort(); + if (fooU.chars[2] != 65538) __builtin_abort(); + + auto foo = "\x61\x62\x63"_foo; + if (is_same::value != true) __builtin_abort(); + if (sizeof(foo.chars)/sizeof(char) != 3) __builtin_abort(); + if (foo.chars[0] != 97) __builtin_abort(); + if (foo.chars[1] != 98) __builtin_a
Re: PR C++/58708 - string literal operator templates broken
On Thu, Oct 31, 2013 at 08:34:55AM -0400, Ed Smith-Rowland wrote: > 2013-10-31 Edward Smith-Rowland <3dw...@verizon.net> > > PR c++/58708 > * parser.c (make_string_pack): Discover non-const type and size > of character and build parm pack with correct type and chars. > > gcc/testsuite: > > 2013-10-31 Edward Smith-Rowland <3dw...@verizon.net> > > PR c++/58708 > *g++.dg/cpp1y/pr58708.C : New. The testcase LGTM, the ChangeLog entry doesn't have space after * and has extra space before : (and both the PR and * g++.dg/ line should be indented by a single tab and no other spaces). For the C++ parser change I'm deferring it to Jason, if it has been already approved, the patch is ok, if not, Jason needs to ack it. Jakub
[PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals
Hello, In this problem report, the compiler is fed a (bogus) translation unit in which some literals contains bytes whose value is zero. The preprocessor detects that and proceeds to emit diagnostics for that king of bogus literals. But then when the diagnostics machinery re-reads the input file again to display the bogus literals with a caret, it attempts to calculate the length of each of the lines it got using fgets. The line length calculation is done using strlen. But that doesn't work well when the content of the line can have several zero bytes. The result is that the read_line never sees the end of the line because strlen repeatedly reports that the line ends before the end-of-line character; so read_line thinks its buffer for reading the line is too small; it thus increases the buffer, leading to a huge memory consumption, pain and disaster. The patch below introduces a new string_length() function that can return the length of a string contained in a buffer even if the string contains zero bytes; it does so by starting from the end of the buffer and stops when it encounters the first non-null byte; for that to work, the buffer must have been totally zeroed before getting data. read_line is then modified to return the length of the line along with the line itself, as the line can now contain zero bytes. Callers of read_line are adjusted consequently. diagnostic_show_locus() is modified to consider that a line can have characters of value zero, and so just show a white space when instructed to display one of these characters. Tested on x86_64-unknown-linux-gnu against trunk. I realize this is diagnostics code and I am supposed to be a maintainer for it, but I'd appreciate a review for it nonetheless. Thanks. gcc/ChangeLog: * input.h (location_get_source_line): Take an additional line_size parameter by reference. * input.c (string_length): New static function definition. (read_line): Take an additional line_length output parameter to be set to the size of the line. Use the new string_length function to compute the size of the line returned by fgets, rather than using strlen. Ensure that the buffer is initially zeroed; ensure that when growing the buffer too. (location_get_source_line): Take an additional output line_len parameter. Update the use of read_line to pass it the line_len parameter. * diagnostic.c (adjust_line): Take an additional input parameter for the length of the line, rather than calculating it with strlen. (diagnostic_show_locus): Adjust the use of location_get_source_line and adjust_line with respect to their new signature. While displaying a line now, do not stop at the first null byte. Rather, display the zero byte as a space and keep going until we reach the size of the line. gcc/testsuite/ChangeLog: * c-c++-common/cpp/warning-zero-in-literals-1.c: New test file. --- gcc/diagnostic.c | 17 +++--- gcc/input.c| 60 + gcc/input.h| 3 +- .../c-c++-common/cpp/warning-zero-in-literals-1.c | Bin 0 -> 240 bytes 4 files changed, 62 insertions(+), 18 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/cpp/warning-zero-in-literals-1.c diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 36094a1..0ca7081 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -259,12 +259,13 @@ diagnostic_build_prefix (diagnostic_context *context, MAX_WIDTH by some margin, then adjust the start of the line such that the COLUMN is smaller than MAX_WIDTH minus the margin. The margin is either 10 characters or the difference between the column - and the length of the line, whatever is smaller. */ + and the length of the line, whatever is smaller. The length of + LINE is given by LINE_WIDTH. */ static const char * -adjust_line (const char *line, int max_width, int *column_p) +adjust_line (const char *line, int line_width, +int max_width, int *column_p) { int right_margin = 10; - int line_width = strlen (line); int column = *column_p; right_margin = MIN (line_width - column, right_margin); @@ -284,6 +285,7 @@ diagnostic_show_locus (diagnostic_context * context, const diagnostic_info *diagnostic) { const char *line; + int line_width; char *buffer; expanded_location s; int max_width; @@ -297,22 +299,25 @@ diagnostic_show_locus (diagnostic_context * context, context->last_location = diagnostic->location; s = expand_location_to_spelling_point (diagnostic->location); - line = location_get_source_line (s); + line = location_get_source_line (s, line_width); if (line == NULL) return; max_width = context->caret_max_width; - line = adjust_line (line, max_width, &(s.column)); + line = adj
[PATCH] LRA: Fix incorrect register spill/reload
Hello, When investigating regression with LRA enabled for mips16 I found incorrect spilling and reload of registers by callee. In the case, one register was not saved, although used, and another one never used but saved/restored. The issue appears to be in setting registers ever lived and subsequent passes save/restore the wrong register(s). I have attached a patch below. I presume that the statement terminator was typed accidentally as I do not see a justification of the df_set_regs_ever_live() function to be outside the for loop. Or I am wrong? Regards, Robert * lra-spills.c (assign_spill_hard_regs): Removed statement terminator after comment. Loop body outside the for loop. diff --git a/gcc/lra-spills.c b/gcc/lra-spills.c index 7c0c630..e1cf654 100644 --- a/gcc/lra-spills.c +++ b/gcc/lra-spills.c @@ -334,8 +334,8 @@ assign_spill_hard_regs (int *pseudo_regnos, int n) for (nr = 0; nr < hard_regno_nregs[hard_regno][lra_reg_info[regno].biggest_mode]; nr++) - /* Just loop. */; - df_set_regs_ever_live (hard_regno + nr, true); + /* Just loop. */ + df_set_regs_ever_live (hard_regno + nr, true); } bitmap_clear (&ok_insn_bitmap); free (reserved_hard_regs);
Re: [PATCH, PR 10474] Split live-ranges of function arguments to help shrink-wrapping
On Thu, Oct 31, 2013 at 12:16:41AM +0100, Jakub Jelinek wrote: > On Fri, Oct 25, 2013 at 05:19:06PM +0200, Martin Jambor wrote: > > 2013-10-23 Martin Jambor > > > > PR rtl-optimization/10474 > > * ira.c (find_moveable_pseudos): Do not calculate dominance info > > nor df analysis. > > (interesting_dest_for_shprep): New function. > > (split_live_ranges_for_shrink_wrap): Likewise. > > (ira): Calculate dominance info and df analysis. Call > > split_live_ranges_for_shrink_wrap. > > > > testsuite/ > > * gcc.dg/pr10474.c: New testcase. > > * gcc.dg/ira-shrinkwrap-prep-1.c: Likewise. > > * gcc.dg/ira-shrinkwrap-prep-2.c: Likewise. > > Unfortunately this patch breaks i686-linux bootstrap, Because of this, PR 58934 and perhaps other problems, and because I have reasons to doubt that I will be able to resolve them today or tomorrow (for example seeing postreload in the backraces makes me think I'll need some help :-), I am about to commit the following to revert my patch, after it passed C and C++ bootstrap and x86_64-linux. Sorry for the breakage, Martin 2013-10-31 Martin Jambor PR rtl-optimization/58934 Revert: 2013-10-30 Martin Jambor PR rtl-optimization/10474 * ira.c (find_moveable_pseudos): Do not calculate dominance info nor df analysis. (interesting_dest_for_shprep): New function. (split_live_ranges_for_shrink_wrap): Likewise. (ira): Calculate dominance info and df analysis. Call split_live_ranges_for_shrink_wrap. testsuite/ * gcc.dg/pr10474.c: New testcase. * gcc.dg/ira-shrinkwrap-prep-1.c: Likewise. * gcc.dg/ira-shrinkwrap-prep-2.c: Likewise. diff --git a/gcc/ira.c b/gcc/ira.c index d959109..1a26fed 100644 --- b/gcc/ira.c +++ a/gcc/ira.c @@ -3990,6 +3990,9 @@ pseudo_replaced_reg.release (); pseudo_replaced_reg.safe_grow_cleared (max_regs); + df_analyze (); + calculate_dominance_info (CDI_DOMINATORS); + i = 0; bitmap_initialize (&live, 0); bitmap_initialize (&used, 0); @@ -4309,196 +4312,7 @@ regstat_free_ri (); regstat_init_n_sets_and_refs (); regstat_compute_ri (); -} - - -/* If insn is interesting for parameter range-splitting shring-wrapping - preparation, i.e. it is a single set from a hard register to a pseudo, which - is live at CALL_DOM, return the destination. Otherwise return NULL. */ - -static rtx -interesting_dest_for_shprep (rtx insn, basic_block call_dom) -{ - rtx set = single_set (insn); - if (!set) -return NULL; - rtx src = SET_SRC (set); - rtx dest = SET_DEST (set); - if (!REG_P (src) || !HARD_REGISTER_P (src) - || !REG_P (dest) || HARD_REGISTER_P (dest) - || (call_dom && !bitmap_bit_p (df_get_live_in (call_dom), REGNO (dest -return NULL; - return dest; -} - -/* Split live ranges of pseudos that are loaded from hard registers in the - first BB in a BB that dominates all non-sibling call if such a BB can be - found and is not in a loop. Return true if the function has made any - changes. */ - -static bool -split_live_ranges_for_shrink_wrap (void) -{ - basic_block bb, call_dom = NULL; - basic_block first = single_succ (ENTRY_BLOCK_PTR); - rtx insn, last_interesting_insn = NULL; - bitmap_head need_new, reachable; - vec queue; - - if (!flag_shrink_wrap) -return false; - - bitmap_initialize (&need_new, 0); - bitmap_initialize (&reachable, 0); - queue.create (n_basic_blocks); - - FOR_EACH_BB (bb) -FOR_BB_INSNS (bb, insn) - if (CALL_P (insn) && !SIBLING_CALL_P (insn)) - { - if (bb == first) - { - bitmap_clear (&need_new); - bitmap_clear (&reachable); - queue.release (); - return false; - } - - bitmap_set_bit (&need_new, bb->index); - bitmap_set_bit (&reachable, bb->index); - queue.quick_push (bb); - break; - } - - if (queue.is_empty ()) -{ - bitmap_clear (&need_new); - bitmap_clear (&reachable); - queue.release (); - return false; -} - - while (!queue.is_empty ()) -{ - edge e; - edge_iterator ei; - - bb = queue.pop (); - FOR_EACH_EDGE (e, ei, bb->succs) - if (e->dest != EXIT_BLOCK_PTR - && bitmap_set_bit (&reachable, e->dest->index)) - queue.quick_push (e->dest); -} - queue.release (); - - FOR_BB_INSNS (first, insn) -{ - rtx dest = interesting_dest_for_shprep (insn, NULL); - if (!dest) - continue; - - if (DF_REG_DEF_COUNT (REGNO (dest)) > 1) - { - bitmap_clear (&need_new); - bitmap_clear (&reachable); - return false; - } - - for (df_ref use = DF_REG_USE_CHAIN (REGNO(dest)); - use; - use = DF_REF_NEXT_REG (use)) - { - if (NONDEBUG_INSN_P (DF_REF_INSN (use)) - && GET_CODE (DF_REF_REG (use)) == SUBREG) - { - /* This is
Re: C++14 digit separators..
OK. Jason
Re: [PATCH GCC]Simplify address expression in IVOPT
On 10/30/13 14:46, Richard Biener wrote: On Tue, Oct 29, 2013 at 10:18 AM, bin.cheng wrote: Hi, I noticed that IVOPT generates complex address expressions like below for iv base. &arr_base[0].y &arr[0] &MEM[p+o] It's even worse for targets support auto-increment addressing mode because IVOPT adjusts such base expression with +/- step, then creates below: &arr_base[0].y +/- step &arr[0] +/- step &MEM[p+o] +/- step It has two disadvantages: 1) Cost computation in IVOPT can't handle complex address expression and general returns spill_cost for it, which is bad since address iv is important to IVOPT. 2) IVOPT creates duplicate candidates for IVs which have same value in different forms, for example, two candidates are generated with each for "&a[0]" and "&a". Again, it's even worse for auto-increment addressing mode. This patch fixes the issue by simplifying address expression at the entry of allocating IV struct. Maybe the simplification can be put in various fold* functions but I think it might be better in this way, because: 1) fold* functions are used from front-end to various tree optimizations, the simplified address expressions may not be what each optimizer wanted. Think about parallelism related passes, they might want the array index information kept for further analysis. 2) In some way, the simplification is conflict with current implementation of fold* function. Take fold_binary_loc as an example, it tries to simplify "&a[i1] +p c* i2" into "&a[i1+i2]". Of course we can simplify in this way for IVOPT too, but that will cause new problems like: a) we have to add code in IVOPT to cope with complex ARRAY_REF which is the exactly thing we want to avoid; b) the simplification can't always be done because of the sign/unsigned offset problem (especially for auto-increment addressing mode). 3) There are many entry point for fold* functions, the change will be non-trivial. 4) The simplification is only done in alloc_iv for true (not duplicate ones) iv struct, the number of such iv should be moderate. With these points, I think it might be a win to do the simplification in IVOPT and create a kind of sand box to let IVOPT play. Any suggestions? Bootstrap and tested on x86/x86_64/arm. The patch causes three cases failed on some target, but all of them are false alarm, which can be resolved by refining test cases to check more accurate information. Is it OK? Hmm. I think you want what get_inner_reference_aff does, using the return value of get_inner_reference as starting point for determine_base_object. And you don't want to restrict yourselves so much on what exprs to process, but only exclude DECL_Ps. Just amend get_inner_reference_aff to return the tree base object. Or, update determine_base_object to handle MEM_REF, ARRAY_REF, COMPONENT_REF, etc. by calling get_inner_reference to get the base and continuing the recursive determine_base_object on the return value (TREE_OPERAND (base, 0)). Calling an amended get_inner_reference_aff can be expensive, as the function will also spend time in transforming the reference from tree to aff_tree. Yufeng
Re: [PATCH] Time profiler - phase 1
Martin Liška writes: > Hello, >I've cooperating with Jan on a new profile-based function > reordering stuff. This first patch introduces a new GCOV counter that > instruments each function call and stores the time of first run of a > function. I'm curious, do you have any numbers how much that slows down a typical instrumented run? Seems like heavy weight instrumentation. -Andi -- a...@linux.intel.com -- Speaking for myself only
Re: C++ PATCH to deal with trivial but non-callable [cd]tors
On 10/25/2013 03:04 PM, Jason Merrill wrote: In C++ all classes have destructors, but we try to defer building the implicit declaration. My patch causes us to build those implicit declarations more often, which is probably a bit of a memory regression, We can still avoid doing this in C++98 mode. Tested x86_64-pc-linux-gnu, applying to trunk. commit 7b8a53224af20adaa67a3df38523fcc0051cec3d Author: Jason Merrill Date: Thu Oct 31 09:39:54 2013 -0400 * class.c (type_build_ctor_call): Return early in C++98 mode. (type_build_dtor_call): Likewise. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 43f90d7..64681ba 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5163,6 +5163,8 @@ type_build_ctor_call (tree t) return false; if (!TYPE_HAS_DEFAULT_CONSTRUCTOR (inner)) return true; + if (cxx_dialect < cxx11) +return false; /* A user-declared constructor might be private, and a constructor might be trivial but deleted. */ for (tree fns = lookup_fnfields_slot (inner, complete_ctor_identifier); @@ -5188,6 +5190,8 @@ type_build_dtor_call (tree t) if (!CLASS_TYPE_P (inner) || ANON_AGGR_TYPE_P (inner) || !COMPLETE_TYPE_P (inner)) return false; + if (cxx_dialect < cxx11) +return false; /* A user-declared destructor might be private, and a destructor might be trivial but deleted. */ for (tree fns = lookup_fnfields_slot (inner, complete_dtor_identifier);
Re: PING: Fwd: Re: [patch] implement Cilk Plus simd loops on trunk
PING On 10/18/13 13:48, Aldy Hernandez wrote: On 10/02/13 16:53, Jason Merrill wrote: Sorry for the delay, and thank you for the review. On 08/27/2013 04:03 PM, Aldy Hernandez wrote: + /* First, try to parse as an initialized declaration. See + cp_parser_condition, from whence the bulk of this is copied. */ You didn't do this copy, but I'd appreciate it if you could reintegrate this with cp_parser_condition. I notice that there's already been significant drift: this copied code doesn't recognize {} initialization. This has the potential of throwing my mind for a spin. Can I do this as a followup, and keep it simple for now? + else if (!TREE_TYPE (e) || !TREE_CONSTANT (e) + || !INTEGRAL_TYPE_P (TREE_TYPE (e))) +cp_parser_error (parser, + "step size must be an integer constant"); Can't the step size be a value-dependent expression like a template non-type parameter? Fixed. I also found some nuances in how we were (NOT) handling variables as the standard mentioned, both for C and C++. Fixed as well, and added testcases when appropriate. + if (cp_lexer_next_token_is_keyword (parser->lexer, RID_STATIC) + || cp_lexer_next_token_is_keyword (parser->lexer, RID_REGISTER) + || cp_lexer_next_token_is_keyword (parser->lexer, RID_EXTERN) + || cp_lexer_next_token_is_keyword (parser->lexer, RID_MUTABLE) + || cp_lexer_next_token_is_keyword (parser->lexer, RID_THREAD)) +{ + error_at (loc, "storage class is not allowed"); + cp_lexer_consume_token (parser->lexer); +} How is this different from any other for-loop? Sigh, frustratingly because the standard says so. + gcc_assert (for_keyword == RID_FOR); + + if (!cp_lexer_next_token_is_keyword (parser->lexer, for_keyword)) +{ + if (for_keyword == RID_FOR) A lot of code in this function tests for_keyword after the assert. A comment lower down says + /* Handle _Cilk_for here when implemented. */ + gcc_unreachable (); So do we need the earlier assert? At least add a comment to it. Removed. How does this look? Aldy
Re: [Patch] Fix canadian cross build on systems with no fenv.h
On 30 October 2013 17:17, Steve Ellcey wrote: > > Tested with both my canadian cross build and a standard cross build > targetting mips-mti-elf. > > OK for checkin? Yes, thanks.
RE: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals
Hi, if you want to read zero-chars, why don't you simply use fgetc, optionally replacing '\0' with ' ' in read_line? Bernd.
Re: [PATCH] LRA: Fix incorrect register spill/reload
On 10/31/2013 09:23 AM, Robert Suchanek wrote: > Hello, > > When investigating regression with LRA enabled for mips16 I found incorrect > spilling and reload of > registers by callee. In the case, one register was not saved, although used, > and another one never > used but saved/restored. > > The issue appears to be in setting registers ever lived and subsequent passes > save/restore the wrong > register(s). I have attached a patch below. I presume that the statement > terminator was > typed accidentally as I do not see a justification of the > df_set_regs_ever_live() function to be outside > the for loop. Or I am wrong? No, you are not wrong. It looks a typo for me. It was not found earlier as it is used right now only for x86 general reg spills into sse regs and sse regs are not saved. Robert, thanks for finding it and informing. You can commit the patch into the trunk. > > > * lra-spills.c (assign_spill_hard_regs): Removed statement terminator > after comment. > Loop body outside the for loop. > > diff --git a/gcc/lra-spills.c b/gcc/lra-spills.c > index 7c0c630..e1cf654 100644 > --- a/gcc/lra-spills.c > +++ b/gcc/lra-spills.c > @@ -334,8 +334,8 @@ assign_spill_hard_regs (int *pseudo_regnos, int n) >for (nr = 0; >nr < > hard_regno_nregs[hard_regno][lra_reg_info[regno].biggest_mode]; >nr++) > - /* Just loop. */; > - df_set_regs_ever_live (hard_regno + nr, true); > + /* Just loop. */ > +df_set_regs_ever_live (hard_regno + nr, true); > } >bitmap_clear (&ok_insn_bitmap); >free (reserved_hard_regs); > >
C++ PATCH for c++/58162 (wrong error with NSDMI, const and move ctor)
We're building up the full initialization for the non-static data member in cp_parser_late_parse_one_default_arg, so we don't need to do it again when we use the NSDMI. Tested x86_64-pc-linux-gnu, applying to trunk. commit a0065b92a8039a07eb0d5fa577b919e820d86590 Author: Jason Merrill Date: Tue Sep 24 06:15:28 2013 -0500 PR c++/58162 * parser.c (cp_parser_late_parse_one_default_arg): Set TARGET_EXPR_DIRECT_INIT_P. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 9e28ced..bbc8e75 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -23212,6 +23212,9 @@ cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl, && CONSTRUCTOR_IS_DIRECT_INIT (parsed_arg)) flags = LOOKUP_NORMAL; parsed_arg = digest_init_flags (TREE_TYPE (decl), parsed_arg, flags); + if (TREE_CODE (parsed_arg) == TARGET_EXPR) + /* This represents the whole initialization. */ + TARGET_EXPR_DIRECT_INIT_P (parsed_arg) = true; } } diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi9.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi9.C new file mode 100644 index 000..febe0ec --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi9.C @@ -0,0 +1,13 @@ +// PR c++/58162 +// { dg-require-effective-target c++11 } + +struct A { + A(); + A(A&&); +}; + +struct B { + A const a = A(); +}; + +B b;
Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals
On Thu, Oct 31, 2013 at 03:36:07PM +0100, Bernd Edlinger wrote: > if you want to read zero-chars, why don't you simply use fgetc, > optionally replacing '\0' with ' ' in read_line? Because it is too slow? getline(3) would be much better for this purpose, though of course it is a GNU extension in glibc and so we'd need some fallback, which very well could be the fgetc or something similar. Jakub
Re: C++ PATCH to deal with trivial but non-callable [cd]tors
> I think a good way to check for any non-trivial methods would be to > check trivial_type_p in the front end and then see if there are any > !DECL_ARTIFICIAL decls in TYPE_METHODS. Revised patch attached, tested on x86-64/Linux. 2013-10-31 Eric Botcazou c-family/ * c-ada-spec.h (cpp_operation): Add IS_TRIVIAL. (dump_ada_specs): Adjust prototype of second callback. * c-ada-spec.c (cpp_check): New global variable. (dump_ada_nodes): Remove cpp_check parameter and do not pass it down. (print_generic_ada_decl): Likewise. (has_static_fields): Change return type to bool and add guard. (has_nontrivial_methods): New predicate. (is_tagged_type): Change return type to bool. (separate_class_package): Call has_nontrivial_methods. (pp_ada_tree_identifier): Minor tweaks. (dump_ada_function_declaration): Adjust calls to dump_generic_ada_node. (dump_ada_array_domains): Likewise. (dump_ada_array_type): Likewise. (dump_template_types): Remove cpp_check parameter and do not pass it to dump_generic_ada_node. (dump_ada_template): Likewise. (dump_generic_ada_node): Remove cpp_check parameter and do not pass it recursively. (print_ada_methods): Change return type to integer. Remove cpp_check parameter and do not pass it down. (dump_nested_types): Remove cpp_check parameter and do not pass it to dump_generic_ada_node. (print_ada_declaration): Likewise. Test RECORD_OR_UNION_TYPE_P before accessing methods. (print_ada_struct_decl): Remove cpp_check parameter and do not pass it down. Use has_nontrivial_methods to recognize C++ classes. Use return value of print_ada_methods. (dump_ads): Rename cpp_check parameter to check and adjust prototype. Set cpp_check to it before invoking dump_ada_nodes. (dump_ada_specs): Likewise. cp/ * decl2.c (cpp_check): Change type of first parameter and deal with IS_TRIVIAL. -- Eric BotcazouIndex: c-family/c-ada-spec.h === --- c-family/c-ada-spec.h (revision 204201) +++ c-family/c-ada-spec.h (working copy) @@ -29,13 +29,14 @@ typedef enum { IS_CONSTRUCTOR, IS_DESTRUCTOR, IS_COPY_CONSTRUCTOR, - IS_TEMPLATE + IS_TEMPLATE, + IS_TRIVIAL } cpp_operation; extern location_t decl_sloc (const_tree, bool); extern void collect_ada_nodes (tree, const char *); extern void collect_source_ref (const char *); extern void dump_ada_specs (void (*)(const char *), - int (*)(tree, cpp_operation)); + int (*)(const_tree, cpp_operation)); #endif /* ! C_ADA_SPEC_H */ Index: c-family/c-ada-spec.c === --- c-family/c-ada-spec.c (revision 204201) +++ c-family/c-ada-spec.c (working copy) @@ -46,32 +46,31 @@ along with GCC; see the file COPYING3. #endif /* HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG */ /* Local functions, macros and variables. */ -static int dump_generic_ada_node (pretty_printer *, tree, tree, - int (*)(tree, cpp_operation), int, int, bool); -static int print_ada_declaration (pretty_printer *, tree, tree, - int (*cpp_check)(tree, cpp_operation), int); -static void print_ada_struct_decl (pretty_printer *, tree, tree, - int (*cpp_check)(tree, cpp_operation), int, - bool); +static int dump_generic_ada_node (pretty_printer *, tree, tree, int, int, + bool); +static int print_ada_declaration (pretty_printer *, tree, tree, int); +static void print_ada_struct_decl (pretty_printer *, tree, tree, int, bool); static void dump_sloc (pretty_printer *buffer, tree node); static void print_comment (pretty_printer *, const char *); -static void print_generic_ada_decl (pretty_printer *, tree, -int (*)(tree, cpp_operation), const char *); +static void print_generic_ada_decl (pretty_printer *, tree, const char *); static char *get_ada_package (const char *); -static void dump_ada_nodes (pretty_printer *, const char *, - int (*)(tree, cpp_operation)); +static void dump_ada_nodes (pretty_printer *, const char *); static void reset_ada_withs (void); static void dump_ada_withs (FILE *); static void dump_ads (const char *, void (*)(const char *), - int (*)(tree, cpp_operation)); + int (*)(const_tree, cpp_operation)); static char *to_ada_name (const char *, int *); static bool separate_class_package (tree); -#define INDENT(SPACE) do { \ - int i; for (i = 0; icount || LOCATION_LINE (decl_sloc (to_dump[i], false)) < LOCATION_LINE (comments->entries[j].sloc)) - print_generic_ada_decl (pp, to_dump[i++], cpp_check, source_file); + print_generic_ada_decl (pp, to_dump[i++], source_file); else break; } @@ -736,18 +734,15 @@ print_comment (pretty_printer *pp, const pp_newline (pp); } -/* Prints declaration DECL to
Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals
Jakub Jelinek writes: > On Thu, Oct 31, 2013 at 03:36:07PM +0100, Bernd Edlinger wrote: >> if you want to read zero-chars, why don't you simply use fgetc, >> optionally replacing '\0' with ' ' in read_line? > > Because it is too slow? > > getline(3) would be much better for this purpose, though of course > it is a GNU extension in glibc and so we'd need some fallback, which > very well could be the fgetc or something similar. So would getline (+ the current patch as a fallback) be acceptable? -- Dodji
[gomp4 simd, RFC] Simple fix to override vectorization cost estimation.
Hi All, Here is a simple fix which allows to vectorize loop marked with 'pragma omp simd' even if cost model tells us that vectorization is not profitable. I checked that on simple test-case is works as expected. Is it Ok for trunk? ChangeLog: 2013-10-31 Yuri Rumyantsev * tree-vect-loop.c (vect_estimate_min_profitable_iters): Override cost estimation for loops marked as vectorizable. patch Description: Binary data
Re: [v3 patch] Extend smart ptr assertions to reject void*
On 30 October 2013 19:49, Jonathan Wakely wrote: > Because of the GNU extension that allows sizeof(void) we fail to > reject ill-formed programs. This patch fixes that. > > 2013-10-30 Jonathan Wakely > > * include/bits/shared_ptr (__shared_ptr): Assert non-void pointer. > * include/bits/shared_ptr (default_delete): Likewise. > * include/backward/auto_ptr.h (__shared_ptr(auto_ptr&&)): Likewise. > * testsuite/20_util/shared_ptr/cons/58839.cc: Do not use > default_delete. > * testsuite/20_util/shared_ptr/cons/void_neg.cc: New. > * testsuite/20_util/default_delete/void_neg.cc: New. > * testsuite/20_util/shared_ptr/cons/43820_neg.cc: Adjust line numbers. > * testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise. > > Tested x86_64-linux, committed to trunk. And this just corrects the recently-added testcase on the 4.8 branch. commit 969f89d2ee9fdaef87a94efe116febac2a47565a Author: Jonathan Wakely Date: Thu Oct 31 14:35:51 2013 + * testsuite/20_util/shared_ptr/cons/58839.cc: Do not use default_delete. diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58839.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58839.cc index 6ad2564..f78a07f 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58839.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58839.cc @@ -22,8 +22,12 @@ // libstdc++/58839 +struct D { + void operator()(void*) const noexcept { } +}; + void test01() { - std::unique_ptr y; + std::unique_ptr y; std::shared_ptr x = std::move(y); }
Re: [gomp4 simd, RFC] Simple fix to override vectorization cost estimation.
On Thu, Oct 31, 2013 at 07:02:28PM +0400, Yuri Rumyantsev wrote: > Here is a simple fix which allows to vectorize loop marked with > 'pragma omp simd' even if cost model tells us that vectorization is > not profitable. > I checked that on simple test-case is works as expected. > > Is it Ok for trunk? > > ChangeLog: > > 2013-10-31 Yuri Rumyantsev > > * tree-vect-loop.c (vect_estimate_min_profitable_iters): Override > cost estimation for loops marked as vectorizable. That looks too simplistics, IMHO it is undesirable to disregard the profitability checks together. For #pragma omp simd or #pragma simd loops, I can understand that we should admit our cost model is not very high quality and so in border cases consider vectorizing rather than not vectorizing, say for force_vect by increasing the scalar cost by some factor or decreasing vector cost by some factor, but disregarding it altogether doesn't look wise. The question is what factor should we use? 150% of scalar cost, something else? Jakub
[patch] optimize stack checking for leaf functions
Given that we maintain a protection area of STACK_CHECK_PROTECT bytes during stack checking, there is no point in checking for leaf functions if: 1. the static frame size is lower than STACK_CHECK_PROTECT bytes, and 2. there is no dynamic frame allocation. The attached patch does that for the back-ends which implement static stack checking modulo Alpha. Tested on a bunch of platforms covering the various cases, any objections (given that I wrote essentially all the code here)? 2013-10-31 Eric Botcazou * config/i386/i386.c (ix86_expand_prologue): Optimize stack checking for leaf functions without dynamic stack allocation. * config/ia64/ia64.c (ia64_emit_probe_stack_range): Adjust. (ia64_expand_prologue): Likewise. * config/mips/mips.c (mips_expand_prologue): Likewise. * config/rs6000/rs6000.c (rs6000_emit_prologue): Likewise. * config/sparc/sparc.c (sparc_expand_prologue): Likewise. (sparc_flat_expand_prologue): Likewise. -- Eric BotcazouIndex: config/sparc/sparc.c === --- config/sparc/sparc.c (revision 204201) +++ config/sparc/sparc.c (working copy) @@ -5362,8 +5362,17 @@ sparc_expand_prologue (void) if (flag_stack_usage_info) current_function_static_stack_size = size; - if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK && size) -sparc_emit_probe_stack_range (STACK_CHECK_PROTECT, size); + if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK) +{ + if (crtl->is_leaf && !cfun->calls_alloca) + { + if (size > PROBE_INTERVAL && size > STACK_CHECK_PROTECT) + sparc_emit_probe_stack_range (STACK_CHECK_PROTECT, + size - STACK_CHECK_PROTECT); + } + else if (size > 0) + sparc_emit_probe_stack_range (STACK_CHECK_PROTECT, size); +} if (size == 0) ; /* do nothing. */ @@ -5464,8 +5473,17 @@ sparc_flat_expand_prologue (void) if (flag_stack_usage_info) current_function_static_stack_size = size; - if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK && size) -sparc_emit_probe_stack_range (STACK_CHECK_PROTECT, size); + if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK) +{ + if (crtl->is_leaf && !cfun->calls_alloca) + { + if (size > PROBE_INTERVAL && size > STACK_CHECK_PROTECT) + sparc_emit_probe_stack_range (STACK_CHECK_PROTECT, + size - STACK_CHECK_PROTECT); + } + else if (size > 0) + sparc_emit_probe_stack_range (STACK_CHECK_PROTECT, size); +} if (sparc_save_local_in_regs_p) emit_save_or_restore_local_in_regs (stack_pointer_rtx, SPARC_STACK_BIAS, Index: config/i386/i386.c === --- config/i386/i386.c (revision 204201) +++ config/i386/i386.c (working copy) @@ -10653,8 +10653,12 @@ ix86_expand_prologue (void) if (STACK_CHECK_MOVING_SP) { - ix86_adjust_stack_and_probe (allocate); - allocate = 0; + if (!(crtl->is_leaf && !cfun->calls_alloca + && allocate <= PROBE_INTERVAL)) + { + ix86_adjust_stack_and_probe (allocate); + allocate = 0; + } } else { @@ -10664,9 +10668,26 @@ ix86_expand_prologue (void) size = 0x8000 - STACK_CHECK_PROTECT - 1; if (TARGET_STACK_PROBE) - ix86_emit_probe_stack_range (0, size + STACK_CHECK_PROTECT); + { + if (crtl->is_leaf && !cfun->calls_alloca) + { + if (size > PROBE_INTERVAL) + ix86_emit_probe_stack_range (0, size); + } + else + ix86_emit_probe_stack_range (0, size + STACK_CHECK_PROTECT); + } else - ix86_emit_probe_stack_range (STACK_CHECK_PROTECT, size); + { + if (crtl->is_leaf && !cfun->calls_alloca) + { + if (size > PROBE_INTERVAL && size > STACK_CHECK_PROTECT) + ix86_emit_probe_stack_range (STACK_CHECK_PROTECT, + size - STACK_CHECK_PROTECT); + } + else + ix86_emit_probe_stack_range (STACK_CHECK_PROTECT, size); + } } } Index: config/ia64/ia64.c === --- config/ia64/ia64.c (revision 204201) +++ config/ia64/ia64.c (working copy) @@ -3206,61 +3206,54 @@ gen_fr_restore_x (rtx dest, rtx src, rtx #define BACKING_STORE_SIZE(N) ((N) > 0 ? ((N) + (N)/63 + 1) * 8 : 0) /* Emit code to probe a range of stack addresses from FIRST to FIRST+SIZE, - inclusive. These are offsets from the current stack pointer. SOL is the - size of local registers. ??? This clobbers r2 and r3. */ + inclusive. These are offsets from the current stack pointer. BS_SIZE + is the size of the backing store. ??? This clobbers r2 and r3. */ static void -ia64_emit_probe_stack_range (HOST_WIDE_INT first, HOST_WIDE_INT size, int sol) +ia64_emit_probe_stack_range (HOST_WIDE_INT first, HOST_WIDE_INT size, + int bs_size) { - /* On the IA-64 there is a second stack in memory, namely the Backing Store -of the Register Stack Engine. We also need to probe it after checking -that the
Two C++ cleanup PATCHes
1) Some changes to constant initialization that were needed by an early version of the "trivial but deleted" patch. They aren't needed anymore, but still seem correct. 2) We had two functions for building cleanup calls, which is unnecessary duplication. Also, there's no point in limiting use of LOOKUP_NONVIRTUAL in cxx_maybe_build_cleanup because it will be added anyway in build_new_method_call. Tested x86_64-pc-linux-gnu, applying to trunk. commit d2987bf536b65ef47ab537d84659caebb501cfc1 Author: Jason Merrill Date: Tue Oct 22 16:35:25 2013 -0400 * semantics.c (cxx_eval_call_expression): Handle trivial value-initialization. * typeck2.c (store_init_value): Call maybe_constant_init after cxx_constant_value. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index bbdf81a..de3e8e7 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8289,12 +8289,18 @@ cxx_eval_call_expression (const constexpr_call *old_call, tree t, return t; } - /* Shortcut trivial copy constructor/op=. */ - if (call_expr_nargs (t) == 2 && trivial_fn_p (fun)) + /* Shortcut trivial constructor/op=. */ + if (trivial_fn_p (fun)) { - tree arg = convert_from_reference (get_nth_callarg (t, 1)); - return cxx_eval_constant_expression (old_call, arg, allow_non_constant, - addr, non_constant_p, overflow_p); + if (call_expr_nargs (t) == 2) + { + tree arg = convert_from_reference (get_nth_callarg (t, 1)); + return cxx_eval_constant_expression (old_call, arg, allow_non_constant, + addr, non_constant_p, overflow_p); + } + else if (TREE_CODE (t) == AGGR_INIT_EXPR + && AGGR_INIT_ZERO_FIRST (t)) + return build_zero_init (DECL_CONTEXT (fun), NULL_TREE, false); } /* If in direct recursive call, optimize definition search. */ diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index d6ff3ca..9da8e3d 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -775,7 +775,6 @@ store_init_value (tree decl, tree init, vec** cleanups, int flags) { bool const_init; value = fold_non_dependent_expr (value); - value = maybe_constant_init (value); if (DECL_DECLARED_CONSTEXPR_P (decl) || DECL_IN_AGGR_P (decl)) { @@ -786,6 +785,7 @@ store_init_value (tree decl, tree init, vec** cleanups, int flags) else value = cxx_constant_value (value); } + value = maybe_constant_init (value); const_init = (reduced_constant_expression_p (value) || error_operand_p (value)); DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = const_init; commit 72431a75a083a8e89cb44b0f2258b6400c98add6 Author: Jason Merrill Date: Thu Oct 17 14:05:37 2013 -0400 * decl.c (cxx_maybe_build_cleanup): Always set LOOKUP_NONVIRTUAL. * decl2.c (build_cleanup): Just call cxx_maybe_build_cleanup. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 476d559..09c1daa 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -14298,9 +14298,7 @@ cxx_maybe_build_cleanup (tree decl, tsubst_flags_t complain) type = TREE_TYPE (decl); if (type_build_dtor_call (type)) { - int flags = LOOKUP_NORMAL|LOOKUP_DESTRUCTOR; - bool has_vbases = (TREE_CODE (type) == RECORD_TYPE - && CLASSTYPE_VBASECLASSES (type)); + int flags = LOOKUP_NORMAL|LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR; tree addr; tree call; @@ -14309,10 +14307,6 @@ cxx_maybe_build_cleanup (tree decl, tsubst_flags_t complain) else addr = build_address (decl); - /* Optimize for space over speed here. */ - if (!has_vbases || flag_expensive_optimizations) - flags |= LOOKUP_NONVIRTUAL; - call = build_delete (TREE_TYPE (addr), addr, sfk_complete_destructor, flags, 0, complain); if (call == error_mark_node) diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index d776471..18e0e52 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2722,26 +2722,9 @@ import_export_decl (tree decl) tree build_cleanup (tree decl) { - tree temp; - tree type = TREE_TYPE (decl); - - /* This function should only be called for declarations that really - require cleanups. */ - gcc_assert (!TYPE_HAS_TRIVIAL_DESTRUCTOR (type)); - - /* Treat all objects with destructors as used; the destructor may do - something substantive. */ - mark_used (decl); - - if (TREE_CODE (type) == ARRAY_TYPE) -temp = decl; - else -temp = build_address (decl); - temp = build_delete (TREE_TYPE (temp), temp, - sfk_complete_destructor, - LOOKUP_NORMAL|LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0, - tf_warning_or_error); - return temp; + tree clean = cxx_maybe_build_cleanup (decl, tf_warning_or_error); + gcc_assert (clean != NULL_TREE); + return clean; } /* Returns the initialization guard variable for the variable DECL,
patch to fix mips16 LRA register shuffling
The following patch fixes a problem reported by Matt Fortune. LRA generated additional moves for frame pointer eliminated into stack pointer. LRA uses register number of the elimination result when matching constraints. But it did not substitute RTL operand itself and that resulted in EXTRA_CONSTRAINT hooks failure and worse code generation. The patch was bootstrapped on x86/x86-64 and ppc64 (with LRA). Committed as rev. 204267. 2013-10-31 Vladimir Makarov * lra-constraints (process_alt_operands): Use the result elimination register for operand when matching constraints. Index: lra-constraints.c === --- lra-constraints.c (revision 204245) +++ lra-constraints.c (working copy) @@ -1466,23 +1466,32 @@ function. */ for (nop = 0; nop < n_operands; nop++) { + rtx reg; + op = no_subreg_reg_operand[nop] = *curr_id->operand_loc[nop]; /* The real hard regno of the operand after the allocation. */ hard_regno[nop] = get_hard_regno (op); - operand_reg[nop] = op; - biggest_mode[nop] = GET_MODE (operand_reg[nop]); - if (GET_CODE (operand_reg[nop]) == SUBREG) + operand_reg[nop] = reg = op; + biggest_mode[nop] = GET_MODE (op); + if (GET_CODE (op) == SUBREG) { - operand_reg[nop] = SUBREG_REG (operand_reg[nop]); + operand_reg[nop] = reg = SUBREG_REG (op); if (GET_MODE_SIZE (biggest_mode[nop]) - < GET_MODE_SIZE (GET_MODE (operand_reg[nop]))) - biggest_mode[nop] = GET_MODE (operand_reg[nop]); + < GET_MODE_SIZE (GET_MODE (reg))) + biggest_mode[nop] = GET_MODE (reg); } - if (REG_P (operand_reg[nop])) - no_subreg_reg_operand[nop] = operand_reg[nop]; + if (! REG_P (reg)) + operand_reg[nop] = NULL_RTX; + else if (REGNO (reg) >= FIRST_PSEUDO_REGISTER + || ((int) REGNO (reg) + == lra_get_elimination_hard_regno (REGNO (reg + no_subreg_reg_operand[nop] = reg; else - operand_reg[nop] = NULL_RTX; + operand_reg[nop] = no_subreg_reg_operand[nop] + /* Just use natural mode for elimination result. It should + be enough for extra constraints hooks. */ + = regno_reg_rtx[hard_regno[nop]]; } /* The constraints are made of several alternatives. Each operand's
Re: C++ PATCH to deal with trivial but non-callable [cd]tors
On 10/31/2013 10:47 AM, Eric Botcazou wrote: I think a good way to check for any non-trivial methods would be to check trivial_type_p in the front end and then see if there are any !DECL_ARTIFICIAL decls in TYPE_METHODS. Revised patch attached, tested on x86-64/Linux. Looks good. Jason
Re: [PATCH 1/n] Add conditional compare support
On 10/31/2013 02:06 AM, Zhenqiang Chen wrote: > With two compares, we might swap the order of the two compares to get a > valid combination. This is what current ARM does (Please refer > arm_select_dominace_cc_mode, cmp_and, cmp_ior, and_scc_scc and ior_scc_scc). > To improve gen_ccmp_first, we need another function/hook to determine which > compare is done first. I will double check ARM backend to avoid hook. Hmm. I hadn't thought of that, and missed that point when looking through your previous patches. I think you should have a third hook for that. ARM will need it, but IA-64 doesn't. > Hook gen_ccmp_next needs one more parameter to indicate AND/IOR since they > will generate different instructions. True, I forgot about that while writing the hook descriptions. r~
[PATCH 1/6] Convert gimple types from a union to C++ inheritance
* Makefile.in (GIMPLE_H): Add dep on is-a.h. * coretypes.h (union gimple_statement_d): Remove declaration. (gimple): Convert from being a "union gimple_statement_d *" to a "struct gimple_statement_base *". (const_gimple): Likewise (with "const"). * ggc.h (ggc_alloc_cleared_gimple_statement_d_stat): Replace with... (ggc_alloc_cleared_gimple_statement_stat): ...this. * gimple-pretty-print.c (debug): Change parameter from a "gimple_statement_d &" to a "gimple_statement_base &". (debug): Change parameter from a "gimple_statement_d *" to a "gimple_statement_base *". * gimple-pretty-print.h (debug): Update declarations as above. * gimple.c (gimple_alloc_stat): Update for renaming of ggc_alloc_cleared_gimple_statement_d_stat to ggc_alloc_cleared_gimple_statement_stat. * gimple.h: Include "is-a.h" for use by is_a_helper specializations in followup autogenerated patch. (struct gimple statement_base): Make this type usable as a base class by adding "desc", "tag" and "variable_size" to GTY, thus using opting-in to gengtype's support for simple inheritance. (gimple_statement_with_ops_base): Convert to a subclass of gimple_statement_base, dropping initial "gsbase" field. Note that this type is abstract, with no GSS_ value, and thus no GTY tag value. (gimple_statement_with_ops): Convert to a subclass of gimple_statement_with_ops_base, dropping initial "opbase" field. Add tag value to GTY marking. Update marking of op field to reflect how num_ops field is accessed via inheritance. (gimple_statement_with_memory_ops_base): Convert to a subclass of gimple_statement_with_ops_base, dropping initial "opbase" field. Add tag value to GTY marking. (gimple_statement_with_memory_ops): Convert to a subclass of public gimple_statement_with_memory_ops_base, dropping initial "membase" field. Add tag value to GTY marking. Update marking of op field to reflect how num_ops field is accessed via inheritance. (gimple_statement_call): Analogous changes that also update the marking of the "u" union. (gimple_statement_omp): Convert to a subclass of gimple_statement_base, dropping initial "gsbase" field, adding tag value to GTY marking. (gimple_statement_bind): Likewise. (gimple_statement_catch): Likewise. (gimple_statement_eh_filter): Likewise. (gimple_statement_eh_else): Likewise. (gimple_statement_eh_mnt): Likewise. (gimple_statement_phi): Likewise. (gimple_statement_eh_ctrl): Likewise. (gimple_statement_try): Likewise. (gimple_statement_wce): Likewise. (gimple_statement_asm): Convert to a subclass of gimple_statement_with_memory_ops_base, dropping initial "membase" field, adding tag value to GTY marking, and updating marking of op field. (gimple_statement_omp_critical): Convert to a subclass of gimple_statement_omp, dropping initial "omp" field, adding tag value to GTY marking. (gimple_statement_omp_for): Likewise. (gimple_statement_omp_parallel): Likewise. (gimple_statement_omp_task): Convert to a subclass of gimple_statement_omp_parallel, dropping initial "par" field, adding tag value to GTY marking. (gimple_statement_omp_sections): Convert to a subclass of gimple_statement_omp, dropping initial "omp" field, adding tag value to GTY marking. (gimple_statement_omp_continue): Convert to a subclass of gimple_statement_base, dropping initial "gsbase" field, adding tag value to GTY marking. (gimple_statement_omp_single): Convert to a subclass of gimple_statement_omp, dropping initial "omp" field, adding tag value to GTY marking. (gimple_statement_omp_atomic_load): Convert to a subclass of gimple_statement_base, dropping initial "gsbase" field, adding tag value to GTY marking. (gimple_statement_omp_atomic_store): Convert to a subclass of gimple_statement_base, dropping initial "gsbase" field, adding tag value to GTY marking. (gimple_statement_transaction): Convert to a subclass of gimple_statement_with_memory_ops_base, dropping initial "gsbase" field, adding tag value to GTY marking. (union gimple_statement_d): Remove. * system.h (CONST_CAST_GIMPLE): Update to use "struct gimple_statement_base *" rather than "union gimple_statement_d *". * tree-ssa-ccp.c (gimple_htab): Convert underlying type from gimple_statement_d to gimple_statement_base. --- gcc/Makefile.in | 2 +- gcc/coretypes.h | 5 +- gcc/ggc.h | 6 +- gcc/gi
[PATCH 2/6] Hand-written port of various accessors within gimple.h
* gimple.h (gimple_use_ops): Port from union to usage of dyn_cast. (gimple_set_use_ops): Port from union to usage of as_a. (gimple_set_vuse): Likewise. (gimple_set_vdef): Likewise. (gimple_call_internal_fn): Port from union to a static_cast, given that the type has already been asserted. (gimple_omp_body_ptr): Port from unchecked union usage to a static_cast. (gimple_omp_set_body): Likewise. --- gcc/gimple.h | 27 --- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/gcc/gimple.h b/gcc/gimple.h index f288e81..6ff7602 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -1467,9 +1467,11 @@ gimple_has_mem_ops (const_gimple g) static inline struct use_optype_d * gimple_use_ops (const_gimple g) { - if (!gimple_has_ops (g)) + const gimple_statement_with_ops *ops_stmt = +dyn_cast (g); + if (!ops_stmt) return NULL; - return g->gsops.opbase.use_ops; + return ops_stmt->use_ops; } @@ -1478,8 +1480,9 @@ gimple_use_ops (const_gimple g) static inline void gimple_set_use_ops (gimple g, struct use_optype_d *use) { - gcc_gimple_checking_assert (gimple_has_ops (g)); - g->gsops.opbase.use_ops = use; + gimple_statement_with_ops *ops_stmt = +as_a (g); + ops_stmt->use_ops = use; } @@ -1528,8 +1531,9 @@ gimple_vdef_ptr (gimple g) static inline void gimple_set_vuse (gimple g, tree vuse) { - gcc_gimple_checking_assert (gimple_has_mem_ops (g)); - g->gsmembase.vuse = vuse; + gimple_statement_with_memory_ops *mem_ops_stmt = +as_a (g); + mem_ops_stmt->vuse = vuse; } /* Set the single VDEF operand of the statement G. */ @@ -1537,8 +1541,9 @@ gimple_set_vuse (gimple g, tree vuse) static inline void gimple_set_vdef (gimple g, tree vdef) { - gcc_gimple_checking_assert (gimple_has_mem_ops (g)); - g->gsmembase.vdef = vdef; + gimple_statement_with_memory_ops *mem_ops_stmt = +as_a (g); + mem_ops_stmt->vdef = vdef; } @@ -2226,7 +2231,7 @@ static inline enum internal_fn gimple_call_internal_fn (const_gimple gs) { gcc_gimple_checking_assert (gimple_call_internal_p (gs)); - return gs->gimple_call.u.internal_fn; + return static_cast (gs)->u.internal_fn; } @@ -4031,7 +4036,7 @@ get_lineno (const_gimple stmt) static inline gimple_seq * gimple_omp_body_ptr (gimple gs) { - return &gs->omp.body; + return &static_cast (gs)->body; } /* Return the body for the OMP statement GS. */ @@ -4047,7 +4052,7 @@ gimple_omp_body (gimple gs) static inline void gimple_omp_set_body (gimple gs, gimple_seq body) { - gs->omp.body = body; + static_cast (gs)->body = body; } -- 1.7.11.7
[PATCH 0/6] Conversion of gimple types to C++ inheritance (v3)
[Shamelessly hijacking Andrew's thread about gimple.h refactoring, since this seems on-topic for that, and I'm keen to hear from Andrew on how the following would interact with his work - I *think* our two cleanups are orthogonal. [This is a revised version of the patches sent as: http://gcc.gnu.org/ml/gcc-patches/2013-08/msg01788.html and http://gcc.gnu.org/ml/gcc-patches/2013-08/msg01954.html which got bogged down in discussion of hand-written GTY hooks. This patch series updates things to make use of the new support in gengtype for simple inheritance schemes] The gimple statement types are currently implemented using a hand-coded C inheritance scheme, with a "union gimple_statement_d" holding the various possible structs for a statement. The following series of patches convert it to a C++ hierarchy, using the existing structs, eliminating the union. The "gimple" typedef changes from being a (union gimple_statement_d *) to being a: (struct gimple_statement_base *) There are no virtual functions in the new code: the sizes of the various structs are unchanged. It makes use of "is-a.h", using the as_a template function to perform downcasts, which are checked (via gcc_checking_assert) in an ENABLE_CHECKING build, and are simple casts in an unchecked build, albeit it in an inlined function rather than a macro. For example, one can write: gimple_statement_phi *phi = as_a (gsi_stmt (gsi)); and then directly access the fields of the phi, as a phi. The existing accessor functions in gimple.h become somewhat redundant in this scheme, but are preserved. The earlier versions of the patches made all of the types GTY((user)) and provided hand-written implementations of the gc and pch marker routines. In this new version we rely on the support for simple inheritance that I recently added to gengtype, by adding a "desc" to the GTY marking for the base class, and a "tag" to the marking for all of the concrete subclasses. (I say "class", but all the types remain structs since their fields are all publicly accessible). As noted in the earlier patch, I believe this is a superior scheme to the C implementation: * We can get closer to compile-time type-safety, checking the gimple code once and downcasting with an as_a, then directly accessing fields, rather than going through accessor functions that check each time. In some places we may want to replace a "gimple" with a subclass e.g. phis are always of the phi subclass, to get full compile-time type-safety. * This scheme is likely to be easier for newbies to understand. * Currently in gdb, dereferencing a gimple leads to screenfuls of text, showing all the various union values. With this, you get just the base class, and can cast it to the appropriate subclass. * With this, we're working directly with the language constructs, rather than rolling our own, and thus other tools can better understand the code. (e.g. doxygen). Again, as noted in the earlier patch series, the names of the structs are rather verbose. I would prefer to also rename them all to eliminate the "_statement" component: "gimple_statement_base" -> "gimple_base" "gimple_statement_phi" -> "gimple_phi" "gimple_statement_omp" -> "gimple_omp" etc, but I didn't do this to mimimize the patch size. But if the core maintainers are up for that, I can redo the patch series with that change also, or do that as a followup. The patch is in 6 parts; all of them are needed together. * Patch 1 of 6: This patch adds inheritance to the various gimple types, eliminating the initial baseclass fields, and eliminating the union gimple_statement_d. All the types remain structs. They become marked with GTY(()), gaining GSS_ tag values. * Patch 2 of 6: This patch ports various accessor functions within gimple.h to the new scheme. * Patch 3 of 6: This patch is autogenerated by "refactor_gimple.py" from https://github.com/davidmalcolm/gcc-refactoring-scripts There is a test suite "test_refactor_gimple.py" which may give a clearer idea of the changes that the script makes (and add confidence that it's doing the right thing). The patch converts code of the form: { GIMPLE_CHECK (gs, SOME_CODE); gimple_subclass_get/set_some_field (gs, value); } to code of this form: { some_subclass *stmt = as_a (gs); stmt->some_field = value; } It also autogenerates specializations of is_a_helper ::test equivalent to a GIMPLE_CHECK() for use by is_a and as_a. * Patch 4 of 6: This patch implement further specializations of is_a_helper ::test, for gimple_has_ops and gimple_has_mem_ops. * Patch 5 of 6: This patch does the rest of porting from union access to subclass access (all the fiddly places that the script in patch 3 couldn't handle). * Patch 6 of 6: This patch updates the gdb python pretty-printing hook. Succe
[PATCH 4/6] Implement is_a_helper <>::test specializations for various gimple types
* gimple.h (is_a_helper ::test): New. (is_a_helper ::test): New. (is_a_helper ::test): New. (is_a_helper ::test): New. --- gcc/gimple.h | 30 ++ 1 file changed, 30 insertions(+) diff --git a/gcc/gimple.h b/gcc/gimple.h index f258992..710ce04 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -1756,6 +1756,21 @@ gimple_has_ops (const_gimple g) return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN; } +template <> +template <> +inline bool +is_a_helper ::test (const_gimple gs) +{ + return gimple_has_ops (gs); +} + +template <> +template <> +inline bool +is_a_helper ::test (gimple gs) +{ + return gimple_has_ops (gs); +} /* Return true if GIMPLE statement G has memory operands. */ @@ -1765,6 +1780,21 @@ gimple_has_mem_ops (const_gimple g) return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN; } +template <> +template <> +inline bool +is_a_helper ::test (const_gimple gs) +{ + return gimple_has_mem_ops (gs); +} + +template <> +template <> +inline bool +is_a_helper ::test (gimple gs) +{ + return gimple_has_mem_ops (gs); +} /* Return the set of USE operands for statement G. */ -- 1.7.11.7
[PATCH 6/6] Update gdb hooks to reflect changes to gimple types
gcc/ * gdbhooks.py (GimplePrinter.to_string): Update lookup of code field to reflect inheritance, rather than embedding of the base gimple type. --- gcc/gdbhooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index 53abf32..c05e574 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -240,7 +240,7 @@ class GimplePrinter: def to_string (self): if long(self.gdbval) == 0: return '' -val_gimple_code = self.gdbval['gsbase']['code'] +val_gimple_code = self.gdbval['code'] val_gimple_code_name = gdb.parse_and_eval('gimple_code_name') val_code_name = val_gimple_code_name[long(val_gimple_code)] result = '<%s 0x%x' % (val_code_name.string(), -- 1.7.11.7
[PATCH 5/6] Port various places from union access to subclass access.
* gimple-streamer-in.c (input_gimple_stmt): Port from union access to use of as_a. * gimple.c (gimple_build_asm_1): Likewise. (gimple_build_try): Likewise. Also, return a specific subclass rather than just gimple. (gimple_build_resx): Port from union access to use of as_a. (gimple_build_eh_dispatch): Likewise. (gimple_build_omp_for): Likewise. Also, convert allocation of iter now that gengtype no longer provides a typed allocator function. (gimple_copy): Likewise. * gimple.h (gimple_build_try): Return a specific subclass rather than just gimple. * gimplify.c (gimplify_cleanup_point_expr): Replace union access with subclass access by making use of new return type of gimple_build_try. * tree-phinodes.c: (allocate_phi_node): Return a "gimple_statement_phi *" rather than just a gimple. (resize_phi_node): Likewise. (make_phi_node): Replace union access with subclass access by making use of new return type of allocate_phi_node. (reserve_phi_args_for_new_edge): Replace union access with as_a. (remove_phi_arg_num): Accept a "gimple_statement_phi *" rather than just a gimple. (remove_phi_args): Update for change to remove_phi_arg_num. --- gcc/gimple-streamer-in.c | 11 - gcc/gimple.c | 58 ++-- gcc/gimple.h | 3 ++- gcc/gimplify.c | 4 ++-- gcc/tree-phinodes.c | 37 -- 5 files changed, 66 insertions(+), 47 deletions(-) diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c index 4f31b83..2555dbe 100644 --- a/gcc/gimple-streamer-in.c +++ b/gcc/gimple-streamer-in.c @@ -129,13 +129,14 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in, case GIMPLE_ASM: { /* FIXME lto. Move most of this into a new gimple_asm_set_string(). */ + gimple_statement_asm *asm_stmt = as_a (stmt); tree str; - stmt->gimple_asm.ni = streamer_read_uhwi (ib); - stmt->gimple_asm.no = streamer_read_uhwi (ib); - stmt->gimple_asm.nc = streamer_read_uhwi (ib); - stmt->gimple_asm.nl = streamer_read_uhwi (ib); + asm_stmt->ni = streamer_read_uhwi (ib); + asm_stmt->no = streamer_read_uhwi (ib); + asm_stmt->nc = streamer_read_uhwi (ib); + asm_stmt->nl = streamer_read_uhwi (ib); str = streamer_read_string_cst (data_in, ib); - stmt->gimple_asm.string = TREE_STRING_POINTER (str); + asm_stmt->string = TREE_STRING_POINTER (str); } /* Fallthru */ diff --git a/gcc/gimple.c b/gcc/gimple.c index 9b1337a..e9ef8e0 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -641,21 +641,22 @@ static inline gimple gimple_build_asm_1 (const char *string, unsigned ninputs, unsigned noutputs, unsigned nclobbers, unsigned nlabels) { - gimple p; + gimple_statement_asm *p; int size = strlen (string); /* ASMs with labels cannot have outputs. This should have been enforced by the front end. */ gcc_assert (nlabels == 0 || noutputs == 0); - p = gimple_build_with_ops (GIMPLE_ASM, ERROR_MARK, -ninputs + noutputs + nclobbers + nlabels); + p = as_a ( +gimple_build_with_ops (GIMPLE_ASM, ERROR_MARK, + ninputs + noutputs + nclobbers + nlabels)); - p->gimple_asm.ni = ninputs; - p->gimple_asm.no = noutputs; - p->gimple_asm.nc = nclobbers; - p->gimple_asm.nl = nlabels; - p->gimple_asm.string = ggc_alloc_string (string, size); + p->ni = ninputs; + p->no = noutputs; + p->nc = nclobbers; + p->nl = nlabels; + p->string = ggc_alloc_string (string, size); if (GATHER_STATISTICS) gimple_alloc_sizes[(int) gimple_alloc_kind (GIMPLE_ASM)] += size; @@ -767,14 +768,14 @@ gimple_build_eh_else (gimple_seq n_body, gimple_seq e_body) KIND is either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY depending on whether this is a try/catch or a try/finally respectively. */ -gimple +gimple_statement_try * gimple_build_try (gimple_seq eval, gimple_seq cleanup, enum gimple_try_flags kind) { - gimple p; + gimple_statement_try *p; gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY); - p = gimple_alloc (GIMPLE_TRY, 0); + p = as_a (gimple_alloc (GIMPLE_TRY, 0)); gimple_set_subcode (p, kind); if (eval) gimple_try_set_eval (p, eval); @@ -804,8 +805,10 @@ gimple_build_wce (gimple_seq cleanup) gimple gimple_build_resx (int region) { - gimple p = gimple_build_with_ops (GIMPLE_RESX, ERROR_MARK, 0); - p->gimple_eh_ctrl.region = region; + gimple_statement_eh_ctrl *p = +as_a ( + gimple_build_with_ops (GIMPLE_RESX, ERROR_MARK, 0)); + p->region = region; return p; } @@ -852,8 +855,10 @@ gimple_build_switch (tree index, tree default_label, vec args) gimple gim
Re: patch to fix PR58784 (ARM LRA crash)
(this time in plain text !) > Does this mean we can now turn on LRA for ARM state by default and > start looking at performance issues if any ? With the other patch for 58785 and a small one I've to post, we are even about to turn LRA on by default completely, as the compiler now bootstrap also in thumb and first testsuite are clean :-) I juste want ton pass a full validation before. Yvan >> Ramana >> >> >> >> >> >> > 2013-10-30 Vladimir Makarov >> > >> > PR target/58784 >> > * lra.c (check_rtl): Remove address check before LRA work. >> > >> > 2013-10-30 Vladimir Makarov >> > >> > PR target/58784 >> > * gcc.target/arm/pr58784.c: New. >> >
Re: [C, C++, OpenMP] Add support for -fopenmp-simd
On Sun, Oct 27, 2013 at 10:45:57PM +0100, Tobias Burnus wrote: > The code is written such that when "-fopenmp" is used, > -f(no-)openmp-simd has no effect. The following "simd" pragmas are > listed in OpenMP 4.0 - and will all get translated into "#pragma omp > simd", only, with -fopenmp-simd: > #pragma omp simd > #pragma omp for simd > #pragma omp distribute simd > #pragma omp distribute parallel for simd > #pragma omp parallel for simd > #pragma omp teams distribute simd > #pragma omp target teams distribute simd > #pragma omp teams distribute parallel for simd > #pragma omp target teams distribute parallel for simd > > I did an all-language bootstrap, followed by regtesting on x86-64-gnu-linux. > (I did a minor change before sending this patch and will have to repeat it.) I think we should also parse #pragma omp declare reduction even for -fopenmp-simd, that is something that if not used in reduction clauses will not do anything except diagnosing errors, and it may be used in #pragma omp simd (and the combined constructs too). Also, it would be nice if the testcases for this option included also some clauses (both valid clauses for the simd itself and clauses valid for the other combined constructs together with simd that they are parsed but then thrown away). Otherwise it looks good to me. Thanks for working on it. Jakub
Re: [patch] make the libstdc++ pretty printers compatible with both Python 2 and Python3
> "Matthias" == Matthias Klose writes: Matthias> Starting with gdb 7.6, gdb can be linked with both Python 2.x Matthias> and Python 3.x. Therefore the pretty printers should be Matthias> compatible with both Python versions. Thanks for doing this. Matthias> -n = self.rbiter.next() Matthias> +n = next(self.rbiter) Matthias> -def next(self): Matthias> -item = self.rbiter.next() Matthias> +def __next__(self): Matthias> +item = next(self.rbiter) Matthias> +return zip (counter, data) I don't think these two hunks will work on Python 2.x. But, I also don't think they are really needed, as I think it's just fine to call the 'next' method on the iterator objects. Matthias> + Matthias> def display_hint (self): Matthias> return 'map' Spurious whitespace change? You didn't say how you tested this. Did you run the libstdc++ pretty-printer tests? Tom
[PATCH] Try to avoid vector mode punning in SET_DEST on i?86
Hi! On Wed, Oct 30, 2013 at 12:11:25PM +0100, Jakub Jelinek wrote: > > > the patch attempts to avoid gen_lowpart on the non-MEM lhs of the > > > unaligned > > > loads, which usually means combine will fail, by doing the load into a > > > temporary pseudo in that case and then doing a pseudo to pseudo move with > > > gen_lowpart on the rhs (which will be merged soon after into following > > > instructions). > > > > Is this similar to PR44141? There were similar problems with V4SFmode > > subregs, so combine was not able to merge load to the arithemtic insn. > > >From the work on the vectorization last year I remember many cases where > subregs (even equal size) on the LHS of instructions prevented combiner or > other RTL optimizations from doing it's job. I believe I've changed some > easy places that did that completely unnecessarily, but certainly have not > went through all the code to look for other places where this is done. > > Perhaps let's hack up a checking pass that will after expansion walk the > whole IL and complain about same sized subregs on the LHS of insns, then do > make > check with it for a couple of ISAs (-msse2,-msse4,-mavx,-mavx2 e.g.? So, I've used a hack in cfgexpand.c: --- cfgexpand.c.jj 2013-10-30 08:15:36.0 +0100 +++ cfgexpand.c 2013-10-30 16:19:33.974203309 +0100 @@ -4535,6 +4535,31 @@ expand_stack_alignment (void) } } +static void +check_vector_subregs (rtx, const_rtx pat, void *data) +{ + rtx x; + if (GET_CODE (pat) != SET) +return; + x = SET_DEST (pat); + if (GET_CODE (x) == SUBREG + && GET_CODE (SUBREG_REG (x)) == REG + && (GET_MODE_CLASS (GET_MODE (x)) == MODE_VECTOR_INT + || GET_MODE_CLASS (GET_MODE (x)) == MODE_VECTOR_FLOAT + || GET_MODE_CLASS (GET_MODE (SUBREG_REG (x))) == MODE_VECTOR_INT + || GET_MODE_CLASS (GET_MODE (SUBREG_REG (x))) == MODE_VECTOR_FLOAT) + && GET_MODE_BITSIZE (GET_MODE (x)) +== GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (x +{ + FILE *f = fopen ("/tmp/subregs", "a"); + fprintf (f, "%s %d ", main_input_filename ? main_input_filename : "-", + (int) BITS_PER_WORD); + print_inline_rtx (f, (rtx) data, 0); + putc ('\n', f); + fclose (f); +} +} + /* Translate the intermediate representation contained in the CFG from GIMPLE trees to RTL. @@ -4922,6 +4947,13 @@ gimple_expand_cfg (void) set_block_levels (DECL_INITIAL (cfun->decl), 0); default_rtl_profile (); + { +rtx insn; +for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) + if (INSN_P (insn)) + note_stores (PATTERN (insn), check_vector_subregs, insn); + } + timevar_pop (TV_POST_EXPAND); return 0; which revealed about 18000 vector mode punning subregs in SET_DEST in x86_64 64-bit i386.exp testing alone, this patch brings that down to zero (and in the whole make check-gcc down to about 40 which are from various parts of the middle-end). The disadvantage of mode punning subregs in SET_DEST is that then CSE, combine, etc. don't attempt to optimize those. Additionally, I've noticed that expand_vec_perm_palignr would happily clobber *d, that seems undesirable to me, other places always modify a copy of the structure. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2013-10-31 Jakub Jelinek * optabs.c (expand_vec_perm): Avoid vector mode punning SUBREGs in SET_DEST. * expmed.c (store_bit_field_1): Likewise. * config/i386/sse.md (movdi_to_sse, vec_pack_sfix_trunc_v2df, vec_pack_sfix_v2df, vec_shl_, vec_shr_, vec_interleave_high, vec_interleave_low): Likewise. * config/i386/i386.c (ix86_expand_vector_move_misalign, ix86_expand_sse_movcc, ix86_expand_int_vcond, ix86_expand_vec_perm, ix86_expand_sse_unpack, ix86_expand_args_builtin, ix86_expand_vector_init_duplicate, ix86_expand_vector_set, emit_reduc_half, expand_vec_perm_blend, expand_vec_perm_pshufb, expand_vec_perm_interleave2, expand_vec_perm_pshufb2, expand_vec_perm_vpshufb2_vpermq, expand_vec_perm_vpshufb2_vpermq_even_odd, expand_vec_perm_even_odd_1, expand_vec_perm_broadcast_1, expand_vec_perm_vpshufb4_vpermq2, ix86_expand_sse2_mulv4si3, ix86_expand_pinsr): Likewise. (expand_vec_perm_palignr): Likewise. Modify a copy of *d rather than *d itself. --- gcc/optabs.c.jj 2013-10-29 09:25:45.0 +0100 +++ gcc/optabs.c2013-10-31 13:20:40.384808642 +0100 @@ -6624,8 +6624,8 @@ expand_vec_perm (enum machine_mode mode, icode = direct_optab_handler (vec_perm_const_optab, qimode); if (icode != CODE_FOR_nothing) { - tmp = expand_vec_perm_1 (icode, gen_lowpart (qimode, target), - gen_lowpart (qimode, v0), + tmp = mode != qimode ? gen_reg_rtx (qimode) : target; + tmp = expand_vec_perm_1 (icode, tmp, gen_lowpar
Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals
On 31 October 2013 05:46, Dodji Seketeli wrote: > +*/ > +static size_t > +string_length (const char* buf, size_t buf_size) > +{ > + for (int i = buf_size - 1; i > 0; --i) > +{ > + if (buf[i] != 0) > + return i + 1; > + > + if (buf[i - 1] != 0) > + return i; > +} > + return 0; > +} Why do you check both buf[i] and buf[i - 1] within the loop? Cheers, Manuel.
[patch] [arm] ARM Cortex-M3/M4 tuning
Based on Julian's http://gcc.gnu.org/ml/gcc-patches/2012-07/msg01006.html and * Merged with latest mainline and applied test * Only apply to Cortex-M3 and M4 * Set LOGICAL_OP_NON_SHORT_CIRCUIT to false Test: - Coremark on M3/M4 gained 5% - GCC make check with qemu Cortex-M3 resulting following expected regressions, which will be fixed by following-up condition compare patches * gcc.target/arm/thumb2-cond-cmp-1.c: Expected fail for now. * gcc.target/arm/thumb2-cond-cmp-2.c: Likewise. * gcc.target/arm/thumb2-cond-cmp-3.c: Likewise. * gcc.target/arm/thumb2-cond-cmp-4.c: Likewise. ChangeLog: 2013-11-01 Julian Brown Joey Ye * config/arm/arm.c (arm_cortex_m_branch_cost): New. (arm_v7m_tune): New. (arm_*_tune): Add comments for Sched adj cost. * config/arm/arm-cores.def (cortex-m4, cortex-m3): Use arm_v7m_tune tuning. testsuite: 2013-11-01 Joey Ye * gcc.dg/tree-ssa/forwprop-28.c: Disable for cortex_m. * gcc.dg/tree-ssa/vrp47.c: Likewise. * gcc.dg/tree-ssa/vrp87.c: Likewise. * gcc.dg/tree-ssa/ssa-dom-thread-4.c: Ignore for cortex_m. * gcc.dg/tree-ssa/ssa-vrp-thread-1.c: Likewise. v7m_tune_allin1-131016.patch Description: Binary data
Re: Aliasing: look through pointer's def stmt
On Wed, 30 Oct 2013, Richard Biener wrote: --- gcc/tree-ssa-alias.c(revision 204188) +++ gcc/tree-ssa-alias.c(working copy) @@ -567,20 +567,29 @@ void ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size) { HOST_WIDE_INT t1, t2; ref->ref = NULL_TREE; if (TREE_CODE (ptr) == SSA_NAME) { gimple stmt = SSA_NAME_DEF_STMT (ptr); if (gimple_assign_single_p (stmt) && gimple_assign_rhs_code (stmt) == ADDR_EXPR) ptr = gimple_assign_rhs1 (stmt); + else if (is_gimple_assign (stmt) + && gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR + && host_integerp (gimple_assign_rhs2 (stmt), 0) + && (t1 = int_cst_value (gimple_assign_rhs2 (stmt))) >= 0) No need to restrict this to positive offsets I think. Here is the follow-up patch to remove this restriction (bootstrap+testsuite on x86_64-unknown-linux-gnu). I don't really know how safe it is. I couldn't use host_integerp(,1) since it returns false for (size_t)(-1) on x86_64, and host_integerp(,0) seemed strange, but I could use it if you want. 2013-11-01 Marc Glisse gcc/ * tree-ssa-alias.h (ranges_overlap_p): Handle negative offsets. * tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Likewise. gcc/testsuite/ * gcc.dg/tree-ssa/alias-26.c: New file. -- Marc GlisseIndex: gcc/testsuite/gcc.dg/tree-ssa/alias-26.c === --- gcc/testsuite/gcc.dg/tree-ssa/alias-26.c(revision 0) +++ gcc/testsuite/gcc.dg/tree-ssa/alias-26.c(working copy) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +void f (const char *c, int *i) +{ + *i = 42; + __builtin_memcpy (i - 1, c, sizeof (int)); + if (*i != 42) __builtin_abort(); +} + +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ + Property changes on: gcc/testsuite/gcc.dg/tree-ssa/alias-26.c ___ Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision URL \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: gcc/tree-ssa-alias.c === --- gcc/tree-ssa-alias.c(revision 204267) +++ gcc/tree-ssa-alias.c(working copy) @@ -552,42 +552,42 @@ ao_ref_base_alias_set (ao_ref *ref) alias_set_type ao_ref_alias_set (ao_ref *ref) { if (ref->ref_alias_set != -1) return ref->ref_alias_set; ref->ref_alias_set = get_alias_set (ref->ref); return ref->ref_alias_set; } /* Init an alias-oracle reference representation from a gimple pointer - PTR and a gimple size SIZE in bytes. If SIZE is NULL_TREE the the + PTR and a gimple size SIZE in bytes. If SIZE is NULL_TREE then the size is assumed to be unknown. The access is assumed to be only to or after of the pointer target, not before it. */ void ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size) { HOST_WIDE_INT t1, t2, extra_offset = 0; ref->ref = NULL_TREE; if (TREE_CODE (ptr) == SSA_NAME) { gimple stmt = SSA_NAME_DEF_STMT (ptr); if (gimple_assign_single_p (stmt) && gimple_assign_rhs_code (stmt) == ADDR_EXPR) ptr = gimple_assign_rhs1 (stmt); else if (is_gimple_assign (stmt) && gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR - && host_integerp (gimple_assign_rhs2 (stmt), 0) - && (t1 = int_cst_value (gimple_assign_rhs2 (stmt))) >= 0) + && TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST) { ptr = gimple_assign_rhs1 (stmt); - extra_offset = BITS_PER_UNIT * t1; + extra_offset = BITS_PER_UNIT +* int_cst_value (gimple_assign_rhs2 (stmt)); } } if (TREE_CODE (ptr) == ADDR_EXPR) ref->base = get_ref_base_and_extent (TREE_OPERAND (ptr, 0), &ref->offset, &t1, &t2); else { ref->base = build2 (MEM_REF, char_type_node, ptr, null_pointer_node); Index: gcc/tree-ssa-alias.h === --- gcc/tree-ssa-alias.h(revision 204267) +++ gcc/tree-ssa-alias.h(working copy) @@ -139,30 +139,30 @@ extern void pt_solution_set_var (struct extern void dump_pta_stats (FILE *); extern GTY(()) struct pt_solution ipa_escaped_pt; /* Return true, if the two ranges [POS1, SIZE1] and [POS2, SIZE2] overlap. SIZE1 and/or SIZE2 can be (unsigned)-1 in which case the range is open-ended. Otherwise return false. */ static inline bool -ranges_overlap_p (unsigned HOST_WIDE_INT pos1, - unsigned HOST_WIDE_INT size1, - unsigned HOST_WIDE_INT pos2, - unsigned HOST_
RE: [PATCH] Workaround errata for the PMC-Sierra RM7000 cpu.
> -Original Message- > From: Richard Sandiford [mailto:rdsandif...@googlemail.com] > Sent: Thursday, October 10, 2013 1:21 PM > To: Moore, Catherine > Cc: gcc-patches@gcc.gnu.org > Subject: Re: [PATCH] Workaround errata for the PMC-Sierra RM7000 cpu. > > "Moore, Catherine" writes: > >> -Original Message- > >> From: Richard Sandiford [mailto:rdsandif...@googlemail.com] > >> Subject: Re: [PATCH] Workaround errata for the PMC-Sierra RM7000 cpu. > >> > >> "Moore, Catherine" writes: > >> > Hi Richard, > >> > > >> > This patch implements a workaround for errors on the PMC-Sierra > >> > RM7000 cpu while executing the dmult or dmultu instruction. The > >> > workaround is to insert three nops after the dmult/dmultu. > >> > >> Do you have any more details? E.g. does "dmult $4,$5;addiu $6,$7,1" > >> cause problems? The VR41xx series had errata like these, but it was > >> always between the multiplication and other references to HI/LO. > > > > I've attached documentation describing the errata. The problem occurs > > with dmult/dmultu followed by a load. > > Thanks. > > >> Normally we've handled this by getting the assembler to insert the > >> nops and compiling in .set reorder mode. That copes with inline asms too. > >> I'm not opposed to doing it differently if there's a specific reason > >> though. > > > > No specific reason. Let me know if we need to change the > implementation. > > The assembler's probably best, all other things being equal. > > Ideally opcodes/mips*.c would have a flag to mark load instructions, but all > we have at the moment are flags to mark load delays, which means that LD > and some other load instructions don't have them. So I can think of three > options: > > (1) Turn INSN_LOAD_MEMORY_DELAY into INSN_LOAD_GPR and > INSN_COPRO_MEMORY_DELAY into INSN_LOAD_COPRO. Add the flags to > all > loads in the opcode table that don't currently have one. > > This would be the best approach, but I can understand why it might > seem like too much effort. > I've decided to go with this approach and will post the patches to the binutils mailing list. I'll follow up here with the recognition of the mfix-pmc option by the driver program. > (2) Stick with inserting three nops regardless. This could be done by > making insns_between return 3 for insn1 being DMULT(U), regardless > of insn2. > > (3) A slightly hacky approach would be to do (2), but check for memory > instructions using: > > (insn2 == NULL || strchr (insn2->insn_mo->args, '(')) > > That would conservatively match prefetches and stores too, but would > at least avoid the nops in some cases. It's probably not worth the > risk or hackiness though. > > Thanks, > Richard
Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals
On Thu, Oct 31, 2013 at 04:00:01PM +0100, Dodji Seketeli wrote: > Jakub Jelinek writes: > > > On Thu, Oct 31, 2013 at 03:36:07PM +0100, Bernd Edlinger wrote: > >> if you want to read zero-chars, why don't you simply use fgetc, > >> optionally replacing '\0' with ' ' in read_line? > > > > Because it is too slow? > > > > getline(3) would be much better for this purpose, though of course > > it is a GNU extension in glibc and so we'd need some fallback, which > > very well could be the fgetc or something similar. > > So would getline (+ the current patch as a fallback) be acceptable? I think even as a fallback is the patch too expensive. I'd say best would be to write some getline API compatible function and just use it, using fread on say fixed size buffer (4KB or similar), then for the number of characters returned by fread that were stored into that buffer look for the line terminator there and allocate/copy to the dynamically allocated buffer. A slight complication is what to do on mingw/cygwin and other DOS or Mac style line ending environments, no idea what fgets exactly does there. But, ignoring the DOS/Mac style line endings, it would be roughly (partially from glibc iogetdelim.c). ssize_t getline_fallback (char **lineptr, size_t *n, FILE *fp) { ssize_t cur_len = 0, len; char buf[16384]; if (lineptr == NULL || n == NULL) return -1; if (*lineptr == NULL || *n == 0) { *n = 120; *lineptr = (char *) malloc (*n); if (*lineptr == NULL) return -1; } len = fread (buf, 1, sizeof buf, fp); if (ferror (fp)) return -1; for (;;) { size_t needed; char *t = memchr (buf, '\n', len); if (t != NULL) len = (t - buf) + 1; if (__builtin_expect (len >= SSIZE_MAX - cur_len, 0)) return -1; needed = cur_len + len + 1; if (needed > *n) { char *new_lineptr; if (needed < 2 * *n) needed = 2 * *n; new_lineptr = realloc (*lineptr, needed); if (new_lineptr == NULL) return -1; *lineptr = new_lineptr; *n = needed; } memcpy (*lineptr + cur_len, buf, len); cur_len += len; if (t != NULL) break; len = fread (buf, 1, sizeof buf, fp); if (ferror (fp)) return -1; if (len == 0) break; } (*lineptr)[cur_len] = '\0'; return cur_len; } For the DOS/Mac style line endings, you probably want to look at what exactly does libcpp do with them. BTW, we probably want to do something with the speed of the caret diagnostics too, right now it opens the file again for each single line to be printed in caret diagnostics and reads all lines until the right one, so imagine how fast is printing of many warnings on almost adjacent lines near the end of many megabytes long file. Perhaps we could remember the last file we've opened for caret diagnostics, don't fclose the file right away but only if a new request is for a different file, perhaps keep some vector of line start offsets (say starting byte of every 100th line or similar) and also remember the last read line offset, so if a new request is for the same file, but higher line than last, we can just keep getlineing, and if it is smaller line than last, we look up the offset of the line / 100, fseek to it and just getline only modulo 100 lines. Maybe we should keep not just one, but 2 or 4 opened files as cache (again, with the starting line offsets vectors). Jakub
Re: [PATCH] LRA: Fix incorrect register spill/reload
> Vladimir Makarov wrote: > Robert, thanks for finding it and informing. You can commit the patch > into the trunk. Robert, Do you have GCC SVN access? If not, please ask one of us to commit your patch for you. Thanks, David
Re: [RFC] [Testsuite,ARM] Neon intrinsics executable tests
Hi Ramana, >> More later I need to get back to something else and I need to play more with >> your original testsuite - but I'd like some discussion around some of these >> points anyway. >> Rob Savoye is going to have a look at how to integrate the tests in a more straightforward way (he knows dejagnu quite a bit ;-) Christophe.
Re: [PATCH 0/6] Conversion of gimple types to C++ inheritance (v3)
On 10/31/2013 05:26 PM, David Malcolm wrote: [Shamelessly hijacking Andrew's thread about gimple.h refactoring, since this seems on-topic for that, and I'm keen to hear from Andrew on how the following would interact with his work - I *think* our two cleanups are orthogonal. [This is a revised version of the patches sent as: http://gcc.gnu.org/ml/gcc-patches/2013-08/msg01788.html and http://gcc.gnu.org/ml/gcc-patches/2013-08/msg01954.html which got bogged down in discussion of hand-written GTY hooks. This patch series updates things to make use of the new support in gengtype for simple inheritance schemes] The gimple statement types are currently implemented using a hand-coded C inheritance scheme, with a "union gimple_statement_d" holding the various possible structs for a statement. The following series of patches convert it to a C++ hierarchy, using the existing structs, eliminating the union. The "gimple" typedef changes from being a (union gimple_statement_d *) to being a: (struct gimple_statement_base *) Very good idea. But please, document that in some texinfo file, probably gcc/doc/gimple.texi Gimple-s are so damn important, even for plugin writers, that a small but up to date documentation is absolutely essential. You don"t need to write a lot of doc, just the minimal stuff (which at least tells which file should the plugin writer look into and list all the relevant classes). I hope your patches (or similar ones) will be accepted in 4.9 Regards. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mine, sont seulement les miennes} ***
[PATCH] New port committed: Andes nds32.
Hi, all, Thanks for all who gave me suggestions, review comments, and approval to this new nds32 port for GCC trunk. The Andes nds32 port now is committed into trunk as Rev.204269: http://gcc.gnu.org/r204269 We also add items on wwwdoc for nds32 port contribution: htdocs/backends.html -- Revision 1.48 htdocs/index.html -- Revision 1.897 htdocs/readings.html -- Revision 1.233 htdocs/gcc-4.9/changes.html -- Revision 1.31 We will keep maintaining nds32 port and the testsuite result will be periodically published on appropriate mailing list. Best regards, jasonwucj
Re: [PATCH][ubsan] Add VLA bound instrumentation
On Wed, Oct 30, 2013 at 09:10:30PM -0400, Jason Merrill wrote: > On 10/30/2013 12:15 PM, Marek Polacek wrote: > >On Wed, Oct 30, 2013 at 11:56:25AM -0400, Jason Merrill wrote: > >>Saving 'size' here doesn't help since it's already been used above. > >>Could you use itype instead of size here? > > > >I already experimented with that and I think I can't, since we call > >the finish_expr_stmt too soon, which results in: > > > > int x = 1; > > int a[0:(sizetype) SAVE_EXPR ]; > > > > <>; > > < > if (SAVE_EXPR <= 0) > > { > > __builtin___ubsan_handle_vla_bound_not_positive (&*.Lubsan_data0, > > (unsigned long) SAVE_EXPR ); > > } > > else > > { > > 0 > > }, (void) SAVE_EXPR ; >; > > ssizetype D.2143; > > < > (void) (D.2143 = (ssizetype) ++x + -1) >; > > Ah, looks like you're getting an unfortunate interaction with > stabilize_vla_size, which is replacing the contents of the SAVE_EXPR > with a reference to a variable that isn't initialized yet. Perhaps > we should move the stabilize_vla_size call into > compute_array_index_type, too. That works, thanks. So implemented as below in the patch. I was quite nervous about dropping the guards before stabilize_vla_size, but we can't really use them in compute_array_index_type, also I don't see any new regressions or bootstrap failures. (The C++1y check was adjusted accordingly to your recent patch, so we never throw on zero-length arrays.) Regtested, ran bootstrap-ubsan on x86_64-linux, ok for you now? 2013-10-31 Marek Polacek Implement -fsanitize=vla-bound. * opts.c (common_handle_option): Handle vla-bound. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_VLA_BOUND_NOT_POSITIVE): Define. * flag-types.h (enum sanitize_code): Add SANITIZE_VLA. * asan.c (initialize_sanitizer_builtins): Build BT_FN_VOID_PTR_PTR. c-family/ * c-ubsan.c: Don't include hash-table.h. (ubsan_instrument_vla): New function. * c-ubsan.h: Declare it. cp/ * decl.c (cp_finish_decl): Move C++1y bounds checking... (compute_array_index_type): ...here. Add VLA instrumentation. Call stabilize_vla_size. (grokdeclarator): Don't call stabilize_vla_size here. c/ * c-decl.c (grokdeclarator): Add VLA instrumentation. testsuite/ * g++.dg/ubsan/cxx1y-vla.C: New test. * c-c++-common/ubsan/vla-3.c: New test. * c-c++-common/ubsan/vla-2.c: New test. * c-c++-common/ubsan/vla-4.c: New test. * c-c++-common/ubsan/vla-1.c: New test. --- gcc/opts.c.mp 2013-10-31 18:06:23.269355759 +0100 +++ gcc/opts.c 2013-10-31 18:06:47.325449575 +0100 @@ -1444,6 +1444,7 @@ common_handle_option (struct gcc_options { "undefined", SANITIZE_UNDEFINED, sizeof "undefined" - 1 }, { "unreachable", SANITIZE_UNREACHABLE, sizeof "unreachable" - 1 }, + { "vla-bound", SANITIZE_VLA, sizeof "vla-bound" - 1 }, { NULL, 0, 0 } }; const char *comma; --- gcc/c-family/c-ubsan.c.mp 2013-10-31 18:06:23.263355735 +0100 +++ gcc/c-family/c-ubsan.c 2013-10-31 18:06:47.295449445 +0100 @@ -25,7 +25,6 @@ along with GCC; see the file COPYING3. #include "alloc-pool.h" #include "cgraph.h" #include "gimple.h" -#include "hash-table.h" #include "output.h" #include "toplev.h" #include "ubsan.h" @@ -86,8 +85,7 @@ ubsan_instrument_division (location_t lo return t; } -/* Instrument left and right shifts. If not instrumenting, return - NULL_TREE. */ +/* Instrument left and right shifts. */ tree ubsan_instrument_shift (location_t loc, enum tree_code code, @@ -157,4 +155,23 @@ ubsan_instrument_shift (location_t loc, t = fold_build3 (COND_EXPR, void_type_node, t, tt, void_zero_node); return t; +} + +/* Instrument variable length array bound. */ + +tree +ubsan_instrument_vla (location_t loc, tree size) +{ + tree type = TREE_TYPE (size); + tree t, tt; + + t = fold_build2 (LE_EXPR, boolean_type_node, size, build_int_cst (type, 0)); + tree data = ubsan_create_data ("__ubsan_vla_data", +loc, ubsan_type_descriptor (type), NULL_TREE); + data = build_fold_addr_expr_loc (loc, data); + tt = builtin_decl_explicit (BUILT_IN_UBSAN_HANDLE_VLA_BOUND_NOT_POSITIVE); + tt = build_call_expr_loc (loc, tt, 2, data, ubsan_encode_value (size)); + t = fold_build3 (COND_EXPR, void_type_node, t, tt, void_zero_node); + + return t; } --- gcc/c-family/c-ubsan.h.mp 2013-10-31 18:06:23.264355739 +0100 +++ gcc/c-family/c-ubsan.h 2013-10-31 18:06:47.296449449 +0100 @@ -23,5 +23,6 @@ along with GCC; see the file COPYING3. extern tree ubsan_instrument_division (location_t, tree, tree); extern tree ubsan_instrument_shift (location_t, enum tree_code, tree, tree); +extern tree ubsan_instrument_vla (location_t, tree); #endif /* GCC_C_UBSAN_H */ --- gcc/sanitizer.def.mp2013-10-31 18:
Re: [gomp4 simd, RFC] Simple fix to override vectorization cost estimation.
Jakub Jelinek wrote: >On Thu, Oct 31, 2013 at 07:02:28PM +0400, Yuri Rumyantsev wrote: >> Here is a simple fix which allows to vectorize loop marked with >> 'pragma omp simd' even if cost model tells us that vectorization is >> not profitable. >> I checked that on simple test-case is works as expected. >> >> Is it Ok for trunk? >> >> ChangeLog: >> >> 2013-10-31 Yuri Rumyantsev >> >> * tree-vect-loop.c (vect_estimate_min_profitable_iters): Override >> cost estimation for loops marked as vectorizable. > >That looks too simplistics, IMHO it is undesirable to disregard the >profitability checks together. For #pragma omp simd or #pragma simd >loops, I can understand that we should admit our cost model is not very >high >quality and so in border cases consider vectorizing rather than not >vectorizing, say for force_vect by increasing the scalar cost by some >factor or decreasing vector cost by some factor, but disregarding it >altogether doesn't look wise. The question is what factor should we >use? >150% of scalar cost, something else? Please improve the cost-model instead. Thanks, Richard. > Jakub
Re: [PATCH] Vectorizing abs(char/short/int) on x86.
On Wed, Oct 30, 2013 at 9:02 PM, Cong Hou wrote: > I have run check_GNU_style.sh on my patch. > > The patch is submitted. Thank you for your comments and help on this patch! I have committed a couple of fixes/improvements to your expander in i386.c. There is no need to check for the result of expand_simple_binop. Also, there is no guarantee that expand_simple_binop will expand to the target. It can return different RTX. Also, unhandled modes are now marked with gcc_unreachable. 2013-10-31 Uros Bizjak * config/i386/i386.c (ix86_expand_sse2_abs): Rename function arguments. Use gcc_unreachable for unhandled modes. Do not check results of expand_simple_binop. If not expanded to target, move the result. Tested on x86_64-pc-linux-gnu and committed. Uros. Index: config/i386/i386.c === --- config/i386/i386.c (revision 204264) +++ config/i386/i386.c (working copy) @@ -42020,36 +42020,36 @@ return false; } +/* Calculate integer abs() using only SSE2 instructions. */ + void -ix86_expand_sse2_abs (rtx op0, rtx op1) +ix86_expand_sse2_abs (rtx target, rtx input) { enum machine_mode mode = GET_MODE (op0); - rtx tmp0, tmp1; + rtx tmp0, tmp1, x; switch (mode) { /* For 32-bit signed integer X, the best way to calculate the absolute value of X is (((signed) X >> (W-1)) ^ X) - ((signed) X >> (W-1)). */ case V4SImode: - tmp0 = expand_simple_binop (mode, ASHIFTRT, op1, + tmp0 = expand_simple_binop (mode, ASHIFTRT, input, GEN_INT (GET_MODE_BITSIZE -(GET_MODE_INNER (mode)) - 1), +(GET_MODE_INNER (mode)) - 1), NULL, 0, OPTAB_DIRECT); - if (tmp0) - tmp1 = expand_simple_binop (mode, XOR, op1, tmp0, - NULL, 0, OPTAB_DIRECT); - if (tmp0 && tmp1) - expand_simple_binop (mode, MINUS, tmp1, tmp0, - op0, 0, OPTAB_DIRECT); + tmp1 = expand_simple_binop (mode, XOR, tmp0, input, + NULL, 0, OPTAB_DIRECT); + x = expand_simple_binop (mode, MINUS, tmp1, tmp0, +output, 0, OPTAB_DIRECT); break; /* For 16-bit signed integer X, the best way to calculate the absolute value of X is max (X, -X), as SSE2 provides the PMAXSW insn. */ case V8HImode: tmp0 = expand_unop (mode, neg_optab, op1, NULL_RTX, 0); - if (tmp0) - expand_simple_binop (mode, SMAX, op1, tmp0, op0, 0, - OPTAB_DIRECT); + + x = expand_simple_binop (mode, SMAX, tmp0, input, +output, 0, OPTAB_DIRECT); break; /* For 8-bit signed integer X, the best way to calculate the absolute @@ -42057,14 +42057,17 @@ as SSE2 provides the PMINUB insn. */ case V16QImode: tmp0 = expand_unop (mode, neg_optab, op1, NULL_RTX, 0); - if (tmp0) - expand_simple_binop (V16QImode, UMIN, op1, tmp0, op0, 0, - OPTAB_DIRECT); + + x = expand_simple_binop (V16QImode, UMIN, tmp0, input, +output, 0, OPTAB_DIRECT); break; default: - break; + gcc_unreachable (); } + + if (x != output) +emit_move_insn (output, x); } /* Expand an insert into a vector register through pinsr insn.
Re: [PATCH] Try to avoid vector mode punning in SET_DEST on i?86
On 10/31/2013 09:49 AM, Jakub Jelinek wrote: > 2013-10-31 Jakub Jelinek > > * optabs.c (expand_vec_perm): Avoid vector mode punning > SUBREGs in SET_DEST. > * expmed.c (store_bit_field_1): Likewise. > * config/i386/sse.md (movdi_to_sse, vec_pack_sfix_trunc_v2df, > vec_pack_sfix_v2df, vec_shl_, vec_shr_, > vec_interleave_high, vec_interleave_low): Likewise. > * config/i386/i386.c (ix86_expand_vector_move_misalign, > ix86_expand_sse_movcc, ix86_expand_int_vcond, ix86_expand_vec_perm, > ix86_expand_sse_unpack, ix86_expand_args_builtin, > ix86_expand_vector_init_duplicate, ix86_expand_vector_set, > emit_reduc_half, expand_vec_perm_blend, expand_vec_perm_pshufb, > expand_vec_perm_interleave2, expand_vec_perm_pshufb2, > expand_vec_perm_vpshufb2_vpermq, > expand_vec_perm_vpshufb2_vpermq_even_odd, expand_vec_perm_even_odd_1, > expand_vec_perm_broadcast_1, expand_vec_perm_vpshufb4_vpermq2, > ix86_expand_sse2_mulv4si3, ix86_expand_pinsr): Likewise. > (expand_vec_perm_palignr): Likewise. Modify a copy of *d rather > than *d itself. Ok. r~
Re: [C++ Patch / RFC] PR 29234
... I understand that at this point likely this isn't 4.9 material anymore. Just wanted to add that in the meanwhile I noticed that my WIP patch fixes c++/56037 too, which in fact seems to me a slightly less uncommon kind of code and that I tidied a bit the comments and simplified the cp_parser_cast_expression hunk. Still looking for feedback, in any case! Thanks! Paolo. /// Index: cp/parser.c === --- cp/parser.c (revision 204268) +++ cp/parser.c (working copy) @@ -5800,31 +5800,45 @@ cp_parser_postfix_expression (cp_parser *parser, b && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN)) { tree initializer = NULL_TREE; - bool saved_in_type_id_in_expr_p; + bool compound_literal_p; cp_parser_parse_tentatively (parser); /* Consume the `('. */ cp_lexer_consume_token (parser->lexer); - /* Parse the type. */ - saved_in_type_id_in_expr_p = parser->in_type_id_in_expr_p; - parser->in_type_id_in_expr_p = true; - type = cp_parser_type_id (parser); - parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p; - /* Look for the `)'. */ - cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN); + + /* Avoid calling cp_parser_type_id pointlessly, see comment + in cp_parser_cast_expression about c++/29234. */ + cp_lexer_save_tokens (parser->lexer); + + compound_literal_p + = (cp_parser_skip_to_closing_parenthesis (parser, false, false, + /*consume_paren=*/true) +&& cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)); + + /* Roll back the tokens we skipped. */ + cp_lexer_rollback_tokens (parser->lexer); + + if (!compound_literal_p) + cp_parser_simulate_error (parser); + else + { + /* Parse the type. */ + bool saved_in_type_id_in_expr_p = parser->in_type_id_in_expr_p; + parser->in_type_id_in_expr_p = true; + type = cp_parser_type_id (parser); + parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p; + /* Look for the `)'. */ + cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN); + } + /* If things aren't going well, there's no need to keep going. */ if (!cp_parser_error_occurred (parser)) { - if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) - { - bool non_constant_p; - /* Parse the brace-enclosed initializer list. */ - initializer = cp_parser_braced_list (parser, -&non_constant_p); - } - else - cp_parser_simulate_error (parser); + bool non_constant_p; + /* Parse the brace-enclosed initializer list. */ + initializer = cp_parser_braced_list (parser, +&non_constant_p); } /* If that worked, we're definitely looking at a compound-literal expression. */ @@ -7492,6 +7506,7 @@ cp_parser_tokens_start_cast_expression (cp_parser case CPP_CLOSE_SQUARE: case CPP_CLOSE_PAREN: case CPP_CLOSE_BRACE: +case CPP_OPEN_BRACE: case CPP_DOT: case CPP_DOT_STAR: case CPP_DEREF: @@ -7559,7 +7574,7 @@ cp_parser_cast_expression (cp_parser *parser, bool { tree type = NULL_TREE; tree expr = NULL_TREE; - bool compound_literal_p; + bool cast_expression_p; const char *saved_message; /* There's no way to know yet whether or not this is a cast. @@ -7582,26 +7597,38 @@ cp_parser_cast_expression (cp_parser *parser, bool will commit to the parse at that point, because we cannot undo the action that is done when creating a new class. So, then we cannot back up and do a postfix-expression. +Another tricky case is the following (c++/29234): + struct S { void operator () (); }; + + void foo () + { + ( S()() ); + } + +As a type-id we parse the parenthesized S()() as a function +returning a function, groktypename complains and we cannot +back up in this case too. + Therefore, we scan ahead to the closing `)', and check to see -if the token after the `)' is a `{'. If so, we are not -looking at a cast-expression. +if the tokens after the `)' can start a cast-expression. Otherwise +we are dealing with an unary-expression, a postfix-expression +or something else. Save tokens so th
[committed] Add diagnostics for aligned clause restrictions
Hi! I've noticed I have missed diagnostics for invalid aligned clause arguments (the aligned clause support has been written before the restrictions were added to the standard). Tested on x86_64-linux, committed to trunk. 2013-10-31 Jakub Jelinek * c-typeck.c (c_finish_omp_clauses): Diagnose aligned clause with decl that is not pointer nor array. * semantics.c (finish_omp_clauses): Diagnose aligned clause with decl that is not pointer nor array nor reference to those. * g++.dg/gomp/simd-1.C: New test. * g++.dg/gomp/declare-simd-1.C (f32): Fix up aligned clause argument. * g++.dg/gomp/declare-simd-2.C (fn13, fn14): Add new tests. * gcc.dg/gomp/declare-simd-2.c (fn7, fn8, fn9, fn10, fn11): Likewise. * c-c++-common/gomp/simd6.c: New test. --- gcc/c/c-typeck.c.jj 2013-10-30 08:15:33.0 +0100 +++ gcc/c/c-typeck.c2013-10-31 17:06:51.085755997 +0100 @@ -11504,6 +11504,14 @@ c_finish_omp_clauses (tree clauses) "%qE is not a variable in % clause", t); remove = true; } + else if (!POINTER_TYPE_P (TREE_TYPE (t)) + && TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%qE in % clause is neither a pointer nor " + "an array", t); + remove = true; + } else if (bitmap_bit_p (&aligned_head, DECL_UID (t))) { error_at (OMP_CLAUSE_LOCATION (c), --- gcc/cp/semantics.c.jj 2013-10-31 14:50:29.0 +0100 +++ gcc/cp/semantics.c 2013-10-31 17:08:00.527394011 +0100 @@ -5467,6 +5467,19 @@ finish_omp_clauses (tree clauses) error ("%qE is not a variable in % clause", t); remove = true; } + else if (!type_dependent_expression_p (t) + && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE + && TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE + && (TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE + || (!POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (t))) + && (TREE_CODE (TREE_TYPE (TREE_TYPE (t))) + != ARRAY_TYPE + { + error_at (OMP_CLAUSE_LOCATION (c), + "%qE in % clause is neither a pointer nor " + "an array nor a reference to pointer or array", t); + remove = true; + } else if (bitmap_bit_p (&aligned_head, DECL_UID (t))) { error ("%qD appears more than once in % clauses", t); --- gcc/testsuite/g++.dg/gomp/simd-1.C.jj 2013-10-31 19:23:29.394801317 +0100 +++ gcc/testsuite/g++.dg/gomp/simd-1.C 2013-10-31 19:25:25.218210869 +0100 @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-fopenmp" } + +extern int a[1024]; +int (&b)[1024] = a; + +struct S { int s; } s, &t = s; + +void +f1 (int &x, float &f, int *&p) +{ + int i; + #pragma omp simd aligned(x : 32) // { dg-error "neither a pointer nor an array" } + for (i = 0; i < 1024; i++) +a[i]++; + #pragma omp simd aligned(f) // { dg-error "neither a pointer nor an array" } + for (i = 0; i < 1024; i++) +a[i]++; + #pragma omp simd aligned(t : 16) // { dg-error "neither a pointer nor an array" } + for (i = 0; i < 1024; i++) +a[i]++; + #pragma omp simd aligned(a : 8) + for (i = 0; i < 1024; i++) +a[i]++; + #pragma omp simd aligned(b : 8) + for (i = 0; i < 1024; i++) +b[i]++; + #pragma omp simd aligned(p : 8) + for (i = 0; i < 1024; i++) +a[i]++; +} --- gcc/testsuite/g++.dg/gomp/declare-simd-1.C.jj 2013-10-11 11:23:59.0 +0200 +++ gcc/testsuite/g++.dg/gomp/declare-simd-1.C 2013-10-31 19:27:32.158559550 +0100 @@ -205,7 +205,7 @@ f30 (int x) template struct C { - #pragma omp declare simd simdlen (N) aligned (a : N * sizeof (int)) linear (c : N) notinbranch + #pragma omp declare simd simdlen (N) aligned (b : N * sizeof (int)) linear (c : N) notinbranch int f32 (int a, int *b, int c); }; --- gcc/testsuite/g++.dg/gomp/declare-simd-2.C.jj 2013-10-11 11:23:59.0 +0200 +++ gcc/testsuite/g++.dg/gomp/declare-simd-2.C 2013-10-31 19:31:36.812309117 +0100 @@ -64,4 +64,22 @@ struct D int e; }; +#pragma omp declare simd aligned (a, b, c, d) +int fn13 (int *a, int b[64], int *&c, int (&d)[64]); + +#pragma omp declare simd aligned (a) // { dg-error "neither a pointer nor an array" } +int fn14 (int a); + +#pragma omp declare simd aligned (b) // { dg-error "neither a pointer nor an array" } +int fn14 (int &b); + +#pragma omp declare simd aligned (c) // { dg-error "neither a pointer nor an array" } +int fn14 (float c); + +#pragma omp declare simd aligned (d) // { dg-error "neither a pointer nor an array" } +int fn14 (double &d); + +#pragma omp declare simd aligned (e) // { dg-error "neithe
[v3 patch] define std::integer_sequence et al
Implement my N3658 proposal for C++14. I moved the existing _Build_index_tuple from to and re-used it for std::make_integer_sequence (so that if G++ one day provides an intrinsic to generate a parameter pack of integers [0, N) we only need to change one place to use it.) 2013-10-31 Jonathan Wakely * include/std/tuple (_Index_tuple, _Build_index_tuple): Move to . * include/std/utility (integer_sequence, make_integer_sequence, index_sequence, make_index_sequence, index_sequence_for): Define. * doc/xml/manual/status_cxx2014.xml: Update. * testsuite/20_util/integer_sequence/intseq.cc: New. * testsuite/20_util/integer_sequence/requirements/typedefs.cc: New. Tested x86_64-linux, committed to trunk. commit 29a1079a3edcb51833cf0739affb2d9b3a59d4c3 Author: Jonathan Wakely Date: Sun Apr 28 13:59:42 2013 +0100 * include/std/tuple (_Index_tuple, _Build_index_tuple): Move to . * include/std/utility (integer_sequence, make_integer_sequence, index_sequence, make_index_sequence, index_sequence_for): Define. * doc/xml/manual/status_cxx2014.xml: Update. * testsuite/20_util/integer_sequence/intseq.cc: New. * testsuite/20_util/integer_sequence/requirements/typedefs.cc: New. diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2014.xml b/libstdc++-v3/doc/xml/manual/status_cxx2014.xml index 1f20f0e..4ef4334 100644 --- a/libstdc++-v3/doc/xml/manual/status_cxx2014.xml +++ b/libstdc++-v3/doc/xml/manual/status_cxx2014.xml @@ -185,8 +185,8 @@ particular release. Compile-time integer sequences - WIP - Need tests + Y + diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 063ce02..2580f78 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -917,27 +917,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ::type>::type>::type { }; - // Stores a tuple of indices. Also used by bind() to extract the elements - // in a tuple. - template -struct _Index_tuple -{ - typedef _Index_tuple<_Indexes..., sizeof...(_Indexes)> __next; -}; - - // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>. - template -struct _Build_index_tuple -{ - typedef typename _Build_index_tuple<_Num - 1>::__type::__next __type; -}; - - template<> -struct _Build_index_tuple<0> -{ - typedef _Index_tuple<> __type; -}; - template struct __make_tuple_impl; diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility index ad30ad7..627f79b 100644 --- a/libstdc++-v3/include/std/utility +++ b/libstdc++-v3/include/std/utility @@ -194,6 +194,67 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #endif + // Stores a tuple of indices. Used by tuple and pair, and by bind() to + // extract the elements in a tuple. + template +struct _Index_tuple +{ + typedef _Index_tuple<_Indexes..., sizeof...(_Indexes)> __next; +}; + + // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>. + template +struct _Build_index_tuple +{ + typedef typename _Build_index_tuple<_Num - 1>::__type::__next __type; +}; + + template<> +struct _Build_index_tuple<0> +{ + typedef _Index_tuple<> __type; +}; + +#if __cplusplus > 201103L + /// Class template integer_sequence + template +struct integer_sequence +{ + typedef _Tp value_type; + static constexpr size_t size() { return sizeof...(_Idx); } +}; + + template::__type> +struct _Make_integer_sequence; + + template +struct _Make_integer_sequence<_Tp, _Num, _Index_tuple<_Idx...>> +{ + static_assert( _Num >= 0, +"Cannot make integer sequence of negative length" ); + + typedef integer_sequence<_Tp, static_cast<_Tp>(_Idx)...> __type; +}; + + /// Alias template make_integer_sequence + template +using make_integer_sequence + = typename _Make_integer_sequence<_Tp, _Num>::__type; + + /// Alias template index_sequence + template +using index_sequence = integer_sequence; + + /// Alias template make_index_sequence + template +using make_index_sequence = make_integer_sequence; + + /// Alias template index_sequence_for + template +using index_sequence_for = make_index_sequence; +#endif + _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/testsuite/20_util/integer_sequence/intseq.cc b/libstdc++-v3/testsuite/20_util/integer_sequence/intseq.cc new file mode 100644 index 000..0f3ed41 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/integer_sequence/intseq.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } +// +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published b
RE: [PATCH] LRA: Fix incorrect register spill/reload
Hi David, No, I do not have read/write SVN access. I know a person who could commit the patch for me, however, if you can commit it, I'd be grateful. Regards, Robert > Vladimir Makarov wrote: > Robert, thanks for finding it and informing. You can commit the patch > into the trunk. Robert, Do you have GCC SVN access? If not, please ask one of us to commit your patch for you. Thanks, David
[PATCH] Support multiline GTY markers in Doxygen filter; add unittests
It's possible to run GCC's sources through Doxygen by setting INPUT_FILTER = contrib/filter_gcc_for_doxygen within contrib/gcc.doxy and invoking doxygen on the latter file. The script filters out various preprocessor constructs from GCC sources before Doxygen tries to parse them. However, as written, it works one line at-a-time, and thus can't cope with GTY markers that span multiple lines. I added such a marker in r204170 (symtab_node_base), and I'd like to add more such markers (see http://gcc.gnu.org/ml/gcc-patches/2013-10/msg02703.html). So the attached patch rewrites the filtering script to cope with multiline GTY markers. I'm not familiar with Perl, so I rewrote the script in Python. I expanded the regexes for readability, and added a unit-testing suite. I also tweaked how comments get layed with @verbatim to avoid inconsistent indentation between the first line and subsequent lines within a comment. Tested with Python 2.7; you can see a sample of the output (from my gimple-as-C++-inheritance working copy) at: http://dmalcolm.fedorapeople.org/gcc/2013-10-31/doxygen/html/structgimple__statement__base.html In particular, with this patch Doxygen is able to cope with the symtab GTY marker, and thus parse the symtab class hierarchy, giving the output viewable here: http://dmalcolm.fedorapeople.org/gcc/2013-10-31/doxygen/html/classsymtab__node__base.html OK for trunk? contrib/ * filter_gcc_for_doxygen: Use filter_params.py rather than filter_params.pl. * filter_params.pl: Delete in favor of... * filter_params.py: New, porting the perl script to python in order to cope with GTY markers that span multiple lines, tweaking the layout of comments, and adding a test suite. --- contrib/filter_gcc_for_doxygen | 2 +- contrib/filter_params.pl | 14 --- contrib/filter_params.py | 191 + 3 files changed, 192 insertions(+), 15 deletions(-) delete mode 100755 contrib/filter_params.pl create mode 100644 contrib/filter_params.py diff --git a/contrib/filter_gcc_for_doxygen b/contrib/filter_gcc_for_doxygen index 3787eeb..ca1db31 100755 --- a/contrib/filter_gcc_for_doxygen +++ b/contrib/filter_gcc_for_doxygen @@ -8,5 +8,5 @@ # process is put on stdout. dir=`dirname $0` -perl $dir/filter_params.pl < $1 | perl $dir/filter_knr2ansi.pl +python $dir/filter_params.py $1 | perl $dir/filter_knr2ansi.pl exit 0 diff --git a/contrib/filter_params.pl b/contrib/filter_params.pl deleted file mode 100755 index 22dae6c..000 --- a/contrib/filter_params.pl +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/perl - -# Filters out some of the #defines used throughout the GCC sources: -# - GTY(()) marks declarations for gengtype.c -# - PARAMS(()) is used for K&R compatibility. See ansidecl.h. - -while (<>) { -s/^\/\* /\/\*\* \@verbatim /; -s/\*\// \@endverbatim \*\//; -s/GTY[ \t]*\(\(.*\)\)//g; -s/[ \t]ATTRIBUTE_UNUSED//g; -s/PARAMS[ \t]*\(\((.*?)\)\)/\($1\)/sg; -print; -} diff --git a/contrib/filter_params.py b/contrib/filter_params.py new file mode 100644 index 000..d5092f6 --- /dev/null +++ b/contrib/filter_params.py @@ -0,0 +1,191 @@ +#!/usr/bin/python +""" +Filters out some of the #defines used throughout the GCC sources: +- GTY(()) marks declarations for gengtype.c +- PARAMS(()) is used for K&R compatibility. See ansidecl.h. + +When passed one or more filenames, acts on those files and prints the +results to stdout. + +When run without a filename, runs a unit-testing suite. +""" +import re +import sys +import unittest + +# Optional whitespace +opt_ws = '\s*' + +def filter_src(text): +""" +str -> str. We operate on the whole of the source file at once +(rather than individual lines) so that we can have multiline +regexes. +""" + +# First, convert tabs to spaces so that we can line things up +# sanely. +text = text.expandtabs(8) + +# Convert C comments from GNU coding convention of: +#/* FIRST_LINE +# NEXT_LINE +# FINAL_LINE. */ +# to: +#/** @verbatim +# FIRST_LINE +# NEXT_LINE +# FINAL_LINE. @endverbatim */ +# so that doxygen will parse them, and so the first line +# lines up correctly with subsequent lines. +# Single-line comments turn from: +#/* TEXT. */ +# into: +#/** @verbatim +#TEXT. @endverbatim */ + +text = re.sub(r'^([ \t]*)/\*+ ', + (r'\1/** @verbatim\n' + r'\1 '), + text, + flags=re.MULTILINE) +text = re.sub(r'\*+/', + r'@endverbatim */', + text) + +# Remove GTY markings (potentially multiline ones): +text = re.sub('GTY' + opt_ws + r'\(\(.*?\)\)\s+', + '', + text, + flags=(re.MULTILINE|re.DOTALL)) + +# Strip out 'ATTRIBUTE_UNUSED' +text = r
Re: [PATCH] Vectorizing abs(char/short/int) on x86.
This update makes it more safe. You showed me how to write better expand code. Thank you for the improvement! thanks, Cong On Thu, Oct 31, 2013 at 11:43 AM, Uros Bizjak wrote: > On Wed, Oct 30, 2013 at 9:02 PM, Cong Hou wrote: >> I have run check_GNU_style.sh on my patch. >> >> The patch is submitted. Thank you for your comments and help on this patch! > > I have committed a couple of fixes/improvements to your expander in > i386.c. There is no need to check for the result of > expand_simple_binop. Also, there is no guarantee that > expand_simple_binop will expand to the target. It can return different > RTX. Also, unhandled modes are now marked with gcc_unreachable. > > 2013-10-31 Uros Bizjak > > * config/i386/i386.c (ix86_expand_sse2_abs): Rename function arguments. > Use gcc_unreachable for unhandled modes. Do not check results of > expand_simple_binop. If not expanded to target, move the result. > > Tested on x86_64-pc-linux-gnu and committed. > > Uros.
symtab_node is now a struct, not a pointer (was Re: [PATCH v2 4/6] Remove symtab_node and const_symtab_node typedefs.)
On Tue, 2013-09-10 at 15:37 +0200, Jan Hubicka wrote: > > gcc/ > > > > * ipa-ref.h (symtab_node): Remove typedef to pointer type, as it > > clashes with the preferred name for the base class. > > (const_symtab_node): Remove redundant typedef. > > This is OK, too. > Actually it is not only clash - it was really inconsistent to write > symtab_node node; > struct cgraph_node *cnode; > > It is good this inconsistency is gone. I've (finally) committed this to trunk (as r204278), followed by the automated renaming patch (as r204279), having rechecked the bootstrap and regrtest on x86_64-unknown-linux-gnu (RHEL 6.4, in fact). So (at long last), the base class is symtab_node, with cgraph_node and varpool_node as C++ subclasses, and the "pointerness" of these types is consistent (i.e. none of them are pointers). Dave
Re: question about register pairs
> Seeing the patched code in its entirety like this, I notice that we > would use HARD_REGNO_NREGS for a regno that's not ok for the mode. > That can be avoided if we put a break into the if. And then the > !bad term in the loop condition becomes redundant. Although the > HARD_REGNO_NREGS definition in tm.texi says that HARD_REGNO_NREGS > must never return zero. That wouldn't be technically violated with > an assert, but I suppose the spirit of the text is that the macro > should return always a non-positive value, so I suppose this use of > HARD_REGNO_MODE_OK is not actually a problem. Alternately, we could assume that if there's a gap in the register class, that the next register that *is* in the register class is a legitimate register pair? I can't think of any reason why you'd do otherwise, and certainly if it *isn't* the first of a pair, there's no way to pass the test anyway. Then we'd just increment by HARD_REGNO_NREGS *or* 1, depending on whether the register is in the set or not, and break out of the test for the first reg that's in the set but not valid for the mode, so no need to increment after that case.
[PATCH] Fix for PR 58925
Hello Everyone, Attached, please find a fix for PR 58925. The issue is summarized below. I will commit this patch tonight since it is trivial, obvious and all the change is in libcilkrts. If anyone has any objections please let me know and I am willing to fix them. Thanks, Balaji V. Iyer. -Original Message- From: Iyer, Balaji V Sent: Thursday, October 31, 2013 11:36 AM To: 'g...@gcc.gnu.org' Cc: Jeff Law Subject: Question about a fix for PR 58925 Hello Everyone, I am currently looking to fix the bug reported in PR 58925. Here is the issue, When the user configures using the following command: ../gcc/configure --enable-version-specific-runtime-libs --disable-bootstrap --disable-werror --disable-multilib --enable-languages=c,c++ Make is OK, but when they do make install: here is the output we get /include" "AR=/usr/x86_64-pc-linux-gnu/bin/ar" "AS=/var/tmp/gcc_build_dir/./gcc/as" "LD=/var/tmp/gcc_build_dir/./gcc/collect-ld" "LIBCFLAGS=-g -O2" "NM=/var/tmp/gcc_build_dir/./gcc/nm" "PICFLAG=" "RANLIB=/usr/x86_64-pc-linux-gnu/bin/ranlib" "DESTDIR=" DO=install multi-do # make test -z "/usr/lib/gcc/x86_64-pc-linux-gnu/" || /bin/mkdir -p "/usr/lib/gcc/x86_64-pc-linux-gnu/" /bin/sh ./libtool --mode=install /usr/bin/install -c libcilkrts.la '/usr/lib/gcc/x86_64-pc-linux-gnu/' libtool: install: error: cannot install `libcilkrts.la' to a directory not ending in /usr/lib/gcc/x86_64-pc-linux-gnu/ I googled the error, but most of them seem to say the issue is in libtool and doing a make clean before make would fix it. I tried that and it is not fixing it. Can someone please give me a suggestion as to where/what I should look for? Thanks, Balaji V. Iyer. diff --git a/libcilkrts/ChangeLog b/libcilkrts/ChangeLog index 3427243..f87be65 100644 --- a/libcilkrts/ChangeLog +++ b/libcilkrts/ChangeLog @@ -1,3 +1,13 @@ +2013-10-31 Balaji V. Iyer + + PR other/58925 + * configure.ac: Added target_alias and GCC_LIBSTDCXX_RAW_CXX_FLAGS + fields. + * configure: Regenerated. + * aclocal.m4: Likewise. + * Makefile.in: Likewise. + * Makefile.am: Added gcc_version field. + 2013-10-30 Balaji V. Iyer * configure.ac: Changed a case statement to include i386. diff --git a/libcilkrts/Makefile.am b/libcilkrts/Makefile.am index f332cfb..a3b07ef 100644 --- a/libcilkrts/Makefile.am +++ b/libcilkrts/Makefile.am @@ -47,6 +47,9 @@ AM_CFLAGS = $(GENERAL_FLAGS) -std=c99 AM_CPPFLAGS = $(GENERAL_FLAGS) AM_LDFLAGS = -lpthread -ldl +# May be used by toolexeclibdir. +gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) + # Target list. toolexeclib_LTLIBRARIES = libcilkrts.la diff --git a/libcilkrts/Makefile.in b/libcilkrts/Makefile.in index 35e2705..9f459cc 100644 --- a/libcilkrts/Makefile.in +++ b/libcilkrts/Makefile.in @@ -122,8 +122,10 @@ DIST_COMMON = $(srcdir)/include/internal/rev.mk README ChangeLog \ @MAC_LINKER_SCRIPT_TRUE@am__append_2 = -Wl,-exported_symbols_list,$(srcdir)/runtime/mac-symbols.txt subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/depstand.m4 \ $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/libstdc++-raw-cxx.m4 \ $(top_srcdir)/../config/multi.m4 \ $(top_srcdir)/../config/override.m4 \ $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \ @@ -243,6 +245,8 @@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSTDCXX_RAW_CXX_CXXFLAGS = @LIBSTDCXX_RAW_CXX_CXXFLAGS@ +LIBSTDCXX_RAW_CXX_LDFLAGS = @LIBSTDCXX_RAW_CXX_LDFLAGS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -323,6 +327,7 @@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ +target_noncanonical = @target_noncanonical@ target_os = @target_os@ target_vendor = @target_vendor@ toolexecdir = @toolexecdir@ @@ -346,6 +351,9 @@ AM_CFLAGS = $(GENERAL_FLAGS) -std=c99 AM_CPPFLAGS = $(GENERAL_FLAGS) AM_LDFLAGS = -lpthread -ldl +# May be used by toolexeclibdir. +gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) + # Target list. toolexeclib_LTLIBRARIES = libcilkrts.la libcilkrts_la_SOURCES = \ diff --git a/libcilkrts/aclocal.m4 b/libcilkrts/aclocal.m4 index 68107ca..c24d0b6 100644 --- a/libcilkrts/aclocal.m4 +++ b/libcilkrts/aclocal.m4 @@ -968,8 +968,10 @@ AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR +m4_include([../config/acx.m4]) m4_include([../config/depstand.m4]) m4_include([../config/lead-dot.m4]) +m4_include([../config/libstdc++-raw-cxx.m4]) m4_include([../config/multi.m4]) m4_include([../config/override.m4]) m4_include([../libtool.m4]) diff --git a/libcilkrts/configure b/libcilkrts/configure index a2dd79c..41deb9f 100644 --- a/libcilkrts/configure +++ b/libcilkrts/configure @@ -681,6 +681,9 @@ am__isrc INSTALL_DATA INSTALL_SCRIP
PR 58834: __builtin_shuffle in a template
Hello, __builtin_shuffle with 2 arguments is represented as having 3 arguments, the second being 0, which isn't supported here. Bootstrap+testsuite on x86_64-unknown-linux-gnu. 2013-11-01 Marc Glisse PR c++/58834 gcc/cp/ * pt.c (value_dependent_expression_p): Handle null argument. gcc/testsuite/ * g++.dg/ext/pr58834.C: New file. -- Marc GlisseIndex: gcc/cp/pt.c === --- gcc/cp/pt.c (revision 204279) +++ gcc/cp/pt.c (working copy) @@ -20499,21 +20499,21 @@ value_dependent_expression_p (tree expre considered dependent. Other parts of the compiler arrange for an expression with type-dependent subexpressions to have no type, so this function doesn't have to be fully recursive. */ bool type_dependent_expression_p (tree expression) { if (!processing_template_decl) return false; - if (expression == error_mark_node) + if (expression == NULL_TREE || expression == error_mark_node) return false; /* An unresolved name is always dependent. */ if (identifier_p (expression) || TREE_CODE (expression) == USING_DECL) return true; /* Some expression forms are never type-dependent. */ if (TREE_CODE (expression) == PSEUDO_DTOR_EXPR || TREE_CODE (expression) == SIZEOF_EXPR || TREE_CODE (expression) == ALIGNOF_EXPR Index: gcc/testsuite/g++.dg/ext/pr58834.C === --- gcc/testsuite/g++.dg/ext/pr58834.C (revision 0) +++ gcc/testsuite/g++.dg/ext/pr58834.C (working copy) @@ -0,0 +1,5 @@ +template void foo() +{ + int i __attribute__((vector_size(2*sizeof(int; + (void) __builtin_shuffle(i, i); +} Property changes on: gcc/testsuite/g++.dg/ext/pr58834.C ___ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision URL \ No newline at end of property
[PATCH] use stack vectors more
From: Trevor Saunders Hi, This patch is pretty dull, it just replaces a bunch of things of the form vec x; x.create (N); // N is a constant blah blah x.release (); by stack_vec x; blah blah Of course its even nicer than that in some of the cases with many early returns. bootstrapped and same test results as r204192 on x86_64-unknown-linux-gnu, ok? Trev 2013-09-28 Trevor Saunders cp/ * semantics.c (build_anon_member_initialization): Convert fields to be a stack_vec. gcc/ * function.c (reorder_blocks): Convert block_stack to a stack_vec. * gimplify.c (gimplify_compound_lval): Likewise. * graphite-clast-to-gimple.c (gloog): Likewise. * graphite-dependences.c (loop_is_parallel_p): Likewise. * graphite-scop-detection.c (scopdet_basic_block_info): Likewise. (limit_scop); Likewise. (build_scops): Likewise. (dot_scop): Likewise. * graphite-sese-to-poly.c (sese_dom_walker): Likewise. (build_scop_drs): Likewise. (insert_stmts): Likewise. (insert_out_of_ssa_copy): Likewise. (remove_phi): Likewise. (rewrite_commutative_reductions_out_of_ssa_close_phi): Likewise. * hw-doloop.c (discover_loop): Likewise. * tree-call-cdce.c (shrink_wrap_one_built_in_call): Likewise. * tree-dfa.c (dump_enumerated_decls): Likewise. * tree-if-conv.c (if_convertable_loop_p): Likewise. * tree-inline.c (tree_function_versioning): Likewise. * tree-loop-distribution.c (build_rdg): Likewise. (rdg_flag_vertex_and_dependent): Likewise. (distribute_loop): Likewise. * tree-parloops.c (loop_parallel_p): Likewise. (eliminate_local_variables): Likewise. (separate_decls_in_region): Likewise. * tree-predcom.c (tree_predictive_commoning_loop): Likewise. * tree-ssa-phiopt.c (cond_if_else_store_replacement): Likewise. * tree-ssa-uncprop.c (uncprop_dom_walker): Likewise. * tree-vect-loop.c (vect_analyze_scaler_cycles_1): Likewise. * tree-vect-patterns.c (vect_pattern_recog): Likewise. * tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Likewise. (vectorizable_condition): Likewise. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 052746c..38eff6b 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -7402,8 +7402,7 @@ build_anon_member_initialization (tree member, tree init, to build up the initializer from the outside in so that we can reuse previously built CONSTRUCTORs if this is, say, the second field in an anonymous struct. So we use a vec as a stack. */ - vec fields; - fields.create (2); + stack_vec fields; do { fields.safe_push (TREE_OPERAND (member, 1)); @@ -7435,7 +7434,6 @@ build_anon_member_initialization (tree member, tree init, /* Now we're at the innermost field, the one that isn't an anonymous aggregate. Add its initializer to the CONSTRUCTOR and we're done. */ gcc_assert (fields.is_empty()); - fields.release (); CONSTRUCTOR_APPEND_ELT (*vec, field, init); return true; diff --git a/gcc/function.c b/gcc/function.c index eb8aca9..21ab691 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4128,12 +4128,11 @@ void reorder_blocks (void) { tree block = DECL_INITIAL (current_function_decl); - vec block_stack; if (block == NULL_TREE) return; - block_stack.create (10); + stack_vec block_stack; /* Reset the TREE_ASM_WRITTEN bit for all blocks. */ clear_block_marks (block); @@ -4145,8 +4144,6 @@ reorder_blocks (void) /* Recreate the block tree from the note nesting. */ reorder_blocks_1 (get_insns (), block, &block_stack); BLOCK_SUBBLOCKS (block) = blocks_nreverse_all (BLOCK_SUBBLOCKS (block)); - - block_stack.release (); } /* Helper function for reorder_blocks. Reset TREE_ASM_WRITTEN. */ diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 5edc6e8..63ceb40 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2142,7 +2142,6 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, fallback_t fallback) { tree *p; - vec expr_stack; enum gimplify_status ret = GS_ALL_DONE, tret; int i; location_t loc = EXPR_LOCATION (*expr_p); @@ -2150,7 +2149,7 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, /* Create a stack of the subexpressions so later we can walk them in order from inner to outer. */ - expr_stack.create (10); + stack_vec expr_stack; /* We can handle anything that get_inner_reference can deal with. */ for (p = expr_p; ; p = &TREE_OPERAND (*p, 0)) diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index 04c23c5..ec4c1d1 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -1652,8 +1652,7 @@ debug_generated_program (scop_p scop) bool gloog (scop_p scop, bb_pbb_htab_type bb_
Re: Rework c99status.html
On Fri, 1 Nov 2013, Gerald Pfeifer wrote: > I don't have a recommendation to change or keep the current name, > however I'll note that changing the name of a single file is going > to be even simpler then the below which I just applied. And this addresses three pages to avoid the redirect I just put in place and refer to the new canonical page. Gerald Index: htdocs/gcc-3.0/features.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.0/features.html,v retrieving revision 1.33 diff -u -3 -p -r1.33 features.html --- htdocs/gcc-3.0/features.html24 Feb 2007 17:16:21 - 1.33 +++ htdocs/gcc-3.0/features.html31 Oct 2013 23:50:24 - @@ -110,7 +110,7 @@ ISO C99 support and improvements to dependency generation. -Support for more ISO C99 features. +Support for more ISO C99 features. Many improvements to support for checking calls to format functions such as printf and scanf, including support for ISO C99 format features, extensions from Index: htdocs/gcc-3.1/changes.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.1/changes.html,v retrieving revision 1.65 diff -u -3 -p -r1.65 changes.html --- htdocs/gcc-3.1/changes.html 9 Sep 2012 22:07:57 - 1.65 +++ htdocs/gcc-3.1/changes.html 31 Oct 2013 23:50:24 - @@ -97,7 +97,7 @@ C/C++ -A few more ISO C99 features. +A few more ISO C99 features. The preprocessor is 10-50% faster than the preprocessor in GCC 3.0. The preprocessor's symbol table has been merged with the Index: htdocs/gcc-3.3/changes.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.3/changes.html,v retrieving revision 1.57 diff -u -3 -p -r1.57 changes.html --- htdocs/gcc-3.3/changes.html 24 Oct 2011 02:35:53 - 1.57 +++ htdocs/gcc-3.3/changes.html 31 Oct 2013 23:50:25 - @@ -126,7 +126,7 @@ for system directories and the special treatment of system header files are not defeated. -A few more ISO C99 features now +A few more ISO C99 features now work correctly. A new function attribute,
[PATCH] Handling == or != comparisons that may affect range test optimization.
(This patch is for the bug 58728: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58728) As in the bug report, consider the following loop: int foo(unsigned int n) { if (n != 0) if (n != 1) if (n != 2) if (n != 3) if (n != 4) return ++n; return n; } The range test optimization should be able to merge all those five conditions into one in reassoc pass, but I fails to do so. The reason is that the phi arg of n is replaced by the constant it compares to in case of == or != comparisons (in vrp pass). GCC checks there is no side effect on n between any two neighboring conditions by examining if they defined the same phi arg in the join node. But as the phi arg is replace by a constant, the check fails. This patch deals with this situation by considering the existence of == or != comparisons, which is attached below (a text file is also attached with proper tabs). Bootstrap and make check both get passed. Any comment? thanks, Cong diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8a38316..9247222 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2013-10-31 Cong Hou + + PR tree-optimization/58728 + * tree-ssa-reassoc.c (suitable_cond_bb): Consider the situtation + that ==/!= comparisons between a variable and a constant may lead + to that the later phi arg of the variable is substitued by the + constant from prior passes, during range test optimization. + 2013-10-14 David Malcolm * dumpfile.h (gcc::dump_manager): New class, to hold state diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 075d071..44a5e70 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-10-31 Cong Hou + + PR tree-optimization/58728 + * gcc.dg/tree-ssa/pr58728: New test. + 2013-10-14 Tobias Burnus PR fortran/58658 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr58728.c b/gcc/testsuite/gcc.dg/tree-ssa/pr58728.c new file mode 100644 index 000..312aebc --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr58728.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-reassoc1-details" } */ + +int foo (unsigned int n) +{ + if (n != 0) +if (n != 1) + return ++n; + return n; +} + +int bar (unsigned int n) +{ + if (n == 0) +; + else if (n == 1) +; + else +return ++n; + return n; +} + + +/* { dg-final { scan-tree-dump-times "Optimizing range tests" 2 "reassoc1" } } */ +/* { dg-final { cleanup-tree-dump "reassoc1" } } */ diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 6859518..bccf99f 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -2426,11 +2426,70 @@ suitable_cond_bb (basic_block bb, basic_block test_bb, basic_block *other_bb, for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi)) { gimple phi = gsi_stmt (gsi); + tree phi_arg = gimple_phi_arg_def (phi, e->dest_idx); + tree phi_arg2 = gimple_phi_arg_def (phi, e2->dest_idx); + /* If both BB and TEST_BB end with GIMPLE_COND, all PHI arguments corresponding to BB and TEST_BB predecessor must be the same. */ - if (!operand_equal_p (gimple_phi_arg_def (phi, e->dest_idx), -gimple_phi_arg_def (phi, e2->dest_idx), 0)) - { + if (!operand_equal_p (phi_arg, phi_arg2, 0)) + { + /* If the condition in BB or TEST_BB is an NE or EQ comparison like + if (n != N) or if (n == N), it is possible that the corresponding + def of n in the phi function is replaced by N. We should still allow + range test optimization in this case. */ + + tree lhs = NULL, rhs = NULL, + lhs2 = NULL, rhs2 = NULL; + bool is_eq_expr = is_cond && (gimple_cond_code (stmt) == NE_EXPR + || gimple_cond_code (stmt) == EQ_EXPR) + && TREE_CODE (phi_arg) == INTEGER_CST; + + if (is_eq_expr) + { +lhs = gimple_cond_lhs (stmt); +rhs = gimple_cond_rhs (stmt); + +if (operand_equal_p (lhs, phi_arg, 0)) + { + tree t = lhs; + lhs = rhs; + rhs = t; + } +if (operand_equal_p (rhs, phi_arg, 0) + && operand_equal_p (lhs, phi_arg2, 0)) + continue; + } + + gimple stmt2 = last_stmt (test_bb); + bool is_eq_expr2 = gimple_code (stmt2) == GIMPLE_COND + && (gimple_cond_code (stmt2) == NE_EXPR + || gimple_cond_code (stmt2) == EQ_EXPR) + && TREE_CODE (phi_arg2) == INTEGER_CST; + + if (is_eq_expr2) + { +lhs2 = gimple_cond_lhs (stmt2); +rhs2 = gimple_cond_rhs (stmt2); + +if (operand_equal_p (lhs2, phi_arg2, 0)) + { + tree t = lhs2; + lhs2 = rhs2; + rhs2 = t; + } +if (operand_equal_p (rhs2, phi_arg2, 0) + && operand_equal_p (lhs2, phi_arg, 0)) + continue; + } + + if (is_eq_expr && is_eq_expr2) + { +if (operand_equal_p (rhs, phi_arg, 0) + && operand_equal_p (rhs2, phi_arg2, 0) + && operand_equal_p (lhs, lhs2, 0)) + continue; + } + /* Otherwise, if one of the blocks doesn't end with GIMPLE_COND, one of the PHIs should have the lhs of the last stmt in that block as PHI arg and that PHI should have 0 or 1 @@ -2
Re: [PATCH C++/testsuite] Remove pchtest check objects and compile with current tool
On Oct 31, 2013, at 1:47 AM, Bernhard Reutner-Fischer wrote: > On 30 October 2013 23:22, Mike Stump wrote: >> On Oct 30, 2013, at 3:14 PM, Bernhard Reutner-Fischer >> wrote: >>> On 30 October 2013 22:47, Mike Stump wrote: Was there a significant purpose for the added C++ comment? If not, can you remove that? If so, can you explain? >>> >>> grep -A9 "CONTENTS is" gcc/testsuite/lib/target-supports.exp >>> # Assume by default that CONTENTS is C code. >>> # Otherwise, code should contain: >>> # "// C++" for c++, >>> # "! Fortran" for Fortran code, >>> # "/* ObjC", for ObjC >>> # "// ObjC++" for ObjC++ >>> # and "// Go" for Go >>> # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to >>> # allow for ObjC/ObjC++ specific flags. >>> proc check_compile {basename type contents args} { >> >> Ah, but this is why I asked for a significant purpose? The language of the >> file selects the options (flags) allowed. The language is set in your code. >> I think it was part of trying different ways to fix it, but, it turned out >> to be neither necessary or sufficient in the end. > > Not sure about any significant purpose, no. Ok, then it can be safely removed. > So, what do you want me to do? Remove the added comment… and repost… Thanks.
[PATCH, rs6000] Fix rs6000_expand_vector_set for little endian
Hi, Brooks Moses reported a bug with code that sets a single element of a vector to a given value and the rest of the vector to zero. This is implemented in rs6000_expand_vector_set, which uses a vperm instruction to place the nonzero value. As usual, we need to adjust the permute control vector and swap the order of the input operands. I added a test case based on the bug report. Bootstrapped and tested on powerpc64{,le}-unknown-linux-gnu with no regressions. The new test now passes for both endiannesses. Is this ok for trunk? Thanks, Bill gcc: 2013-10-31 Bill Schmidt * config/rs6000/rs6000.c (rs6000_expand_vector_set): Adjust for little endian. gcc/testsuite: 2013-10-31 Bill Schmidt * gcc.dg/vmx/vec-set.c: New. Index: gcc/testsuite/gcc.dg/vmx/vec-set.c === --- gcc/testsuite/gcc.dg/vmx/vec-set.c (revision 0) +++ gcc/testsuite/gcc.dg/vmx/vec-set.c (revision 0) @@ -0,0 +1,14 @@ +#include "harness.h" + +vector short +vec_set (short m) +{ + return (vector short){m, 0, 0, 0, 0, 0, 0, 0}; +} + +static void test() +{ + check (vec_all_eq (vec_set (7), +((vector short){7, 0, 0, 0, 0, 0, 0, 0})), +"vec_set"); +} Index: gcc/config/rs6000/rs6000.c === --- gcc/config/rs6000/rs6000.c (revision 204192) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -5529,10 +5529,27 @@ rs6000_expand_vector_set (rtx target, rtx val, int XVECEXP (mask, 0, elt*width + i) = GEN_INT (i + 0x10); x = gen_rtx_CONST_VECTOR (V16QImode, XVEC (mask, 0)); - x = gen_rtx_UNSPEC (mode, - gen_rtvec (3, target, reg, -force_reg (V16QImode, x)), - UNSPEC_VPERM); + + if (!BYTES_BIG_ENDIAN) +{ + /* Invert selector. */ + rtx splat = gen_rtx_VEC_DUPLICATE (V16QImode, +gen_rtx_CONST_INT (QImode, -1)); + rtx tmp = gen_reg_rtx (V16QImode); + emit_move_insn (tmp, splat); + x = gen_rtx_MINUS (V16QImode, tmp, force_reg (V16QImode, x)); + emit_move_insn (tmp, x); + + /* Permute with operands reversed and adjusted selector. */ + x = gen_rtx_UNSPEC (mode, gen_rtvec (3, reg, target, tmp), + UNSPEC_VPERM); +} + else +x = gen_rtx_UNSPEC (mode, + gen_rtvec (3, target, reg, + force_reg (V16QImode, x)), + UNSPEC_VPERM); + emit_insn (gen_rtx_SET (VOIDmode, target, x)); }
[Fwd: Re: [PATCH, rs6000] Correct handling of multiply high-part for little endian]
Hi maintainers, I agree with David that duplicating this code is a bad approach. What he and I would both prefer is to add a target hook to account for an anomaly in the PowerPC architecture. Background: For historical reasons, our vperm instruction (which is produced for gen_vec_perm) has some peculiar semantics in little endian mode. The permute control vector is interpreted to contain elements indexed in big-endian order no matter which endian mode the processor is set to. We can work around this in little endian mode by inverting the permute control vector and swapping the order of the other two input vectors, thus obtaining the same semantics as we would get for big endian. This behavior works when the two vectors are being treated as a single double-wide vector; the swapping is needed to make the long array appear as [8, 7, 6, 5, 4, 3, 2, 1] instead of [4, 3, 2, 1, 8, 7, 6, 5]. In the specific case of expand_mult_highpart (), the two vectors are not a single double-wide vector, but instead contain the odd and even results of widening multiplies. In this case, we still need to invert the permute control vector, but we don't want to swap the operands, because that causes us to mix up the odd and even results. This is the only such case we've run into where the swap is not what we need to obtain the right semantics. What we would like to do is swap the operands an extra time in expand_mult_highpart (), so that our common code will then swap the operands back to their original position. But since this is in target-independent code, we would need a target hook to do this. Something like: if (targetm.swap_vperm_inputs ()) { rtx tmp = m1; m1 = m2; m2 = tmp; } For PowerPC, the target hook would return !BYTES_BIG_ENDIAN. The default implementation for all other targets would return false. Would you find such an approach tolerable? Thanks, Bill --- Begin Message --- On Wed, Oct 30, 2013 at 6:55 PM, Bill Schmidt wrote: > Hi, > > When working around the peculiar little-endian semantics of the vperm > instruction, our usual fix is to complement the permute control vector > and swap the order of the two vector input operands, so that we get a > double-wide vector in the proper order. We don't want to swap the > operands when we are expanding a mult_highpart operation, however, as > the two input operands are not to be interpreted as a double-wide > vector. Instead they represent odd and even elements, and swapping the > operands gets the odd and even elements reversed in the final result. > > The permute for this case is generated by target-neutral code in > optabs.c: expand_mult_highpart (). We obviously can't change that code > directly. However, we can redirect the logic from the "case 2" method > to target-specific code by implementing expansions for the > umul3_highpart and smul3_highpart operations. I've done > this, with the expansions acting exactly as expand_mult_highpart does > today, with the exception that it swaps the input operands to the call > to expand_vec_perm when we are generating little-endian code. We will > later swap them back to their original position in the code in rs6000.c: > altivec_expand_vec_perm_const_le (). > > The change has no intended effect when generating big-endian code. > > Bootstrapped and tested on powerpc64{,le}-unknown-linux-gnu with no new > regressions. This fixes the gcc.dg/vect/pr51581-4.c test failure for > little endian. Ok for trunk? > > Thanks, > Bill > > > 2013-10-30 Bill Schmidt > > * config/rs6000/rs6000-protos.h (altivec_expand_mul_highpart): New > prototype. > * config/rs6000/rs6000.c (altivec_expand_mul_highpart): New. > * config/rs6000/altivec.md (umul3_highpart): New. > (smul_3_highpart): New. I really do not like duplicating this code. I think that you need to explore with the community the possibility of including a hook in the general code to handle the strangeness of PPC LE vector semantics. This is asking for problems if the generic code is updated / modified / fixed. - David --- End Message ---