RE: Two build != host fixes
Hi Eric, > > OK, I think that this compiler is misconfigured, could you try this > > Index: gcc-interface/Makefile.in > === > --- gcc-interface/Makefile.in (revision 205918) > +++ gcc-interface/Makefile.in (working copy) > @@ -1903,7 +1903,7 @@ ifeq ($(strip $(filter-out powerpc% linu > endif > > # ARM linux, GNU eabi > -ifeq ($(strip $(filter-out arm% linux-gnueabi,$(target_cpu) $(target_os))),) > +ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),) > LIBGNAT_TARGET_PAIRS = \ > a-intnam.ads s-inmaop.adb > and rebuild this compiler? > > -- > Eric Botcazou OK, now it works. Thanks. I wonder if you could add some really good comments in the system.ads what's the problem and how to fix it if the No_Implicit_Dynamic_Code makes problems like these? Bernd.
Re: [REPOST] Invalid Code when reading from unaligned zero-sized array
> Does this catch C99 VLAs? I vaguely recall we have a different internal > representation of those?!? And don't those have the same problem? No, VLAs have explicit variable size so they are not problematic here. -- Eric Botcazou
Re: Two build != host fixes
> OK, now it works. Thanks for confirming, I've installed the patch. > I wonder if you could add some really good comments in the system.ads > what's the problem and how to fix it if the No_Implicit_Dynamic_Code > makes problems like these? I think that we need to catch the problem earlier, that is to say stop the build of the Ada library if no configuration is selected in the Makefile. I'll try to come up with something along these lines. -- Eric Botcazou
Re: [PATCH] Don't reject TER unnecessarily (PRs middle-end/58956, middle-end/59470)
Jakub Jelinek wrote: >On Fri, Dec 13, 2013 at 07:30:12AM +0100, Richard Biener wrote: >> Jakub Jelinek wrote: >> >lhs of a call for calls or somewhere in output arguments of inline >asm. >> >> Can you please simply use walk_stmt_load_store_ops to get at the stmt >outputs? > >No, unfortunately. The problem is that >walk_stmt_load_store_{addr_,}ops first >calls and get_base_loadstore on the operand and thus effectively strips >all the >handled components from it. That's a defficiency of that function then which we should fix, for example with either passing both to the callback or by adding a flag. Richard. But we need to look at any uses of >SSA_NAMEs >in the whole operand, not only if it is based on *MEM_REF with SSA_NAME >operand. I.e., a change of the patch to use walk_stmt_load_store_ops >will keep the pr58956.c testcase fixed, because there is *i, but will >make pr59470.c (the new one in the patch) broken, because there the >SSA_NAME is used as ARRAY_REF index and base is some VAR_DECL. >It guess it wouldn't be hard to make similar testcase even for the call >case, though it is unclear if it would be miscompiled or not. > > Jakub
Re: [RFA][PATCH][PR tree-optimization/45685]
On Wed, Dec 11, 2013 at 9:25 PM, Jeff Law wrote: > On 12/11/13 02:51, Richard Biener wrote: >> >> >> That looks wrong - you want to look at HONOR_NANS on the mode >> of one of the comparison operands, not of the actual value you want >> to negate (it's integer and thus never has NaNs). >> >> The rest of the patch looks ok to me. > > Here's the updated version. It addresses the two issues you raised. > Specifically it adds the hairy condition to avoid this code in cases where > it's not likely to be useful and it fixes the call to > invert_tree_comparison. > > > Bootstrapped and regression tested on x86_64-unknown-linux-gnu > OK for the trunk? Ok. Thanks, Richard. > jeff > > > PR tree-optimization/45685 > * tree-ssa-phiopt.c (neg_replacement): New function. > (tree_ssa_phiopt_worker): Call it. > > PR tree-optimization/45685 > * gcc.dg/tree-ssa/pr45685.c: New test. > > > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr45685.c > b/gcc/testsuite/gcc.dg/tree-ssa/pr45685.c > new file mode 100644 > index 000..0628943 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr45685.c > @@ -0,0 +1,41 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O3 -fdump-tree-phiopt1-details" } */ > + > +typedef unsigned long int uint64_t; > +typedef long int int64_t; > +int summation_helper_1(int64_t* products, uint64_t count) > +{ > + int s = 0; > + uint64_t i; > + for(i=0; i + { > + int64_t val = (products[i]>0) ? 1 : -1; > + products[i] *= val; > + if(products[i] != i) > + val = -val; > + products[i] = val; > + s += val; > + } > + return s; > +} > + > + > +int summation_helper_2(int64_t* products, uint64_t count) > +{ > + int s = 0; > + uint64_t i; > + for(i=0; i + { > + int val = (products[i]>0) ? 1 : -1; > + products[i] *= val; > + if(products[i] != i) > + val = -val; > + products[i] = val; > + s += val; > + } > + return s; > +} > + > +/* { dg-final { scan-tree-dump-times "converted to straightline code" 2 > "phiopt1" } } */ > +/* { dg-final { cleanup-tree-dump "phiopt1" } } */ > + > diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c > index 11e565f..96154fb 100644 > --- a/gcc/tree-ssa-phiopt.c > +++ b/gcc/tree-ssa-phiopt.c > @@ -69,6 +69,8 @@ static bool minmax_replacement (basic_block, basic_block, > edge, edge, gimple, tree, tree); > static bool abs_replacement (basic_block, basic_block, > edge, edge, gimple, tree, tree); > +static bool neg_replacement (basic_block, basic_block, > +edge, edge, gimple, tree, tree); > static bool cond_store_replacement (basic_block, basic_block, edge, edge, > struct pointer_set_t *); > static bool cond_if_else_store_replacement (basic_block, basic_block, > basic_block); > @@ -336,6 +338,23 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool > do_hoist_loads) > /* Calculate the set of non-trapping memory accesses. */ > nontrap = get_non_trapping (); > > + /* The replacement of conditional negation with a non-branching > + sequence is really only a win when optimizing for speed and we > + can avoid transformations by gimple if-conversion that result > + in poor RTL generation. > + > + Ideally either gimple if-conversion or the RTL expanders will > + be improved and the code to emit branchless conditional negation > + can be removed. */ > + bool replace_conditional_negation = false; > + if (!do_store_elim) > +replace_conditional_negation > + = ((!optimize_size && optimize >= 2) > +|| (((flag_tree_loop_vectorize || cfun->has_force_vect_loops) > + && flag_tree_loop_if_convert != 0) > +|| flag_tree_loop_if_convert == 1 > +|| flag_tree_loop_if_convert_stores == 1)); > + >/* Search every basic block for COND_EXPR we may be able to optimize. > > We walk the blocks in order that guarantees that a block with > @@ -489,6 +508,9 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool > do_hoist_loads) > cfgchanged = true; > else if (abs_replacement (bb, bb1, e1, e2, phi, arg0, arg1)) > cfgchanged = true; > + else if (replace_conditional_negation > + && neg_replacement (bb, bb1, e1, e2, phi, arg0, arg1)) > + cfgchanged = true; > else if (minmax_replacement (bb, bb1, e1, e2, phi, arg0, arg1)) > cfgchanged = true; > } > @@ -1285,6 +1307,143 @@ abs_replacement (basic_block cond_bb, basic_block > middle_bb, >return true; > } > > +/* The function neg_replacement replaces conditional negation with > +equivalent straight line code. Returns TRUE if replacement is done, > +
RE: [REPOST] Invalid Code when reading from unaligned zero-sized array
Hi, with Eric's patch this test case does no longer compile, while it did compile with my patch: $ cat test.c struct s{ char x[8]; }; int main() { volatile register struct s x __asm__("eax"); x.x[0] = 1; return x.x[0]; } $ gcc -O3 -S test.c test.c: In function 'main': test.c:4:30: error: data type of 'x' isn't suitable for a register volatile register struct s x __asm__("eax"); ^ Bernd.
Re: C++ edge_iterator (was: Re: [SH] PR 53976 - Add RTL pass to eliminate clrt, sett insns)
On Wed, Dec 11, 2013 at 6:47 PM, Oleg Endo wrote: > On Thu, 2013-11-21 at 00:04 +0100, Steven Bosscher wrote: >> Declaring the edge_iterator inside the for() is not a good argument >> against FOR_EACH_EDGE. Of course, brownie points are up for grabs for >> the brave soul daring enough to make edge iterators be proper C++ >> iterators... ;-) > > So, I gave it a try -- see the attached patch. > It allows edge iteration to look more like STL container iteration: > > for (basic_block::edge_iterator ei = bb->pred_edges ().begin (); > ei != bb->pred_edges ().end (); ++ei) > { > basic_block pred_bb = (*ei)->src; > ... > } > > The idea is to first make class vec look more like an STL container. > This would also allow iterating it with std::for_each and use C++11 > range based for loop (in a few years maybe). It would also make it > easier to replace vec uses with STL containers if needed and vice versa. > > Then the > typedef struct basic_block_def* basic_block; > > is replaced with a wrapper class 'basic_block', which is just a simple > POD wrapper around a basic_block_def*. There should be no penalties > compared to passing/storing raw pointers. Because of the union with > constructor restriction of C++98 an additional wrapper class > 'basic_block_in_union' is required, which doesn't have any constructors > defined. > > Having 'basic_block' as a class allows putting typedefs for the edge > iterator types in there (initially I tried putting the typedefs into > struct basic_block_def, but gengtype would bail out). > It would also be possible to have a free standing definition / typedef > of edge_iterator, but it would conflict with the existing one and > require too many changes at once. Moreover, the iterator type actually > depends on the container type, which is vec, and the > container type is defined/selected by the basic_block class. > > The following > basic_block pred_bb = (*ei)->src; > > can also be written as > basic_block pred_bb = ei->src; > > after converting the edge typedef to a wrapper of edge_def*. > > The idea of the approach is to allow co-existence of the new > edge_iterator and the old and thus be able to gradually convert code. > The wrappers around raw pointers also helo encapsulating the underlying > memory management issues. For example, it would be much easier to > replace garbage collected objects with intrusive reference counting. > > Comments and feedback appreciated. Apart from the issues raised by Trevor I want to question if we want to transition to STL-like iterators (yeah, I know, the gsi_ ones are already similar). An obvious cleanup to the existing FOR_EACH machinery is to declare the iterator inside the FOR_EACH, thus make it an implementation detail (like I did with the loop iterator). Richard. > Cheers, > Oleg
Commit: MSP430: Add wakeup function attribute
Hi Guys, I have applied the patch below to add support for a wakeup function attribute to the MSP430 backend. The wakeup attribute applies to interrupt functions, and it makes them wake the processor from low power sleep states when the interrupt handler exits. Cheers Nick gcc/ChangeLog 2013-12-13 Nick Clifton * config/msp430/msp430.c (is_wakeup_func): New function. Returns true if the current function has the wakeup attribute. (msp430_start_function): Note if the function has the wakeup attribute. (msp430_attribute_table): Add wakeup attribute. (msp430_expand_epilogue): Add support for wakeup functions. * config/msp430/msp430.md (disable_interrupts): Emit a NOP after the DINT instruction. * doc/extend.texi: Document the wakeup attribute.
Cleanup patches, mostly in the realm of OpenMP
Hi! OK to apply the following cleanup patches to trunk, assuming that testing (still running) is fine? commit 68c9deec084dff1e5d8caf6a17ec3eec1f8f9f33 Author: Thomas Schwinge Date: Wed Oct 23 19:40:10 2013 +0200 Fix description of OpenMP parallel directive in the C and C++ front ends. gcc/c/ * c-parser.c (c_parser_omp_parallel): Fix description. gcc/cp/ parser.c (cp_parser_omp_parallel): Fix description. diff --git gcc/c/c-parser.c gcc/c/c-parser.c index c78d269..28f53c1 100644 --- gcc/c/c-parser.c +++ gcc/c/c-parser.c @@ -12032,9 +12032,16 @@ c_parser_omp_sections (location_t loc, c_parser *parser, } /* OpenMP 2.5: - # pragma parallel parallel-clause new-line - # pragma parallel for parallel-for-clause new-line - # pragma parallel sections parallel-sections-clause new-line + # pragma omp parallel parallel-clause[optseq] new-line + structured-block + # pragma omp parallel for parallel-for-clause[optseq] new-line + structured-block + # pragma omp parallel sections parallel-sections-clause[optseq] new-line + structured-block + + OpenMP 4.0: + # pragma omp parallel for simd parallel-for-simd-clause[optseq] new-line + structured-block LOC is the location of the #pragma token. */ diff --git gcc/cp/parser.c gcc/cp/parser.c index dd02734..9f8ad39 100644 --- gcc/cp/parser.c +++ gcc/cp/parser.c @@ -29512,12 +29512,16 @@ cp_parser_omp_sections (cp_parser *parser, cp_token *pragma_tok, } /* OpenMP 2.5: - # pragma parallel parallel-clause new-line - # pragma parallel for parallel-for-clause new-line - # pragma parallel sections parallel-sections-clause new-line + # pragma omp parallel parallel-clause[optseq] new-line + structured-block + # pragma omp parallel for parallel-for-clause[optseq] new-line + structured-block + # pragma omp parallel sections parallel-sections-clause[optseq] new-line + structured-block OpenMP 4.0: - # pragma parallel for simd parallel-for-simd-clause new-line */ + # pragma omp parallel for simd parallel-for-simd-clause[optseq] new-line + structured-block */ #define OMP_PARALLEL_CLAUSE_MASK \ ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF) \ commit 46ac50be669906346aee96c88509962ca2d0efb3 Author: Thomas Schwinge Date: Wed Oct 23 20:01:38 2013 +0200 Properly order chapters in GCC Internals manual. gcc/ * doc/gccint.texi (Top): Fix inclusion order. diff --git gcc/doc/gccint.texi gcc/doc/gccint.texi index 7d79500..a80cc5d 100644 --- gcc/doc/gccint.texi +++ gcc/doc/gccint.texi @@ -143,12 +143,12 @@ Additional tutorial information is linked to from @include sourcebuild.texi @include options.texi @include passes.texi -@include rtl.texi @include generic.texi @include gimple.texi @include tree-ssa.texi -@include loop.texi +@include rtl.texi @include cfg.texi +@include loop.texi @include md.texi @include tm.texi @include hostconfig.texi commit 2fdb23db57bfa7a27b2d14b0e98d6d6f764e5261 Author: Thomas Schwinge Date: Thu Oct 31 14:55:47 2013 +0100 Document passes.def. gcc/ * doc/cfg.texi (Control Flow): Refer to passes.def instead of passes.c. * doc/passes.texi (Pass manager): Refer to passes.def. diff --git gcc/doc/cfg.texi gcc/doc/cfg.texi index b759e36..1be3f47 100644 --- gcc/doc/cfg.texi +++ gcc/doc/cfg.texi @@ -23,7 +23,7 @@ used to represent the control flow graph are defined in In GCC, the representation of control flow is maintained throughout the compilation process, from constructing the CFG early in -@code{pass_build_cfg} to @code{pass_free_cfg} (see @file{passes.c}). +@code{pass_build_cfg} to @code{pass_free_cfg} (see @file{passes.def}). The CFG takes various different modes and may undergo extensive manipulations, but the graph is always valid between its construction and its release. This way, transfer of information such as data flow, diff --git gcc/doc/passes.texi gcc/doc/passes.texi index 3ed9a4f..9a68ad2 100644 --- gcc/doc/passes.texi +++ gcc/doc/passes.texi @@ -208,6 +208,7 @@ semantic checks), it should return @code{GS_ERROR}. The pass manager is located in @file{passes.c}, @file{tree-optimize.c} and @file{tree-pass.h}. +It processes passes as described in @file{passes.def}. Its job is to run all of the individual passes in the correct order, and take care of standard bookkeeping that applies to every pass. commit b345a58a0c66a2e1bc29bb842740773caa6088e0 Author: Thomas Schwinge Date: Wed Oct 30 12:16:53 2013 +0100 gcc/gimplify.c:gimplify_omp_ctx is a variable remapping context. gcc/ * gimplify.c (gimplify_omp_ctx): Describe as a variable remapping context. diff --git gcc/gimplify.c gcc/gimplify.c index 7203456..f54e6e1 100644 --- gcc/gimplify.c +++ gcc/gimplify.c @@ -129,6 +129,8 @@ struct gimplify_ctx bool in_cleanup_point_expr; }; +/* Variable remapping cont
maybe_fold_stmt (was: [gomp4] #pragma omp target* fixes)
Hi! On Thu, 5 Sep 2013 18:11:05 +0200, Jakub Jelinek wrote: > 4) the reference testcase showed a problem with fold_stmt calls > we do very early, during gimplification, because for TREE_READONLY > vars with DECL_INITIAL fold_stmt can replace the uses of the var with > its initializer, but as the gimplifier isn't aware of it, we wouldn't remap > that, or worse there could be explicit remapping of it via array section, > but one that the compiler doesn't see, and if that is smaller than > the whole array size, that would result in runtime error. So, after > some talk with richi on IRC, I've decided to just not fold_stmt > inside of target constructs during gimplification and defer it until > omplower. > * gimplify.c (gimplify_call_expr): Don't call fold_stmt > inside of #pragma omp target construct. > (gimplify_modify_expr): Likewise. > * omp-low.c > (lower_omp): Call fold_stmt on all stmts inside of > #pragma omp target construct. > --- gcc/gimplify.c.jj 2013-09-05 09:19:03.0 +0200 > +++ gcc/gimplify.c2013-09-05 14:45:48.632720617 +0200 > @@ -2704,7 +2704,14 @@ gimplify_call_expr (tree *expr_p, gimple >notice_special_calls (call); >gimplify_seq_add_stmt (pre_p, call); >gsi = gsi_last (*pre_p); > - fold_stmt (&gsi); > + /* Don't fold stmts inside of target construct. We'll do it > + during omplower pass instead. */ > + struct gimplify_omp_ctx *ctx; > + for (ctx = gimplify_omp_ctxp; ctx; ctx = ctx->outer_context) > + if (ctx->region_type == ORT_TARGET) > + break; > + if (ctx == NULL) > + fold_stmt (&gsi); >*expr_p = NULL_TREE; > } >else > @@ -4961,7 +4968,14 @@ gimplify_modify_expr (tree *expr_p, gimp > >gimplify_seq_add_stmt (pre_p, assign); >gsi = gsi_last (*pre_p); > - fold_stmt (&gsi); > + /* Don't fold stmts inside of target construct. We'll do it > + during omplower pass instead. */ > + struct gimplify_omp_ctx *ctx; > + for (ctx = gimplify_omp_ctxp; ctx; ctx = ctx->outer_context) > +if (ctx->region_type == ORT_TARGET) > + break; > + if (ctx == NULL) > +fold_stmt (&gsi); > >if (want_value) > { > --- gcc/omp-low.c.jj 2013-09-05 09:19:03.0 +0200 > +++ gcc/omp-low.c 2013-09-05 17:11:14.693638660 +0200 > @@ -9673,6 +9685,12 @@ lower_omp (gimple_seq *body, omp_context >gimple_stmt_iterator gsi; >for (gsi = gsi_start (*body); !gsi_end_p (gsi); gsi_next (&gsi)) > lower_omp_1 (&gsi, ctx); > + /* Inside target region we haven't called fold_stmt during gimplification, > + because it can break code by adding decl references that weren't in the > + source. Call fold_stmt now. */ > + if (target_nesting_level) > +for (gsi = gsi_start (*body); !gsi_end_p (gsi); gsi_next (&gsi)) > + fold_stmt (&gsi); >input_location = saved_location; > } OK to commit to trunk the following patch? commit 6ff10eb51ea39a25e53e0369626559be208bb16e Author: Thomas Schwinge Date: Mon Oct 21 16:37:41 2013 +0200 Refactor common code into new maybe_fold_stmt function. gcc/ * gimplify.c (gimplify_call_expr, gimplify_modify_expr): Move common code... (maybe_fold_stmt): ... into this new function. * omp-low.c (lower_omp): Update comment. diff --git gcc/gimplify.c gcc/gimplify.c index 1ca847a..7203456 100644 --- gcc/gimplify.c +++ gcc/gimplify.c @@ -2184,6 +2184,23 @@ gimplify_arg (tree *arg_p, gimple_seq *pre_p, location_t call_location) return gimplify_expr (arg_p, pre_p, NULL, test, fb); } +/* Don't fold STMT inside ORT_TARGET, because it can break code by adding decl + references that weren't in the source. We'll do it during omplower pass + instead. */ + +static bool +maybe_fold_stmt (gimple_stmt_iterator *gsi) +{ + bool changed = false; + struct gimplify_omp_ctx *ctx; + for (ctx = gimplify_omp_ctxp; ctx; ctx = ctx->outer_context) +if (ctx->region_type == ORT_TARGET) + break; + if (ctx == NULL) +changed = fold_stmt (gsi); + return changed; +} + /* Gimplify the CALL_EXPR node *EXPR_P into the GIMPLE sequence PRE_P. WANT_VALUE is true if the result of the call is desired. */ @@ -2417,14 +2434,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value) notice_special_calls (call); gimplify_seq_add_stmt (pre_p, call); gsi = gsi_last (*pre_p); - /* Don't fold stmts inside of target construct. We'll do it -during omplower pass instead. */ - struct gimplify_omp_ctx *ctx; - for (ctx = gimplify_omp_ctxp; ctx; ctx = ctx->outer_context) - if (ctx->region_type == ORT_TARGET) - break; - if (ctx == NULL) - fold_stmt (&gsi); + maybe_fold_stmt (&gsi); *expr_p = NULL_TREE; } else @@ -4572,14 +4582,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, gimplify_seq_add_stmt (pre_p, assign); gsi = gs
Re: [REPOST] Invalid Code when reading from unaligned zero-sized array
> with Eric's patch this test case does no longer compile, while it did > compile with my patch: > > $ cat test.c > struct s{ char x[8]; }; > int main() > { > volatile register struct s x __asm__("eax"); > x.x[0] = 1; > return x.x[0]; > } > > $ gcc -O3 -S test.c > test.c: In function 'main': > test.c:4:30: error: data type of 'x' isn't suitable for a register >volatile register struct s x __asm__("eax"); Well, sure, but try with: struct s { char x[7]; }; or struct s { char y; char x[7]; }; -- Eric Botcazou
Commit: MSP430: Add wakeup function attribute
[This time with the patch attached] Hi Guys, I have applied the patch below to add support for a wakeup function attribute to the MSP430 backend. The wakeup attribute applies to interrupt functions, and it makes them wake the processor from low power sleep states when the interrupt handler exits. Cheers Nick gcc/ChangeLog 2013-12-13 Nick Clifton * config/msp430/msp430.c (is_wakeup_func): New function. Returns true if the current function has the wakeup attribute. (msp430_start_function): Note if the function has the wakeup attribute. (msp430_attribute_table): Add wakeup attribute. (msp430_expand_epilogue): Add support for wakeup functions. * config/msp430/msp430.md (disable_interrupts): Emit a NOP after the DINT instruction. * doc/extend.texi: Document the wakeup attribute. Index: config/msp430/msp430.c === --- config/msp430/msp430.c (revision 205957) +++ config/msp430/msp430.c (working copy) @@ -966,6 +966,12 @@ return is_attr_func ("interrupt"); } +static bool +is_wakeup_func (void) +{ + return msp430_is_interrupt_func () && is_attr_func ("wakeup"); +} + static inline bool is_naked_func (void) { @@ -1005,6 +1011,8 @@ fprintf (outfile, "reentrant "); if (is_critical_func ()) fprintf (outfile, "critical "); + if (is_wakeup_func ()) + fprintf (outfile, "wakeup "); fprintf (outfile, "\n"); } @@ -1131,6 +1139,7 @@ { "naked", 0, 0, true, false, false, msp430_attr, false }, { "reentrant", 0, 0, true, false, false, msp430_attr, false }, { "critical", 0, 0, true, false, false, msp430_attr, false }, + { "wakeup", 0, 0, true, false, false, msp430_attr, false }, { NULL, 0, 0, false, false, false, NULL,false } }; @@ -1409,6 +1418,14 @@ emit_insn (gen_epilogue_start_marker ()); + if (is_wakeup_func ()) +/* Clear the SCG1, SCG0, OSCOFF and CPUOFF bits in the saved copy of the + status register current residing on the stack. When this function + executes its RETI instruction the SR will be updated with this saved + value, thus ensuring that the processor is woken up from any low power + state in which it may be residing. */ +emit_insn (gen_bic_SR (GEN_INT (0xf0))); + fs = cfun->machine->framesize_locals + cfun->machine->framesize_outgoing; increment_stack (fs); Index: config/msp430/msp430.md === --- config/msp430/msp430.md (revision 205957) +++ config/msp430/msp430.md (working copy) @@ -1253,11 +1253,11 @@ "1" "NOP" ) - + (define_insn "disable_interrupts" [(unspec_volatile [(const_int 0)] UNS_DINT)] "" - "DINT" + "DINT \; NOP" ) (define_insn "enable_interrupts" Index: doc/extend.texi === --- doc/extend.texi (revision 205957) +++ doc/extend.texi (working copy) @@ -2919,6 +2919,13 @@ or @code{critical} attributes. They can have the @code{interrupt} attribute. +@item wakeup +@cindex @code{wakeup} attribute +This attribute only applies to interrupt functions. It is silently +ignored if applied to a non-interrupt function. A wakeup interrupt +function will rouse the processor from any low-power state that it +might be in when the function exits. + @end table On Epiphany targets one or more optional parameters can be added like this:
Re: [trunk]: Patch to move BITS_PER_UNIT to be available for genmodes.c
On Wed, 11 Dec 2013, Kenneth Zadeck wrote: > > > This patch is for the trunk, but it solves a problem that comes up for > wide-int. For wide-int we need to have the BITS_PER_UNIT available earlier. > So this patch sets the default value (8) in genmodes.c so that it is available > by anyone who includes insn-modes.h. The generator for tm.h was modified to > include insn-modes.h.The value for BITS_PER_UNIT can be overridden by any > port by placing a define for it in their target modes file. > > This patch removes the definition of BITS_PER_UNIT from 7 platform .h files. > All of those platforms initialized it to the default value so there was no > need for additions to their target modes file. > > In addition, this target also changes the way that MAX_BITSIZE_MODE_ANY_INT is > calculated.The value is heavily used on the wide-int branch to allocate > buffers that are used to hold large integer values. The change in the way it > is computed was motivated by the i386 port, but there may be other ports that > have the same problem. The i386 port defines two very large integer modes > that are only used as containers for large vectors. They are never used for > large integers. The new way of computing this allows a port to say (very > early) that some of these integer modes are never used to hold numbers and so > smaller buffers can be used for integer calculations. Other ports that play > the same game should follow suit. > > This patch has been bootstrapped and regression tested on x86-64. Ok to > commit? Ok. Thanks, Richard. > Kenny > -- Richard Biener SUSE / SUSE Labs SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 GF: Jeff Hawn, Jennifer Guild, Felix Imend"orffer
Re: [PATCH PR41488]Recognize more induction variables by simplifying PEELED chrec in scalar evolution
On Thu, Dec 12, 2013 at 6:55 AM, bin.cheng wrote: > > >> -Original Message- >> From: Richard Biener [mailto:richard.guent...@gmail.com] >> Sent: Wednesday, December 11, 2013 6:04 PM >> To: Jakub Jelinek >> Cc: Bin.Cheng; Jeff Law; Bin Cheng; gcc-patches List >> Subject: Re: [PATCH PR41488]Recognize more induction variables by >> simplifying PEELED chrec in scalar evolution >> >> On Wed, Dec 11, 2013 at 9:50 AM, Jakub Jelinek wrote: >> > On Wed, Dec 11, 2013 at 04:31:55PM +0800, Bin.Cheng wrote: >> >> Thank both of you for being patient on this patch. >> >> I went through the documentation quickly and realized that I have to >> >> modify pointer-map structure to make it recognized by GC (maybe more >> > >> > Changing pointer_map at this point is IMHO not appropriate. >> > >> >> work suggested by Jakub). It seems I shouldn't include that task in >> >> this patch at this stage 3, I am thinking just call free_affine* >> >> function in the place it is created for SCEV. Of course, that makes >> >> it more expensive. >> > >> > Perhaps you could call free_affine_expand_cache say from >> > analyze_scalar_evolution, that is the innermost enclosing exported API >> > that indirectly calls your new code, but it seems it is also called >> > recursively from analyze_scalar_evolution_1 or functions it calls. >> > So maybe you'd need to rename analyze_scalar_evolution to >> > analyze_scalar_evolution_2 and adjust some calls to >> > analyze_scalar_evolution to the latter in tree-scalar-evolution.c, and >> > add analyze_scalar_evolution wrapper that calls >> analyze_scalar_evolution_2 and free_affine_expand_cache. >> > Whether this would work depends on detailed analysis of the >> > tree-scalar-evolution.c callgraph, there are tons of functions, most >> > of them static, and the question is if there is a single non-static >> > (or at most a few of them) function that cover all calls to your new >> > code in the static functions it (indirectly) calls, i.e. if there >> > isn't any other external entry point that might call your new code >> > without doing free_affine_expand_cache afterwards. >> > >> > If you can find that, I'd say it would be the safest thing to do. >> > But let's see what say Richard thinks about it too. >> >> I think keeping the SCEV cache live over multiple passes is fragile (we do > re- >> use SSA names and passes do not appropriately call scev_reset[_htab] in > all >> cases). >> >> With fixing that the easiest approach is to associate a affine-expand > cache >> with the scev info. >> >> Without that there isn't a very good solution other than discarding the > cache >> after each expansion at the point you use it. The SCEV cache should >> effectively make most of the affine expansion caching moot (but you can > try >> instrumenting that to verify it). >> >> That is, I suggest to try freeing the cache right after the second >> tree_to_aff_combination_expand. >> >> Btw, >> >> + /* Try harder to check if they are equal. */ >> + tree_to_aff_combination_expand (left, type, &aff1, &peeled_chrec_map); >> + tree_to_aff_combination_expand (step_val, type, &aff2, >> + &peeled_chrec_map); aff_combination_scale (&aff2, >> + double_int_minus_one); aff_combination_add (&aff1, &aff2); left = >> + fold_convert (type, aff_combination_to_tree (&aff1)); >> + >> + /* Transform (init, {left, right}_LOOP)_LOOP to {init, right}_LOOP >> + if "left" equals to "init + right". */ if (operand_equal_p >> + (left, integer_zero_node, 0)) >> >> you don't need aff_combination_to_tree, simply check >> >> aff1.n == 0 && aff1.offset.is_zero () >> >> (you may want to add aff_combination_zero_p or even >> aff_combination_equal_p) > > Hi, > This is the new version patch with bug 59445 fixed and calling free_affine > stuff just after it is used. I also added aff_combination_zero_p as > suggested. > The change in add_old_iv_candidates is unnecessary now, since the previous > version patch triggered the assertion, I just leave it here as an additional > check. > > At last, apology that I missed java in bootstrap before. > > Bootstrap and test on x86/x86_64, arm is still ongoing. Is it OK if tests > pass. Ok. Thanks, Richard. > Thanks, > bin > > 2013-12-12 Bin Cheng > > PR tree-optimization/58296 > PR tree-optimization/41488 > * tree-scalar-evolution.c: Include necessary header files. > (simplify_peeled_chrec): New function. > (analyze_evolution_in_loop): New static variable. > Call simplify_peeled_chrec. > * tree-ssa-loop-ivopts.c (mark_bivs): Don't mark peeled IV as biv. > (add_old_iv_candidates): Don't add candidate for peeled IV. > * tree-affine.h (aff_combination_zero_p): New function. > > gcc/testsuite/ChangeLog > 2013-12-12 Bin Cheng > > PR tree-optimization/58296 > PR tree-optimization/41488 > * gcc.dg/tree-ssa/scev-7.c: New test. > * gcc.dg/pr41488.c: New test. > * g++.dg/pr59445.C: New test.
Re: [REPOST] Invalid Code when reading from unaligned zero-sized array
On Wed, Dec 11, 2013 at 8:19 PM, Eric Botcazou wrote: >> Yes we do, even for struct { struct { int a; char a[1] } }; (note the not >> really "trailing" as there is padding after the trailing array). We do >> take size limitations from a DECL (if we see one) into account to limit the >> effect of this trailing-array-supporting, so it effectively only applies to >> indirect accesses (and the padding example above, you can use the whole >> padding if DECL_SIZE allows that). > > OK, so we want the attached patch? FWIW it passed > > make -k check-c check-c++ RUNTESTFLAGS="compat.exp struct-layout-1.exp" > > on x86/Linux, x86-64/Linux, PowerPC/Linux [*], IA-64/Linux, SPARC/Solaris and > SPARC64/Solaris with ALT_CC_UNDER_TEST set to the unpatched compiler. > > [*] the failures (DFP related) are the same as with the unpatched compiler. + /* As a GNU extension, we support out-of-bounds accesses for a trailing + array in a record type. In this case, if the element type has a non + zero size, then the record type effectively has variable size so it + needs to have BLKmode. */ + if (!DECL_CHAIN (field) The next field may be a TYPE_DECL with struct { char c[8]; typedef int x; }; Instead I'd suggest to keep a 'last_field_array_p' flag that you can check at the end of the loop. + && TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE + && !integer_zerop (TYPE_SIZE (TREE_TYPE (TREE_TYPE (field) +return; + Why does this exclude zero-sized element types? That looks odd to me ;) Btw, the loop already has if (TREE_CODE (TREE_TYPE (field)) == ERROR_MARK || (TYPE_MODE (TREE_TYPE (field)) == BLKmode && ! TYPE_NO_FORCE_BLK (TREE_TYPE (field)) && !(TYPE_SIZE (TREE_TYPE (field)) != 0 && integer_zerop (TYPE_SIZE (TREE_TYPE (field) || ! tree_fits_uhwi_p (bit_position (field)) || DECL_SIZE (field) == 0 || ! tree_fits_uhwi_p (DECL_SIZE (field))) return; which then is supposed to handle struct { struct { char c[8]; } a; } - but it seems to special-case zero-sized members again, thus struct { struct { char c[0]; } a; } would still be broken after your patch? The issue Bernd raises is real as well, though we probably should fix this in a different way by using a different DECL_MODE based on the types size for asm register vars? Btw, do you think we can recover from some of the now BLKmodes by having DECL_MODE != TYPE_MODE? Thanks, Richard. > -- > Eric Botcazou
Re: [trunk]: Patch to move BITS_PER_UNIT to be available for genmodes.c
Hello! > In addition, this target also changes the way that MAX_BITSIZE_MODE_ANY_INT > is calculated. > The value is heavily used on the wide-int branch to allocate buffers that are > used to hold large > integer values. The change in the way it is computed was motivated by the > i386 port, but there > may be other ports that have the same problem. The i386 port defines two very > large integer > modes that are only used as containers for large vectors. They are never used > for large integers. > The new way of computing this allows a port to say (very early) that some of > these integer modes > are never used to hold numbers and so smaller buffers can be used for integer > calculations. Other > ports that play the same game should follow suit. Index: gcc/config/i386/i386-modes.def === --- gcc/config/i386/i386-modes.def (revision 205895) +++ gcc/config/i386/i386-modes.def (working copy) @@ -90,5 +90,10 @@ VECTOR_MODE (INT, QI, 2); /* INT_MODE (OI, 32); INT_MODE (XI, 64); +/* Keep the OI and XI modes from confusing the compiler into thinking + that these modes could actually be used for computation. They are + only holders for vectors during data movement. */ +#define MAX_BITSIZE_MODE_ANY_INT (128) + /* The symbol Pmode stands for one of the above machine modes (usually SImode). The tm.h file specifies which one. It is not a distinct mode. */ __int128 is avaialble only for x86_64 - 64bit targets, so: #define MAX_BITSIZE_MODE_ANY_INT (TARGET_64BIT ? 128 : 64) Uros.
Re: RFA (cgraph): C++ 'structor decloning patch, Mark III
> On 12/12/2013 03:08 PM, Jan Hubicka wrote: > >So only reason why this is optimize_size only is the fact that we can't rely > >on inliner > >to fix up the wrappers? > > I was just being conservative. In fact, the inliner seems to handle > small [cd]tors well, inlining them into the wrappers and then into > callers. Do you think I should enable it more generally? Yep, inliner is designed to handle wrappers well (C++ programs are full of them). I see two possible problems 1) the rule about not inlining/clonning functions with comdat local calls will inhibit some propagation where we need to propagate constants across the wrapper. I am not sure if that is much of problem in practice though. 2) I am not sure if debug info is right? I suppose the wrapper can be just abstract > > >In longer term, it would be nice to disable frontend driven clonning and just > >produce the wrappers/virtual clones to be handled by middle-end. > > Agreed. The only snag is handling variadic functions. Yep, it is sad we have those to go specially here and in thunks :( > diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c > index 7fb4ab9..87c2479 100644 > --- a/gcc/ipa-inline-transform.c > +++ b/gcc/ipa-inline-transform.c > @@ -272,6 +272,18 @@ inline_call (struct cgraph_edge *e, bool update_original, > inline_update_overall_summary (to); >new_size = inline_summary (to)->size; > > + if (callee->calls_comdat_local) > +to->calls_comdat_local = true; > + else if (to->calls_comdat_local && symtab_comdat_local_p (callee)) > +{ > + struct cgraph_edge *se = to->callees; > + for (; se; se = se->next_callee) > + if (se->inline_failed && symtab_comdat_local_p (se->callee)) > + break; > + if (se == NULL) > + to->calls_comdat_local = false; > +} Actually this is still not quite right - when we have !inline_failed case, we need to check if callee calls comdat local. Moreover when we turn comdat_local to false, we need to recomute also function it is inlined into. while (to->callers && !to->callers->inline_failed) recompute for to->callers->caller to = to->callers->caller This path won't execute since we won't inline the wrapper before we inline into the wrapper, so perhaps we can just have assert with comment that this will be needed in future. I think it is just better to be sure we won't forget the flag mistakely on. > diff --git a/gcc/symtab.c b/gcc/symtab.c > index dc700e7..a448dea 100644 > --- a/gcc/symtab.c > +++ b/gcc/symtab.c > @@ -538,6 +538,7 @@ symtab_dissolve_same_comdat_group_list (symtab_node *node) > { >next = n->same_comdat_group; >n->same_comdat_group = NULL; > + DECL_COMDAT_GROUP (n->decl) = NULL_TREE; >n = next; > } >while (n != node); I think you should rather do it only for statics, DECL_ONE_ONLY functions go through specially in visibility and you may end up making function !ONE_ONLY before it is processed because we decided other function in the group to be promoted to static. In this case we may end up to handle the other as normal extern function by mistake. OK with those changes, thanks! Honza
Re: [REPOST] Invalid Code when reading from unaligned zero-sized array
> Instead I'd suggest to keep a 'last_field_array_p' flag that you can > check at the end of the loop. OK, I can do that. > + && TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE > + && !integer_zerop (TYPE_SIZE (TREE_TYPE (TREE_TYPE (field) > +return; > + > > Why does this exclude zero-sized element types? That looks odd to me ;) Because the size cannot change if you add zero to it, even multiple times? > Btw, the loop already has > > if (TREE_CODE (TREE_TYPE (field)) == ERROR_MARK > > || (TYPE_MODE (TREE_TYPE (field)) == BLKmode > > && ! TYPE_NO_FORCE_BLK (TREE_TYPE (field)) > && !(TYPE_SIZE (TREE_TYPE (field)) != 0 >&& integer_zerop (TYPE_SIZE (TREE_TYPE (field) > > || ! tree_fits_uhwi_p (bit_position (field)) > || DECL_SIZE (field) == 0 > || ! tree_fits_uhwi_p (DECL_SIZE (field))) > > return; > > which then is supposed to > handle struct { struct { char c[8]; } a; } - but it seems to > special-case zero-sized > members again, thus struct { struct { char c[0]; } a; } would still be > broken after your patch? Probably indeed, this test was added by the same patch that added the 0-sized bitfield test in the RTL expander http://gcc.gnu.org/ml/gcc-patches/2003-10/msg00823.html and that I think is obsolete now. I can remove it. > The issue Bernd raises is real as well, though we probably should fix this > in a different way by using a different DECL_MODE based on the types > size for asm register vars? Really? The number of open PRs for register variables not behaving properly at run time would make me think that this wouldn't be necessary bad... > Btw, do you think we can recover from some of the now BLKmodes by > having DECL_MODE != TYPE_MODE? Well, if you want to do that, the straightforward solution is to keep the non- BLKmode for the TYPE, put a flag on it and treat it as BLKmode when needed. -- Eric Botcazou
[GOMP4] Patch to add option for offloading
Hi, I've added option -foffload-target to specify target and options for target compiler for offloading. Please, have a look. -- Best regards, Andrey Turetskiy foffload_option.patch Description: Binary data
Re: [trunk]: Patch to move BITS_PER_UNIT to be available for genmodes.c
On Fri, 13 Dec 2013, Uros Bizjak wrote: > Hello! > > > In addition, this target also changes the way that MAX_BITSIZE_MODE_ANY_INT > > is calculated. > > The value is heavily used on the wide-int branch to allocate buffers that > > are used to hold large > > integer values. The change in the way it is computed was motivated by the > > i386 port, but there > > may be other ports that have the same problem. The i386 port defines two > > very large integer > > modes that are only used as containers for large vectors. They are never > > used for large integers. > > The new way of computing this allows a port to say (very early) that some > > of these integer modes > > are never used to hold numbers and so smaller buffers can be used for > > integer calculations. Other > > ports that play the same game should follow suit. > > Index: gcc/config/i386/i386-modes.def > === > --- gcc/config/i386/i386-modes.def (revision 205895) > +++ gcc/config/i386/i386-modes.def (working copy) > @@ -90,5 +90,10 @@ VECTOR_MODE (INT, QI, 2); /* > INT_MODE (OI, 32); > INT_MODE (XI, 64); > > +/* Keep the OI and XI modes from confusing the compiler into thinking > + that these modes could actually be used for computation. They are > + only holders for vectors during data movement. */ > +#define MAX_BITSIZE_MODE_ANY_INT (128) > + > /* The symbol Pmode stands for one of the above machine modes (usually > SImode). > The tm.h file specifies which one. It is not a distinct mode. */ > > __int128 is avaialble only for x86_64 - 64bit targets, so: > > #define MAX_BITSIZE_MODE_ANY_INT (TARGET_64BIT ? 128 : 64) It needs to be a compile-time constant. Richard.
Re: [REPOST] Invalid Code when reading from unaligned zero-sized array
On Fri, Dec 13, 2013 at 12:08 PM, Eric Botcazou wrote: >> Instead I'd suggest to keep a 'last_field_array_p' flag that you can >> check at the end of the loop. > > OK, I can do that. > >> + && TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE >> + && !integer_zerop (TYPE_SIZE (TREE_TYPE (TREE_TYPE (field) >> +return; >> + >> >> Why does this exclude zero-sized element types? That looks odd to me ;) > > Because the size cannot change if you add zero to it, even multiple times? Of course - I wonder if you hit a testcase in the testsuite. >> Btw, the loop already has >> >> if (TREE_CODE (TREE_TYPE (field)) == ERROR_MARK >> >> || (TYPE_MODE (TREE_TYPE (field)) == BLKmode >> >> && ! TYPE_NO_FORCE_BLK (TREE_TYPE (field)) >> && !(TYPE_SIZE (TREE_TYPE (field)) != 0 >>&& integer_zerop (TYPE_SIZE (TREE_TYPE (field) >> >> || ! tree_fits_uhwi_p (bit_position (field)) >> || DECL_SIZE (field) == 0 >> || ! tree_fits_uhwi_p (DECL_SIZE (field))) >> >> return; >> >> which then is supposed to >> handle struct { struct { char c[8]; } a; } - but it seems to >> special-case zero-sized >> members again, thus struct { struct { char c[0]; } a; } would still be >> broken after your patch? > > Probably indeed, this test was added by the same patch that added the 0-sized > bitfield test in the RTL expander >http://gcc.gnu.org/ml/gcc-patches/2003-10/msg00823.html > and that I think is obsolete now. I can remove it. Ok with me. >> The issue Bernd raises is real as well, though we probably should fix this >> in a different way by using a different DECL_MODE based on the types >> size for asm register vars? > > Really? The number of open PRs for register variables not behaving properly > at run time would make me think that this wouldn't be necessary bad... Yeah ... we can wait and see if anybody notices. (especially register vars that you access out-of-bounds behave erratically ...) >> Btw, do you think we can recover from some of the now BLKmodes by >> having DECL_MODE != TYPE_MODE? > > Well, if you want to do that, the straightforward solution is to keep the non- > BLKmode for the TYPE, put a flag on it and treat it as BLKmode when needed. That sounds less conservative though. Anyway, that was just some thought to fix the eventual fallout of making more types have BLKmode. Thanks, Richard. > -- > Eric Botcazou
Re: [RFC] Old school parallelization of WPA streaming
On 2013.12.06 at 10:43 +0100, Richard Biener wrote: > On Fri, 6 Dec 2013, Jan Hubicka wrote: > > > > On Thu, 21 Nov 2013, Jan Hubicka wrote: > > > > > > > > > > > > > Why do you need an additional -fparallelism? Wouldn't > > > > > -fwpa=... be a better match, matching -flto=...? As we already > > > > > pass down a -fwpa option to WPA this would make things easier, no? > > > > > > > > My plan was to possibly use same option later for parallelizing more > > > > parts of > > > > compiler, not only WPA streaming. Streaming in may have some chance if > > > > we get > > > > into thread safety of GGC or move sufficient amount of stuff out of > > > > GGC. Also > > > > we can parallelize inliner heuristic or IPA-PTA if it will ever work. > > > > So it > > > > would make sense with -flto-partition=none and perhaps with local > > > > optimization, > > > > too. > > > > > > I'd like to drop -flto-partition=none eventually. It's just one more > > > path through the compiler to support ... > > > > > > > But I can definitely update the patch to use -fwpa=N and we can deal > > > > with this > > > > once this becomes real. (i.e. I have no clue how to parallelize inliner > > > > without > > > > making its decisions dependent on the parallelizm and declining with > > > > parallelizm > > > > increased nor I have real plans for stream in procedure) > > > > > > Please. > > > > > > > Hi, > > here is updated patch. Sorry for taking time, I should have more time for > > hacking again > > now... > > Ok. Honza, it looks like you forgot to commit the patch. (I see nice speedups with it and it would be unfortunate if it fell through the cracks.) -- Markus
Re: [RFC] Old school parallelization of WPA streaming
> On 2013.12.06 at 10:43 +0100, Richard Biener wrote: > > On Fri, 6 Dec 2013, Jan Hubicka wrote: > > > > > > On Thu, 21 Nov 2013, Jan Hubicka wrote: > > > > > > > > > > > > > > > > Why do you need an additional -fparallelism? Wouldn't > > > > > > -fwpa=... be a better match, matching -flto=...? As we already > > > > > > pass down a -fwpa option to WPA this would make things easier, no? > > > > > > > > > > My plan was to possibly use same option later for parallelizing more > > > > > parts of > > > > > compiler, not only WPA streaming. Streaming in may have some chance > > > > > if we get > > > > > into thread safety of GGC or move sufficient amount of stuff out of > > > > > GGC. Also > > > > > we can parallelize inliner heuristic or IPA-PTA if it will ever work. > > > > > So it > > > > > would make sense with -flto-partition=none and perhaps with local > > > > > optimization, > > > > > too. > > > > > > > > I'd like to drop -flto-partition=none eventually. It's just one more > > > > path through the compiler to support ... > > > > > > > > > But I can definitely update the patch to use -fwpa=N and we can deal > > > > > with this > > > > > once this becomes real. (i.e. I have no clue how to parallelize > > > > > inliner without > > > > > making its decisions dependent on the parallelizm and declining with > > > > > parallelizm > > > > > increased nor I have real plans for stream in procedure) > > > > > > > > Please. > > > > > > > > > > Hi, > > > here is updated patch. Sorry for taking time, I should have more time for > > > hacking again > > > now... > > > > Ok. > > Honza, it looks like you forgot to commit the patch. > (I see nice speedups with it and it would be unfortunate if it fell > through the cracks.) I plan to commit it shortly (i am just slowly progressing through the bugreports and TODOs cumulated) - indeed for bigger apps and edit/relink cycle it is an life saver ;) Honza
Re: [PATCH] Fix PR58944
On Mon, Dec 2, 2013 at 6:46 PM, Sriraman Tallam wrote: > On Thu, Nov 28, 2013 at 9:36 PM, Bernd Edlinger > wrote: >> Hi, >> >> On Wed, 27 Nov 2013 19:49:39, Uros Bizjak wrote: >>> >>> On Mon, Nov 25, 2013 at 10:08 PM, Sriraman Tallam >>> wrote: >>> I have attached a patch to fix this bug : http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58944 A similar problem was also reported here: http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01050.html Recently, ix86_valid_target_attribute_tree in config/i386/i386.c was refactored to not depend on global_options structure and to be able to use any gcc_options structure. One clean way to fix this is by having target_option_default_node save all the default target options which can be restored to any gcc_options structure. The root cause of the above bugs was that ix86_arch_string and ix86_tune_string was not saved in target_option_deault_node in PR58944 and ix86_preferred_stack_boundary_arg was not saved in the latter case. This patch saves all the target options used in i386.opt which are either obtained from the command-line or set to some default. Is this patch alright? >>> >>> Things looks rather complicated, but I see no other solution that save >>> and restore the way you propose. >>> >>> Please wait 24h if somebody has a different idea, otherwise please go >>> ahead and commit the patch to mainline. >>> >> >> Maybe you should also look at the handling or preferred_stack_boundary_arg >> versus incoming_stack_boundary_arg in ix86_option_override_internal: >> >> Remember ix86_incoming_stack_boundary_arg is defined to >> global_options.x_ix86_incoming_stack_boundary_arg. >> >> like this? >> >> if (opts_set->x_ix86_incoming_stack_boundary_arg) >> { >> - if (ix86_incoming_stack_boundary_arg >> + if (opts->x_ix86_incoming_stack_boundary_arg >> < (TARGET_64BIT_P (opts->x_ix86_isa_flags) ? 4 : 2) >> - || ix86_incoming_stack_boundary_arg> 12) >> + || opts->x_ix86_incoming_stack_boundary_arg> 12) >> error ("-mincoming-stack-boundary=%d is not between %d and 12", >> - ix86_incoming_stack_boundary_arg, >> + opts->x_ix86_incoming_stack_boundary_arg, >>TARGET_64BIT_P (opts->x_ix86_isa_flags) ? 4 : 2); >> else >> { >> ix86_user_incoming_stack_boundary >> -= (1 << ix86_incoming_stack_boundary_arg) * BITS_PER_UNIT; >> + = (1 << opts->x_ix86_incoming_stack_boundary_arg) * >> BITS_PER_UNIT; >> ix86_incoming_stack_boundary >> = ix86_user_incoming_stack_boundary; >> } >> > > Thanks for catching this. I will make this change in the same patch. > Your change caused: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59492 -- H.J.
Re: patch for elimination to SP when it is changed in RTL (PR57293)
Thanks for your help Vlad. Another bad news about this PR fix, is that it has resurrected the thumb_movhi_clobber bug (PR 58785) but in a different manner as the original failing testcase still pass. I attached a testcase to be compiled with : cc1 -mthumb -mcpu=cortex-m0 -O2 m.c And Thumb bootstrap seems to be broken with an ICE in check_rtl, I'm checking if it is the same issue. Yvan On 12 December 2013 20:18, Vladimir Makarov wrote: > On 12/11/2013, 1:59 PM, Yvan Roux wrote: >> >> On 11 December 2013 19:25, Vladimir Makarov wrote: >>> >>> On 12/11/2013, 5:35 AM, Yvan Roux wrote: Hi Vladimir, I've some regressions on ARM after this SP elimination patch, and they are execution failures. Here is the list: g++.dg/cilk-plus/AN/array_test_ND_tplt.cc -O3 -fcilkplus gcc.c-torture/execute/va-arg-22.c -O2 gcc.dg/atomic/c11-atomic-exec-5.c -O0 gfortran.dg/direct_io_12.f90 -O[23] gfortran.dg/elemental_dependency_1.f90 -O2 gfortran.dg/matmul_2.f90 -O2 gfortran.dg/matmul_6.f90 -O2 gfortran.dg/mvbits_7.f90 -O3 gfortran.dg/unlimited_polymorphic_1.f03 -O3 I reduced and looked at var-arg-22.c and the issue is that in lra_eliminate_regs_1 (called by get_equiv_with_elimination) we transformed sfp + 0x4c in sp + 0xfc because of a bad sp offset. What we try to do here is to change the pseudo 195 of the insn 118 below : (insn 118 114 112 8 (set (reg:DI 195) (unspec:DI [ (mem:DI (plus:SI (reg/f:SI 215) (const_int 8 [0x8])) [7 MEM[(struct A35 *)_12 + 64B]+8 S8 A8]) ] UNSPEC_UNALIGNED_LOAD)) v2.c:49 146 {unaligned_loaddi} (expr_list:REG_EQUIV (mem/c:DI (plus:SI (reg/f:SI 192) (const_int 8 [0x8])) [7 a35+8 S8 A32]) (nil))) with its equivalent (x arg of lra_eliminate_regs_1): (mem/c:DI (plus:SI (reg/f:SI 102 sfp) (const_int 76 [0x4c])) [7 a35+8 S8 A32]) lra_eliminate_regs_1 is called with full_p = true (it is not really clear for what it means), >>> >>> >>> >>> It means we use full offset between the regs, otherwise we use change in >>> the >>> full offset from the previous iteration (it can be changed as we reserve >>> stack memory for spilled pseudos and the reservation can be done several >>> times). As equiv value is stored as it was before any elimination, we >>> need >>> always to use full offset to make elimination. >> >> >> Ok thanks it's clearer. >> >>> but in the PLUS switch case, we have offset = 0xb (given by ep->offset) and as lra_get_insn_recog_data (insn)->sp_offset value is 0, we will indeed add 0xb to the original 0x4c offset. >>> >>> 0 value is suspicious because it is default. We might have not set up it >>> from neighbor insns. >>> >>> >>> So, here I don't get if it is the sp_offset value of the lra_insn_recog_data element which is not well updated or if lra_ eliminate_regs_1 has to be called with update_p and not full_p (which fixed the value in that particular case). Is it more obvious for you ? >>> >>> Yvan, could you send me the reduced preprocessed case and the options for >>> cc1 to reproduce it. >> >> >> >> Here is cc1 command line : >> >> cc1 -quiet -march=armv7-a -mtune=cortex-a15 -mfloat-abi=hard >> -mfpu=neon -mthumb v2.c -O2 >> >> I use a native build on a chromebook, but it's reproducible with a >> cross compiler. >> >> With the attached test case the issue is when processing insn 118. > > > The offset is updated two times and that is wrong. That is because memory > in init insn is shared by ira_reg_equiv and the test involves 2 equivalent > substitutions. As I wrote equiv should be stored in original form by the > current patch design. Simple copying will not work as the first > substitution is not done in this case. > > I need some time to think how to fix it better still I'll try to fix it > tomorrow. I expected that the patch might have some problems. The patch > code is quite big although it is just a long standing PR fix. Therefore that > was my first PR fixed on stage 3. It is good to have it tested earlier and > sorry to break some arm tests. > > void free (void *) ; extern int *__errno (void); typedef unsigned int size_t; typedef unsigned int __uint32_t; typedef unsigned short __uint16_t; typedef struct _bufhead BUFHEAD; struct _bufhead { BUFHEAD *prev; BUFHEAD *next; BUFHEAD *ovfl; __uint32_t addr; char *page; char flags; }; typedef BUFHEAD **SEGMENT; typedef struct hashhdr { int magic; int version; __uint32_t lorder; int bsize; int bshift; int dsize; int ssize; int sshift; int ovfl_point; int last_freed; int max_bucket; int high_mask; int low_mask; int ffactor; int nkeys; int hdrpages; int h_charkey; int spares[32]; __uint16_t bitmaps[32]; } HASHHDR; type
[x86 PATCH] Fix cost model for Silvermont.
Hi All, Attached is one-line fix which reduced a cost of integer multiplication for HI mode since imul instruction design was improved in SLM (in comparison with Atom). Is it OK for trunk? ChangeLog: 2013-12-13 Yuri Rumyantsev * config/i386/i386.c (slm_cost): Fix imul cost for HI. x86-SLM-imul-fix Description: Binary data
Re: [x86 PATCH] Fix cost model for Silvermont.
On Fri, Dec 13, 2013 at 2:42 PM, Yuri Rumyantsev wrote: > Attached is one-line fix which reduced a cost of integer > multiplication for HI mode since imul instruction design was improved > in SLM (in comparison with Atom). > > Is it OK for trunk? > > ChangeLog: > > 2013-12-13 Yuri Rumyantsev > * config/i386/i386.c (slm_cost): Fix imul cost for HI. OK. Thanks, Uros.
Re: RFA (cgraph): C++ 'structor decloning patch, Mark III
On 12/13/2013 05:58 AM, Jan Hubicka wrote: + if (callee->calls_comdat_local) +to->calls_comdat_local = true; + else if (to->calls_comdat_local && symtab_comdat_local_p (callee)) +{ + struct cgraph_edge *se = to->callees; + for (; se; se = se->next_callee) + if (se->inline_failed && symtab_comdat_local_p (se->callee)) + break; + if (se == NULL) + to->calls_comdat_local = false; +} Actually this is still not quite right - when we have !inline_failed case, we need to check if callee calls comdat local. Moreover when we turn comdat_local to false, we need to recompute also function it is inlined into. I don't see why. If function A calls function B, which calls comdat-local function C, A can be inlined, so why do we need to recompute anything for A after we inline C into B? Jason
Re: [C++ PATCH] Fix GC related issues in C++ FE (PR c++/58627)
On Thu, Dec 12, 2013 at 5:36 AM, Jakub Jelinek wrote: > On Wed, Dec 11, 2013 at 11:51:55AM -0500, Jason Merrill wrote: >> It's only safe to free the targs if they weren't used to instantiate >> any templates, so I lean toward option #1. Did you test this with >> strict gc? > > Ok, after IRC discussion and another bootstrap/regtest I've installed > this variant instead: > > 2013-12-12 Jakub Jelinek > > PR c++/58627 > * call.c (add_template_candidate_real): Don't call ggc_free on targs. > > --- gcc/cp/class.c.jj 2013-11-28 08:18:58.0 +0100 > +++ gcc/cp/class.c 2013-12-11 20:57:40.155059669 +0100 > @@ -7475,8 +7475,6 @@ resolve_address_of_overloaded_function ( > /* See if there's a match. */ > if (same_type_p (target_fn_type, static_fn_type (instantiation))) > matches = tree_cons (instantiation, fn, matches); > - > - ggc_free (targs); > } > >/* Now, remove all but the most specialized of the matches. */ > Has this been checked in? I still see random: FAIL: 17_intro/headers/c++200x/stdc++.cc (test for excess errors) FAIL: 17_intro/headers/c++200x/stdc++_multiple_inclusion.cc (test for excess errors) http://gcc.gnu.org/ml/gcc-testresults/2013-12/msg01230.html -- H.J.
PATCH: PR target/59492: Don't change -fPIC
We can't change -fPIC underneath in x86 backend while middle-end is unchanged. This patch restores opts->x_flag_pic from global flag_pic. OK to install? Thanks. H.J. --- 2013-12-12 H.J. Lu PR target/59492 * config/i386/i386.c (ix86_function_specific_restore): Don't change -fPIC. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 9fd6baa..2d79ee6 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -4333,6 +4333,9 @@ ix86_function_specific_restore (struct gcc_options *opts, unsigned int ix86_arch_mask; int i; + /* We don't change -fPIC. */ + opts->x_flag_pic = flag_pic; + ix86_arch = (enum processor_type) ptr->arch; ix86_schedule = (enum attr_cpu) ptr->schedule; ix86_tune = (enum processor_type) ptr->tune;
Re: [trunk]: Patch to move BITS_PER_UNIT to be available for genmodes.c
On Dec 13, 2013, at 5:11 AM, Richard Biener wrote: > On Fri, 13 Dec 2013, Uros Bizjak wrote: > >> Hello! >> >>> In addition, this target also changes the way that MAX_BITSIZE_MODE_ANY_INT >>> is calculated. >>> The value is heavily used on the wide-int branch to allocate buffers that >>> are used to hold large >>> integer values. The change in the way it is computed was motivated by the >>> i386 port, but there >>> may be other ports that have the same problem. The i386 port defines two >>> very large integer >>> modes that are only used as containers for large vectors. They are never >>> used for large integers. >>> The new way of computing this allows a port to say (very early) that some >>> of these integer modes >>> are never used to hold numbers and so smaller buffers can be used for >>> integer calculations. Other >>> ports that play the same game should follow suit. >> >> Index: gcc/config/i386/i386-modes.def >> === >> --- gcc/config/i386/i386-modes.def (revision 205895) >> +++ gcc/config/i386/i386-modes.def (working copy) >> @@ -90,5 +90,10 @@ VECTOR_MODE (INT, QI, 2); /* >> INT_MODE (OI, 32); >> INT_MODE (XI, 64); >> >> +/* Keep the OI and XI modes from confusing the compiler into thinking >> + that these modes could actually be used for computation. They are >> + only holders for vectors during data movement. */ >> +#define MAX_BITSIZE_MODE_ANY_INT (128) >> + >> /* The symbol Pmode stands for one of the above machine modes (usually >> SImode). >>The tm.h file specifies which one. It is not a distinct mode. */ >> >> __int128 is avaialble only for x86_64 - 64bit targets, so: >> >> #define MAX_BITSIZE_MODE_ANY_INT (TARGET_64BIT ? 128 : 64) > > It needs to be a compile-time constant. > > Richard. I will add a line to the effect to the doc before checking it in.
Re: PATCH to add input_line macro to gdbinit.in
On Thu, 2013-12-12 at 22:51 -0500, Jason Merrill wrote: > I often use input_line in breakpoint conditions when debugging the > compiler, and losing the macro complicates that. Any objection to > adding it to gdbinit.in? Fine by me.
Re: RFA (cgraph): C++ 'structor decloning patch, Mark III
> On 12/13/2013 05:58 AM, Jan Hubicka wrote: > >>+ if (callee->calls_comdat_local) > >>+to->calls_comdat_local = true; > >>+ else if (to->calls_comdat_local && symtab_comdat_local_p (callee)) > >>+{ > >>+ struct cgraph_edge *se = to->callees; > >>+ for (; se; se = se->next_callee) > >>+ if (se->inline_failed && symtab_comdat_local_p (se->callee)) > >>+ break; > >>+ if (se == NULL) > >>+ to->calls_comdat_local = false; > >>+} > > > >Actually this is still not quite right - when we have !inline_failed case, > >we need to check if callee calls comdat local. > > >Moreover when we turn comdat_local to false, we need to recompute also > >function it is inlined into. > > I don't see why. If function A calls function B, which calls > comdat-local function C, A can be inlined, so why do we need to > recompute anything for A after we inline C into B? The situation is whre B is inlined into A and it calls comdat local C. In this case both B and A have the flag set. now we inline C into B and we need to clean up the flag for A, too. This can probably happen when you call the wrapper ctor from the ctor itself? Honza > > Jason
[PATCH 01/16] Const-correctness fixes for some gimple accessors
gcc/ * gimple.h (gimple_assign_single_p): Accept a const_gimple rather than a gimple. (gimple_store_p): Likewise. (gimple_assign_load_p): Likewise. (gimple_assign_cast_p): Likewise. (gimple_clobber_p): Likewise. --- gcc/gimple.h | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/gimple.h b/gcc/gimple.h index c9d9a19..7337c18 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -2326,7 +2326,7 @@ gimple_assign_rhs_class (const_gimple gs) and do not have the semantics of a copy, such as COND_EXPR. */ static inline bool -gimple_assign_single_p (gimple gs) +gimple_assign_single_p (const_gimple gs) { return (is_gimple_assign (gs) && gimple_assign_rhs_class (gs) == GIMPLE_SINGLE_RHS); @@ -2335,7 +2335,7 @@ gimple_assign_single_p (gimple gs) /* Return true if GS performs a store to its lhs. */ static inline bool -gimple_store_p (gimple gs) +gimple_store_p (const_gimple gs) { tree lhs = gimple_get_lhs (gs); return lhs && !is_gimple_reg (lhs); @@ -2344,7 +2344,7 @@ gimple_store_p (gimple gs) /* Return true if GS is an assignment that loads from its rhs1. */ static inline bool -gimple_assign_load_p (gimple gs) +gimple_assign_load_p (const_gimple gs) { tree rhs; if (!gimple_assign_single_p (gs)) @@ -2361,7 +2361,7 @@ gimple_assign_load_p (gimple gs) /* Return true if S is a type-cast assignment. */ static inline bool -gimple_assign_cast_p (gimple s) +gimple_assign_cast_p (const_gimple s) { if (is_gimple_assign (s)) { @@ -2377,7 +2377,7 @@ gimple_assign_cast_p (gimple s) /* Return true if S is a clobber statement. */ static inline bool -gimple_clobber_p (gimple s) +gimple_clobber_p (const_gimple s) { return gimple_assign_single_p (s) && TREE_CLOBBER_P (gimple_assign_rhs1 (s)); -- 1.7.11.7
[RFC for next stage1 00/16] Compile-time gimple-checking
As of r205034 (de6bd75e3c9bc1efe8a6387d48eedaa4dafe622d) and r205428 (a90353203da18288cdac1b0b78fe7b22c69fe63f) the various gimple statements form a C++ inheritance hierarchy, but we're not yet making much use of that in the code: everything refers to just "gimple" (or "const_gimple"), and type-checking is performed at run-time within the various gimple_foo_* accessors in gimple.h, and almost nowhere else. The following patch series introduces compile-time checking of much of the handling of gimple statements. Various new typedefs are introduced for pointers to statements where the specific code is known, matching the corresponding names from gimple.def. For example, it introduces a "gimple_bind" typedef, which is a (gimple_statement_bind *) which has the invariant that stmt->code == GIMPLE_BIND. All of the gimple_bind_* accessors in gimple.h are converted from taking just a "gimple" to a "gimple_bind". Various other expressions have their types strengthened from "gimple" to "gimple_bind", and from plain vec to vec (e.g. within gimplify.c for handling the bind stack). Other such typedefs that are introduced are: * gimple_switch * gimple_cond * gimple_assign * gimple_label * gimple_debug * gimple_phi with various analogous strengthening of types, such as for parameters of functions, for variables, and for fields of some structs - though it's only for gimple_bind that I managed to make all the gimple.h accessors type-safe. Where necessary a new gimple_with_ops subclass is added [1], with the same layout as before, merely adding an invariant on the code. [2] In each case there are some checked downcasts from "gimple" down to the more concrete statement-type, so that the runtime-checking in the checked build happens there, at the boundary between types, rather than the current checking, which is every time an accessor is called and almost nowhere else. Once we're in a more concrete type than "gimple", the compiler can enforce the type-checking for us at compile-time. For example, various variables in tree-into-ssa.c change from just vec to being vec, capturing the "phi-ness" of the contents as a compile-time check (and then not needing to check them any more). Similarly, within tree-inline.h's struct copy_body_data, the field "debug_stmts" can be "concretized" from a vec to a vec. In doing the checked downcasts I ran into the verbosity of the as_a <> API. I first tried simplifying them with custom functions e.g.: static inline gimple_bind as_a_gimple_bind (gimple gs) { return as_a (gs); } but the approach I've gone with makes these checked casts be methods of the gimple_statement_base class, so that e.g. in a switch statement you can write: case GIMPLE_SWITCH: dump_gimple_switch (buffer, gs->as_a_gimple_switch (), spc, flags); break; where the ->as_a_gimple_switch is a no-op cast from "gimple" to the more concrete "gimple_switch" in a release build, with runtime checking for code == GIMPLE_SWITCH added in a checked build (it uses as_a <> internally). This is much less verbose than trying to do it with as_a <> directly, and I think doing it as a method reads better aloud (to my English-speaking mind, at-least): "gs as a gimple switch", as opposed to: "as a gimple switch... gs". It makes the base class a little cluttered, but IMHO it hits a sweet-spot of readability and type-safety with relatively little verbosity (only 8 more characters than doing it with a raw C-style cast). Another advantage of having the checked cast as a *method* is that it implies that the input must be non-NULL (which is the case). For phis, I made gsi_start_phis return a gimple_phi_iterator, rather than a gimple_stmt_iterator, where the phi iterator type is new, a subclass of gimple_stmt_iterator. It has identical layout, but adds a "phi ()" method, which is like gsi_stmt(), but does a checked cast to a gimple_phi. This allows great swathes of phi-manipulation code to be concretized into working on type "gimple_phi" (rather than just "gimple"), with minimal patching. Having these typedefs around may also be useful for debugging, so that you can now type e.g. (gdb) p *(gimple_cond)stmt to quickly get all fields of a stmt (without having to think "is this code a gimple_statement_with_ops?") Successfully bootstrapped®tested the cumulative effect of the patches on x86_64-unknown-linux-gnu (albeit without cloog and thus graphite I now realize), on top of r205716. It's a work-in-progress: I'm posting it now to confirm that I'm on the right track. I'm excited about this approach: but given how much code it changes, I'm guessing this is more appropriate for the next stage1 than 4.9's stage3, (in which case I can start a branch). Though if there's a sudden rush of enthusiasm for more C++ I'm happy to apply it to trunk now :) (that said patch 1 in the series probably *is* appropriate for trunk as-is). Thoughts? Dave [1] the exception is gimple_assign, which subcl
[PATCH 03/16] Introduce gimple_bind and use it for accessors.
This updates all of the gimple_bind_* accessors in gimple.h from taking a plain gimple to taking a gimple_bind (or const_gimple_bind), with the checking happening at the point of cast. Various other types are strengthened from gimple to gimple_bind, and from plain vec to vec. gcc/ * coretypes.h (gimple_bind): New typedef. (const_gimple_bind): New typedef. * gdbhooks.py (build_pretty_printer): Add gimple_bind and its variants, using the gimple printer. * gimple-pretty-print.c (dump_gimple_bind): Update type-signature to require a gimple_bind rather than just a gimple. * gimple.c (gimple_build_bind): Return a gimple_bind rather than just a gimple. * gimple.h (gimple_build_bind): Likewise. * gimple.h (gimple_statement_base::as_a_gimple_bind): New. (gimple_statement_base::dyn_cast_gimple_bind): New. (gimple_seq_first_stmt_as_a_bind): New. * gimple.h (gimple_bind_vars): Update type-signature to require a gimple_bind rather than just a gimple, removing as_a and hence run-time check. (gimple_bind_set_vars): Likewise. (gimple_bind_append_vars): Likewise. (gimple_bind_body_ptr): Likewise. (gimple_bind_body): Likewise. (gimple_bind_set_body): Likewise. (gimple_bind_add_stmt): Likewise. (gimple_bind_add_seq): Likewise. (gimple_bind_block): Likewise. (gimple_bind_set_block): Likewise. * gimplify.c (gimple_push_bind_expr): Likewise. (gimple_current_bind_expr): Likewise. * tree-inline.c (copy_gimple_bind): Likewise. * gimplify.h (gimple_current_bind_expr): Return a gimple_bind rather than a plain gimple. (gimplify_body): Likewise. (gimple_bind_expr_stack): Return a vec rather than a vec. * gimplify.c (struct gimplify_ctx): Strengthen field "bind_expr_stack" from vec to vec. (gimple_bind_expr_stack): Likewise for type of returned value. * gimplify.c (gimplify_body): Strengthen various types from gimple to gimple_bind, including the return type. * gimplify.c (declare_vars): Introduce "gs" as a generic gimple, so that local "scope" can be of type gimple_bind once we've reached the region where it must be of code GIMPLE_BIND. * gimple-low.c (lower_gimple_bind): Add checked cast to gimple_bind, since both callers (lower_function_body and lower_stmt) have checked the code for us. * gimple.c (gimple_copy): Add checked cast to gimple_bind in region guarded by check for code GIMPLE_BIND. * gimple-low.c (gimple_stmt_may_fallthru): Likewise. * gimple-pretty-print.c (pp_gimple_stmt_1): Likewise. * gimple-walk.c (walk_gimple_stmt): Likewise. * omp-low.c (scan_omp_1_stmt): Likewise. (lower_omp_1): Likewise. * tree-cfg.c (verify_gimple_in_seq_2): Likewise. (do_warn_unused_result): Likewise. * tree-inline.c (remap_gimple_stmt): Likewise. (estimate_num_insns): Likewise. * tree-nested.c (convert_nonlocal_reference_stmt): Likewise. * gimplify.c (gimplify_bind_expr): Update local(s) to be a gimple_bind rather than just a gimple. (gimplify_function_tree): Likewise. * omp-low.c (lower_omp_sections): Likewise. (lower_omp_single): Likewise. (lower_omp_master): Likewise. (lower_omp_taskgroup): Likewise. (lower_omp_ordered): Likewise. (lower_omp_critical): Likewise. (lower_omp_taskreg): Likewise. (lower_omp_teams): Likewise. * omp-low.c (lower_omp_for): Likewise; use gimple_seq_first_stmt_as_a_bind to encapsulate the checked cast. (lower_omp_target): Likewise. * tree-nested.c (finalize_nesting_tree_1): Likewise. * gimple.c (empty_stmt_p): Add dyn_cast to a gimple_bind. * tree-inline.c (replace_locals_stmt): Add dyn_cast to gimple_bind. gcc/c-family/ * c-gimplify.c (add_block_to_enclosing): Strengthen local "stack" from being just a vec to a vec. gcc/java/ * java-gimplify.c (java_gimplify_block): Update local to be a gimple_bind rather than just a gimple. --- gcc/c-family/c-gimplify.c | 4 ++-- gcc/coretypes.h | 4 gcc/gdbhooks.py | 4 +++- gcc/gimple-low.c | 5 +++-- gcc/gimple-pretty-print.c | 4 ++-- gcc/gimple-walk.c | 5 +++-- gcc/gimple.c | 21 +++--- gcc/gimple.h | 55 --- gcc/gimplify.c| 37 +++ gcc/gimplify.h| 6 +++--- gcc/java/java-gimplify.c | 2 +- gcc/omp-low.c | 40 +- gcc/tree-cfg.c| 5 +++-- gcc/tree-inline.c | 12 ++- gcc/tree-nested.c | 21 ++---
[PATCH 05/16] Introduce gimple_assign and use it in various places
gcc/ * coretypes.h (gimple_assign): New typedef. (const_gimple_assign): New typedef. * gimple.h (struct gimple_statement_assign): New subclass of gimple_statement_with_memory_ops, adding the invariant that stmt->code == GIMPLE_ASSIGN. (gimple_statement_base::as_a_gimple_assign): New. (gimple_statement_base::dyn_cast_gimple_assign): New. (is_a_helper ::test): New. * gdbhooks.py (build_pretty_printer): Add gimple_assign and its variants, using the gimple printer. * gimple-builder.c (build_assign): Return a gimple_assign rather than just a gimple from each of the overloaded variants. (build_type_cast): Likewise. * gimple-builder.h (build_assign): Likewise. (build_type_cast): Likewise. * gimple.c (gimple_build_assign_stat): Likewise. (gimple_build_assign_with_ops): Likewise. * gimple.h (gimple_build_assign_stat): Likewise. (gimple_build_assign_with_ops): Likewise. * asan.c (get_mem_ref_of_assignment): Require a const_gimple_assign rather than just a "const gimple" (the latter is not a "const_gimple"). * gimple-pretty-print.c (dump_unary_rhs): Require a gimple_assign rather than just a gimple. (dump_binary_rhs): Likewise. (dump_ternary_rhs): Likewise. * tree-cfg.c (verify_gimple_assign_unary): Likewise. (verify_gimple_assign_binary): Likewise. (verify_gimple_assign_ternary): Likewise. (verify_gimple_assign_single): Likewise. (verify_gimple_assign): Likewise. * tree-ssa-sccvn.c (simplify_unary_expression): Likewise. (try_to_simplify): Likewise. * tree-tailcall.c (process_assignment): Likewise. * tree-vect-generic.c (expand_vector_operation): Likewise. * tree-vrp.c (extract_range_from_cond_expr): Likewise. (extract_range_from_assignment): Likewise. * asan.c (has_stmt_been_instrumented_p): Add checked cast to gimple_assign in regions where a stmt is known to have code GIMPLE_ASSIGN. * gimple-pretty-print.c (pp_gimple_stmt_1): Likewise. * tree-cfg.c (verify_gimple_stmt): Likewise. * tree-ssa-sccvn.c (visit_use): Likewise. * tree-tailcall.c (find_tail_calls): Likewise. * tree-vrp.c (vrp_visit_assignment_or_call): Likewise. * tree-vrp.c (simplify_stmt_for_jump_threading): Replace a check against GIMPLE_ASSIGN with a dyn_cast_gimple_assign, introducing a gimple_assign local. * tree-vect-generic.c (expand_vector_condition): Convert local to a gimple_assign, adding a checked cast when extracting from gsi, since this is only called when underlying stmt has code GIMPLE_ASSIGN. (optimize_vector_constructor): Likewise. (lower_vec_perm): Likewise. (expand_vector_operations_1): Convert local to a gimple_assign, introducing a dyn_cast. --- gcc/asan.c| 5 +++-- gcc/coretypes.h | 4 gcc/gdbhooks.py | 2 ++ gcc/gimple-builder.c | 16 gcc/gimple-builder.h | 16 gcc/gimple-pretty-print.c | 10 +- gcc/gimple.c | 10 +- gcc/gimple.h | 41 - gcc/tree-cfg.c| 12 ++-- gcc/tree-ssa-sccvn.c | 6 +++--- gcc/tree-tailcall.c | 5 +++-- gcc/tree-vect-generic.c | 13 +++-- gcc/tree-vrp.c| 12 ++-- 13 files changed, 96 insertions(+), 56 deletions(-) diff --git a/gcc/asan.c b/gcc/asan.c index 74140d6..1c95da1 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -433,7 +433,7 @@ has_mem_ref_been_instrumented (const asan_mem_ref *ref, tree len) otherwise. */ static bool -get_mem_ref_of_assignment (const gimple assignment, +get_mem_ref_of_assignment (const_gimple_assign assignment, asan_mem_ref *ref, bool *ref_is_store) { @@ -801,7 +801,8 @@ has_stmt_been_instrumented_p (gimple stmt) asan_mem_ref r; asan_mem_ref_init (&r, NULL, 1); - if (get_mem_ref_of_assignment (stmt, &r, &r_is_store)) + if (get_mem_ref_of_assignment (stmt->as_a_gimple_assign (), &r, +&r_is_store)) return has_mem_ref_been_instrumented (&r); } else if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL)) diff --git a/gcc/coretypes.h b/gcc/coretypes.h index bb7c0bd..831a8a7 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -78,6 +78,10 @@ struct gimple_statement_switch; typedef struct gimple_statement_switch *gimple_switch; typedef const struct gimple_statement_switch *const_gimple_switch; +struct gimple_statement_assign; +typedef struct gimple_statement_assign *gimple_assign; +typedef const struct gimple_statement_assign *const_gimple_assign; + struct gimple_statement_bind; ty
[PATCH 02/16] Introduce gimple_switch and use it in various places
gcc/ * gimple.h (gimple_statement_switch): New subclass of gimple_statement_with_ops, adding the invariant that stmt->code == GIMPLE_SWITCH. (gimple_statement_base::as_a_gimple_switch): New. (gimple_statement_base::dyn_cast_gimple_switch): New. (is_a_helper ::test (gimple)): New. * coretypes.h (gimple_switch): New typedef (const_gimple_switch): Likewise. * gdbhooks.py (build_pretty_printer): Add gimple_switch and its variants, using the gimple printer. * gimple.c (gimple_build_switch_nlabels): Return a gimple_switch rather than just a gimple. (gimple_build_switch): Likewise. * gimple.h (gimple_build_switch_nlabels): Likewise. (gimple_build_switch): Likewise. * gimple.h (gimple_switch_num_labels): Update type-signature to require a gimple_switch rather than just a gimple. (gimple_switch_set_num_labels): Likewise. (gimple_switch_set_index): Likewise. (gimple_switch_label): Likewise. (gimple_switch_set_label): Likewise. (gimple_switch_default_label): Likewise. (gimple_switch_set_default_label): Likewise. * expr.h (expand_case): Likewise. * gimple-pretty-print.c (dump_gimple_call): Likewise. * stmt.c (compute_cases_per_edge): Likewise. (expand_case): Likewise. * tree-cfg.h (group_case_labels_stmt): Likewise. * tree-cfg.c (make_gimple_switch_edges): Likewise. (find_taken_edge_switch_expr) Likewise. (find_case_label_for_value) Likewise. (get_cases_for_edge): Likewise. (group_case_labels_stmt): Likewise. (verify_gimple_switch): Likewise. * tree-eh.c (verify_norecord_switch_expr): Likewise. * tree-eh.c (lower_eh_constructs_2): Likewise. * tree-loop-distribution.c (generate_loops_for_partition): Likewise. * tree-ssa-dom.c (record_edge_info): Likewise. * tree-ssa-forwprop.c (simplify_gimple_switch_label_vec): Likewise. (simplify_gimple_switch): Likewise. * tree-switch-conversion.c (emit_case_bit_tests): Likewise. (collect_switch_conv_info): Likewise. (build_constructors): Likewise. (array_value_type): Likewise. (build_one_array): Likewise. (build_arrays): Likewise. (gen_inbound_check): Likewise. * tree-vrp.c (find_switch_asserts): Likewise. (find_case_label_range): Likewise. (find_case_label_ranges): Likewise. (vrp_visit_switch_stmt): Likewise. (simplify_switch_using_ranges): Likewise. * tree-vrp.c (switch_update): Strengthen field "stmt" from being merely a gimple to being a gimple_switch. * cfgexpand.c (expand_gimple_stmt_1): Add checked cast to gimple_switch in regions where the stmt code has been tested as GIMPLE_SWITCH. * gimple-pretty-print.c (pp_gimple_stmt_1): Likewise. * tree-cfg.c (make_edges): Likewise. (end_recording_case_labels): Likewise. (cleanup_dead_labels): Likewise. (cleanup_dead_labels): Likewise. (group_case_labels): Likewise. (find_taken_edge): Likewise. (find_case_label_for_value): Likewise. (verify_gimple_stmt): Likewise. (gimple_verify_flow_info): Likewise. (gimple_redirect_edge_and_branch): Likewise. * tree-inline.c (estimate_num_insns): Likewise. * tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Likewise. * tree-ssa-uncprop.c (associate_equivalences_with_edges): Likewise. * tree-switch-conversion.c (do_switchconv): Likewise. * tree-vrp.c (find_assert_locations_1): Likewise. (vrp_visit_stmt): Likewise. (simplify_stmt_using_ranges): Likewise. * ipa-inline-analysis.c (set_switch_stmt_execution_predicate): Introduce local "lastg" as a generic gimple, so that local "last" can be of type gimple_switch once lastg's code has been verified. * omp-low.c (diagnose_sb_2): Introduce switch_stmt local to handle the GIMPLE_SWITCH case. * tree-cfg.c (find_taken_edge_switch_expr): Add gimple_switch argument, since the caller (find_taken_edge) has checked that last_stmt is a switch. --- gcc/cfgexpand.c | 2 +- gcc/coretypes.h | 8 + gcc/expr.h | 2 +- gcc/gdbhooks.py | 7 - gcc/gimple-pretty-print.c| 5 ++-- gcc/gimple.c | 11 +++ gcc/gimple.h | 71 ++-- gcc/ipa-inline-analysis.c| 7 +++-- gcc/omp-low.c| 5 ++-- gcc/stmt.c | 4 +-- gcc/tree-cfg.c | 57 ++- gcc/tree-cfg.h | 2 +- gcc/tree-eh.c| 5 ++-- gcc/tree-inline.c| 21 +++-- gcc/tree-loop-distribut
[PATCH 06/16] Introduce gimple_label and use it in a few places
gcc/ * coretypes.h (gimple_label): New typedef. (const_gimple_label): New typedef. * gimple.h (struct gimple_statement_label): New subclass of gimple_statement_with_ops, adding the invariant that stmt->code == GIMPLE_LABEL. (gimple_statement_base::as_a_gimple_label): New. (gimple_statement_base::dyn_cast_gimple_label): New. (is_a_helper ::test): New. * gdbhooks.py (build_pretty_printer): Add gimple_label and its variants, reusing the gimple printer. * gimple-pretty-print.c (dump_gimple_label): Require a gimple_label rather than just a gimple. * tree-cfg.c (verify_gimple_label): Likewise. * gimple.c (gimple_build_label): Return a gimple_label rather than just a gimple. * gimple.h (gimple_build_label): Likewise. * gimplify.c (gimplify_case_label_expr): Update local to be a gimple_label. * tree-switch-conversion.c (gen_inbound_check): Likewise. * gimple-pretty-print.c (pp_gimple_stmt_1): Add checked cast to gimple_label in regions where a stmt is known to have code GIMPLE_LABEL. * tree-cfg.c (verify_gimple_stmt): Likewise. --- gcc/coretypes.h | 4 gcc/gdbhooks.py | 2 ++ gcc/gimple-pretty-print.c| 4 ++-- gcc/gimple.c | 5 +++-- gcc/gimple.h | 36 +++- gcc/gimplify.c | 6 +++--- gcc/tree-cfg.c | 4 ++-- gcc/tree-switch-conversion.c | 2 +- 8 files changed, 52 insertions(+), 11 deletions(-) diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 831a8a7..5d69c5d 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -74,6 +74,10 @@ struct gimple_statement_cond; typedef struct gimple_statement_cond *gimple_cond; typedef const struct gimple_statement_cond *const_gimple_cond; +struct gimple_statement_label; +typedef struct gimple_statement_label *gimple_label; +typedef const struct gimple_statement_label *const_gimple_label; + struct gimple_statement_switch; typedef struct gimple_statement_switch *gimple_switch; typedef const struct gimple_statement_switch *const_gimple_switch; diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index 933a7ee..2b29585 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -459,6 +459,8 @@ def build_pretty_printer(): # Keep this in the same order as gimple.def: 'gimple_cond', 'const_gimple_cond', 'gimple_statement_cond *', + 'gimple_label', 'const_gimple_label', + 'gimple_statement_label *', 'gimple_switch', 'const_gimple_switch', 'gimple_statement_switch *', 'gimple_assign', 'const_gimple_assign', diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index 9f55bcf..515e0b9 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -853,7 +853,7 @@ dump_gimple_cond (pretty_printer *buffer, gimple_cond gs, int spc, int flags) TDF_* in dumpfils.h). */ static void -dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags) +dump_gimple_label (pretty_printer *buffer, gimple_label gs, int spc, int flags) { tree label = gimple_label_label (gs); if (flags & TDF_RAW) @@ -2110,7 +2110,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags) break; case GIMPLE_LABEL: - dump_gimple_label (buffer, gs, spc, flags); + dump_gimple_label (buffer, gs->as_a_gimple_label (), spc, flags); break; case GIMPLE_GOTO: diff --git a/gcc/gimple.c b/gcc/gimple.c index e94dd33..cf7613c 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -481,10 +481,11 @@ gimple_cond_set_condition_from_tree (gimple_cond stmt, tree cond) /* Build a GIMPLE_LABEL statement for LABEL. */ -gimple +gimple_label gimple_build_label (tree label) { - gimple p = gimple_build_with_ops (GIMPLE_LABEL, ERROR_MARK, 1); + gimple_label p = gimple_build_with_ops (GIMPLE_LABEL, ERROR_MARK, + 1)->as_a_gimple_label (); gimple_label_set_label (p, label); return p; } diff --git a/gcc/gimple.h b/gcc/gimple.h index af01873..e0d2226 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -217,6 +217,12 @@ public: return as_a (this); } + inline gimple_label + as_a_gimple_label () + { +return as_a (this); + } + inline gimple_switch as_a_gimple_switch () { @@ -249,6 +255,12 @@ public: return dyn_cast (this); } + inline gimple_label + dyn_cast_gimple_label () + { +return dyn_cast (this); + } + inline gimple_switch dyn_cast_gimple_switch () { @@ -843,6 +855,20 @@ struct GTY((tag("GSS_WITH_OPS"))) }; /* A statement with the invariant that + stmt->code == GIMPLE_LABEL + i.e.
[PATCH 07/16] Introduce gimple_debug and use it in a few places
gcc/ * coretypes.h (gimple_debug): New typedef. (const_gimple_debug): New typedef. * gimple.h (struct gimple_statement_debug): New subclass of gimple_statement_with_ops, adding the invariant that stmt->code == GIMPLE_DEBUG. (gimple_statement_base::as_a_gimple_debug): New. (gimple_statement_base::dyn_cast_gimple_debug): New. (is_a_helper ::test): New. * gdbhooks.py (build_pretty_printer): Add gimple_debug and its variants, using the gimple printer. * gimple-pretty-print.c (dump_gimple_debug): Require a gimple_debug rather than just a gimple. * tree-inline.c (copy_debug_stmt): Likewise. * tree-inline.h (struct copy_body_data): Strengthen field "debug_stmts" from a vec to a vec. * gimple.c (gimple_build_debug_bind_stat): Return a gimple_debug rather than just a gimple. (gimple_build_debug_source_bind_stat): Likewise. * gimple.h (gimple_build_debug_bind_stat): Likewise. (gimple_build_debug_source_bind_stat): Likewise. * tree-inline.c (remap_gimple_stmt): Update locals to be a gimple_debug. (maybe_move_debug_stmts_to_successors): Likewise. (copy_debug_stmts): Likewise. * gimple-pretty-print.c (pp_gimple_stmt_1): Add checked cast to gimple_debug in regions where a stmt is known to have code GIMPLE_DEBUG. --- gcc/coretypes.h | 4 gcc/gdbhooks.py | 2 ++ gcc/gimple-pretty-print.c | 4 ++-- gcc/gimple.c | 19 +++ gcc/gimple.h | 38 -- gcc/tree-inline.c | 16 +--- gcc/tree-inline.h | 2 +- 7 files changed, 65 insertions(+), 20 deletions(-) diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 5d69c5d..57db319 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -74,6 +74,10 @@ struct gimple_statement_cond; typedef struct gimple_statement_cond *gimple_cond; typedef const struct gimple_statement_cond *const_gimple_cond; +struct gimple_statement_debug; +typedef struct gimple_statement_debug *gimple_debug; +typedef const struct gimple_statement_debug *const_gimple_debug; + struct gimple_statement_label; typedef struct gimple_statement_label *gimple_label; typedef const struct gimple_statement_label *const_gimple_label; diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index 2b29585..9f28c4e 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -459,6 +459,8 @@ def build_pretty_printer(): # Keep this in the same order as gimple.def: 'gimple_cond', 'const_gimple_cond', 'gimple_statement_cond *', + 'gimple_debug', 'const_gimple_debug', + 'gimple_statement_debug *', 'gimple_label', 'const_gimple_label', 'gimple_statement_label *', 'gimple_switch', 'const_gimple_switch', diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index 515e0b9..aa7c148 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -1072,7 +1072,7 @@ dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags) in dumpfile.h). */ static void -dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags) +dump_gimple_debug (pretty_printer *buffer, gimple_debug gs, int spc, int flags) { switch (gs->subcode) { @@ -,7 +,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags) break; case GIMPLE_DEBUG: - dump_gimple_debug (buffer, gs, spc, flags); + dump_gimple_debug (buffer, gs->as_a_gimple_debug (), spc, flags); break; case GIMPLE_PREDICT: diff --git a/gcc/gimple.c b/gcc/gimple.c index cf7613c..a07e582 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -764,12 +764,13 @@ gimple_build_eh_dispatch (int region) VAR is bound to VALUE; block and location are taken from STMT. */ -gimple +gimple_debug gimple_build_debug_bind_stat (tree var, tree value, gimple stmt MEM_STAT_DECL) { - gimple p = gimple_build_with_ops_stat (GIMPLE_DEBUG, -(unsigned)GIMPLE_DEBUG_BIND, 2 -PASS_MEM_STAT); + gimple_debug p = +gimple_build_with_ops_stat (GIMPLE_DEBUG, + (unsigned)GIMPLE_DEBUG_BIND, 2 + PASS_MEM_STAT)->as_a_gimple_debug (); gimple_debug_bind_set_var (p, var); gimple_debug_bind_set_value (p, value); @@ -784,13 +785,15 @@ gimple_build_debug_bind_stat (tree var, tree value, gimple stmt MEM_STAT_DECL) VAR is bound to VALUE; block and location are taken from STMT. */ -gimple +gimple_debug gimple_build_debug_source_bind_stat (tree var, tree value,
[PATCH 04/16] Introduce gimple_cond and use it in various places
gcc/ * coretypes.h (gimple_cond): New typedef. (const_gimple_cond): Likewise. * gimple.h (struct gimple_statement_cond): New subclass of gimple_statement_with_ops, adding the invariant that stmt->code == GIMPLE_COND. (gimple_statement_base::as_a_gimple_cond): New. (gimple_statement_base::dyn_cast_gimple_cond): New. (is_a_helper ::test): New. (gimple_build_cond): Return a gimple_cond, rather than just a gimple. (gimple_build_cond_from_tree): Likewise. * gdbhooks.py (build_pretty_printer): Add gimple_cond and its variants, using the gimple printer. * cfgexpand.c (expand_gimple_cond): Require a gimple_cond rather than just a gimple. * gimple.h (gimple_cond_set_condition_from_tree): Likewise. (gimple_cond_true_p): Likewise. (gimple_cond_false_p): Likewise. (gimple_cond_set_condition): Likewise. * gimple.c (gimple_cond_set_condition_from_tree): Likewise. * gimple-fold.c (fold_gimple_cond): Likewise. * gimple-pretty-print.c (dump_gimple_cond): Likewise. * tree-ssa-dom.c (canonicalize_comparison): Likewise. * tree-ssa-forwprop.c (forward_propagate_into_gimple_cond): Likewise. * tree-ssa-ifcombine.c (recognize_single_bit_test): Likewise. (recognize_bits_test): Likewise. * tree-ssa-threadedge.c (simplify_control_stmt_condition): Likewise. (thread_around_empty_blocks): Likewise. (thread_through_normal_block): Likewise. (thread_across_edge): Likewise. * tree-ssa-threadedge.h (thread_across_edge): Likewise. * tree-vrp.c (range_fits_type_p): Likewise. * cfgexpand.c (expand_gimple_basic_block): Add checked cast to gimple_cond in regions where a stmt is known to have code GIMPLE_COND. * gimple-fold.c (fold_stmt_1): Likewise. * gimple-pretty-print.c (pp_gimple_stmt_1): Likewise. * tree-ssa-dom.c (optimize_stmt): Likewise. * tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Likewise. * tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Likewise. * tree-ssa-uninit.c (convert_control_dep_chain_into_preds): Likewise. * tree-vrp.c (simplify_stmt_using_ranges): Likewise. * cfgloopmanip.c (create_empty_loop_on_edge): Update local to be a gimple_cond. * tree-ssa-uninit.c (use_pred_not_overlap_with_undef_path_pred): Likewise. * tree-vrp.c (identify_jump_threads): Likewise. * gimple.c (gimple_build_cond): Return a gimple_cond, rather than just a gimple. (gimple_build_cond_from_tree): Likewise. * tree-ssa-dom.c (class dom_opt_dom_walker): Strengthen type of field "m_dummy_cond" from a plain gimple to a gimple_cond. * tree-ssa-uninit.c (struct use_pred_info): Strengthen field "cond" from a plain gimple to a gimple_cond. * tree-ssa-ifcombine.c (ifcombine_ifandif): Introduce locals inner_stmt and outer_stmt so that inner_cond and outer_cond can be of type gimple_cond once we know that we have code == GIMPLE_COND. * tree-ssa-loop-unswitch.c (tree_may_unswitch_on): Introduce local "last" so that stmt can be of type gimple_cond. --- gcc/cfgexpand.c | 4 ++-- gcc/cfgloopmanip.c | 2 +- gcc/coretypes.h | 4 gcc/gdbhooks.py | 2 ++ gcc/gimple-fold.c| 4 ++-- gcc/gimple-pretty-print.c| 4 ++-- gcc/gimple.c | 10 +- gcc/gimple.h | 43 +-- gcc/tree-ssa-dom.c | 6 +++--- gcc/tree-ssa-forwprop.c | 5 +++-- gcc/tree-ssa-ifcombine.c | 21 - gcc/tree-ssa-loop-unswitch.c | 19 --- gcc/tree-ssa-threadedge.c| 8 gcc/tree-ssa-threadedge.h| 2 +- gcc/tree-ssa-uninit.c| 6 +++--- gcc/tree-vrp.c | 6 +++--- 16 files changed, 96 insertions(+), 50 deletions(-) diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index fcee483..2cec640 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -2002,7 +2002,7 @@ maybe_cleanup_end_of_block (edge e, rtx last) block and created a new one. */ static basic_block -expand_gimple_cond (basic_block bb, gimple stmt) +expand_gimple_cond (basic_block bb, gimple_cond stmt) { basic_block new_bb, dest; edge new_edge; @@ -5012,7 +5012,7 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls) fixup the CFG accordingly. */ if (gimple_code (stmt) == GIMPLE_COND) { - new_bb = expand_gimple_cond (bb, stmt); + new_bb = expand_gimple_cond (bb, stmt->as_a_gimple_cond ()); if (new_bb) return new_bb; } diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c index 7a6b201..b0e2a5f 100644 --- a/gcc/cfgloopmanip.c +++ b/gcc/c
[PATCH 16/16] tree-ssa-loop-ivopts.c: use gimple_phi in a few places
gcc/ * tree-ssa-loop-ivopts.c (determine_biv_step): Require a gimple_phi. (find_bivs): Convert local "phi" into a gimple_phi. (mark_bivs): Likewise. --- gcc/tree-ssa-loop-ivopts.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index a510145..dfc17e9 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1009,7 +1009,7 @@ get_iv (struct ivopts_data *data, tree var) not define a simple affine biv with nonzero step. */ static tree -determine_biv_step (gimple phi) +determine_biv_step (gimple_phi phi) { struct loop *loop = gimple_bb (phi)->loop_father; tree name = PHI_RESULT (phi); @@ -1029,7 +1029,7 @@ determine_biv_step (gimple phi) static bool find_bivs (struct ivopts_data *data) { - gimple phi; + gimple_phi phi; tree step, type, base; bool found = false; struct loop *loop = data->current_loop; @@ -1074,7 +1074,7 @@ find_bivs (struct ivopts_data *data) static void mark_bivs (struct ivopts_data *data) { - gimple phi; + gimple_phi phi; tree var; struct iv *iv, *incr_iv; struct loop *loop = data->current_loop; -- 1.7.11.7
[PATCH 10/16] Update ssa_prop_visit_phi_fn callbacks to take a gimple_phi
gcc/ * tree-ssa-propagate.h (typedef ssa_prop_visit_phi_fn): Strengthen type of parameter from gimple to gimple_phi. * tree-complex.c (complex_visit_phi): Update signature of callback implementation accordingly. * tree-ssa-ccp.c (ccp_visit_phi_node): Likewise. * tree-ssa-copy.c (copy_prop_visit_phi_node): Likewise. * tree-vrp.c (vrp_visit_phi_node): Likewise. * tree-ssa-propagate.c (simulate_stmt): Add a checked cast to gimple_phi when invoking the ssa_prop_visit_phi callback. --- gcc/tree-complex.c | 2 +- gcc/tree-ssa-ccp.c | 2 +- gcc/tree-ssa-copy.c | 2 +- gcc/tree-ssa-propagate.c | 2 +- gcc/tree-ssa-propagate.h | 2 +- gcc/tree-vrp.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c index 848b5a6..03e8864 100644 --- a/gcc/tree-complex.c +++ b/gcc/tree-complex.c @@ -401,7 +401,7 @@ complex_visit_stmt (gimple stmt, edge *taken_edge_p ATTRIBUTE_UNUSED, /* Evaluate a PHI node against the complex lattice defined above. */ static enum ssa_prop_result -complex_visit_phi (gimple phi) +complex_visit_phi (gimple_phi phi) { complex_lattice_t new_l, old_l; unsigned int ver; diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 3d05258..ead744a 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -998,7 +998,7 @@ ccp_lattice_meet (prop_value_t *val1, prop_value_t *val2) of the PHI node that are incoming via executable edges. */ static enum ssa_prop_result -ccp_visit_phi_node (gimple phi) +ccp_visit_phi_node (gimple_phi phi) { unsigned i; prop_value_t *old_val, new_val; diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c index 0dd5e14..4895ac9 100644 --- a/gcc/tree-ssa-copy.c +++ b/gcc/tree-ssa-copy.c @@ -342,7 +342,7 @@ copy_prop_visit_stmt (gimple stmt, edge *taken_edge_p, tree *result_p) set it to be the value of the LHS of PHI. */ static enum ssa_prop_result -copy_prop_visit_phi_node (gimple phi) +copy_prop_visit_phi_node (gimple_phi phi) { enum ssa_prop_result retval; unsigned i; diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index 783b651..dd2536a 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -322,7 +322,7 @@ simulate_stmt (gimple stmt) if (gimple_code (stmt) == GIMPLE_PHI) { - val = ssa_prop_visit_phi (stmt); + val = ssa_prop_visit_phi (stmt->as_a_gimple_phi ()); output_name = gimple_phi_result (stmt); } else diff --git a/gcc/tree-ssa-propagate.h b/gcc/tree-ssa-propagate.h index 1b8bf90..925f995 100644 --- a/gcc/tree-ssa-propagate.h +++ b/gcc/tree-ssa-propagate.h @@ -63,7 +63,7 @@ enum ssa_prop_result { /* Call-back functions used by the value propagation engine. */ typedef enum ssa_prop_result (*ssa_prop_visit_stmt_fn) (gimple, edge *, tree *); -typedef enum ssa_prop_result (*ssa_prop_visit_phi_fn) (gimple); +typedef enum ssa_prop_result (*ssa_prop_visit_phi_fn) (gimple_phi); typedef bool (*ssa_prop_fold_stmt_fn) (gimple_stmt_iterator *gsi); typedef tree (*ssa_prop_get_value_fn) (tree); diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index ffcf220..ad90ebc 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -8331,7 +8331,7 @@ vrp_meet (value_range_t *vr0, value_range_t *vr1) value ranges, set a new range for the LHS of PHI. */ static enum ssa_prop_result -vrp_visit_phi_node (gimple phi) +vrp_visit_phi_node (gimple_phi phi) { size_t i; tree lhs = PHI_RESULT (phi); -- 1.7.11.7
Re: RFA (cgraph): C++ 'structor decloning patch, Mark III
Hi, On Wed, Dec 11, 2013 at 02:55:26PM +0100, Jan Hubicka wrote: > > On 12/10/2013 04:48 AM, Jan Hubicka wrote: > > >The case where I played with local comdats was the following. > > >I made cgraph_body_availability to get context argument (i.e. instead of > > >saying > > >if something is available in current unit, it was saying if it is available > > >in current function/variable). > > > > > >If two symbols are in the same comdat group and refering each other, they > > >are > > >available even though they may seem overwritable to others. I then started > > >to > > >produce local symbols for those local references that are equivalent to > > >your comdat > > >local. > > > > > >We probably want to get in this extension too. (I did not get data on how > > >often > > >it fires, but it does i.e. for recursive calls of C++ inlines). > > > > I wouldn't expect it to affect anything other than recursive calls, > > since before my patch functions in the same COMDAT don't call each > > other, and with my patch they only call functions that are already > > local. > > > > Also, this optimization would seem to apply to all recursive > > functions, not just those in comdat groups. > > Agreed, I already do the conversion for many functions (based on "inline" > keyword implying that there is no overwrite changing semantic). So far the > conversion > does not happen for comdats, since it would lead to local comdat and I also > ignored the > conversion rule. > I have patch for that that handles it post-inlining + inliner patch that > takes advantage > of function context to allow recursive inlining. > > > > Are you thinking to add this after my patch is in? > > Yes, lets do that incrementally. > > > > >>+ /* Don't clone decls local to a comdat group. */ > > >>+ if (comdat_local_p (node)) > > >>+return false; > > > > > >Why? It seems this should work if the clone becomes another comdat local? > > > > Right, I think the problem was that the clone wasn't becoming comdat > > local. And for the specific case of decloning, there's no point in > > cloning the decloned constructor. > > If it does not make sense, how we ended up cloning it? > Can you show me some code sample of decloning? > > I assume that we basically turn original cloned constructors into wrappers > around common "worker" that is now comdat local. I think ipa-cp may end up > deciding on clonning the wrapper that will break because it will end up static > calling the local comdat function. > On the other hand it may decide to clone both the wrapper and the actual > function > and in that case bringing both static is fine. > > So to be on safe side, we probably want to consider functions calling local > comdat > unclonable but we do not need to worry about local comdats themselves. > For good codegen, I think ipa-cp will need to understand it needs to either > clone > both or nothing. I think it is something Martin can look into? Uh, this will be quite a bit ugly but I will put it on my todo list. Nevertheless, if you believe that a particular function should not be cloned by ipa-cp, the best place to do make that change is in ipcp_versionable_function_p, decide_about_value is too late and a lot of assumptions about versionablity have already been made when it runs. Thanks, Martin
[PATCH 11/16] tree-parloops.c: use gimple_phi in various places
gcc/ * tree-parloops.c (struct reduction_info): Strengthen field "new_phi" from gimple to gimple_phi. (create_phi_for_local_result): Convert local "new_phi" to gimple_phi. (loop_has_vector_phi_nodes): Require a gimple_phi rather than a gimple. (gather_scalar_reductions): Convert to a gimple_phi_iterator and gimple_phi. (try_create_reduction_list): Likewise. --- gcc/tree-parloops.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index a56145d..e4fbab8 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -197,7 +197,7 @@ struct reduction_info tree initial_value; /* The initial value of the reduction var before entering the loop. */ tree field; /* the name of the field in the parloop data structure intended for reduction. */ tree init; /* reduction initialization value. */ - gimple new_phi; /* (helper field) Newly created phi node whose result + gimple_phi new_phi; /* (helper field) Newly created phi node whose result will be passed to the atomic operation. Represents the local result each thread computed for the reduction operation. */ @@ -1036,7 +1036,7 @@ create_phi_for_local_result (reduction_info **slot, struct loop *loop) { struct reduction_info *const reduc = *slot; edge e; - gimple new_phi; + gimple_phi new_phi; basic_block store_bb; tree local_res; source_location locus; @@ -1943,7 +1943,7 @@ loop_has_vector_phi_nodes (struct loop *loop ATTRIBUTE_UNUSED) static void build_new_reduction (reduction_info_table_type reduction_list, -gimple reduc_stmt, gimple phi) +gimple reduc_stmt, gimple_phi phi) { reduction_info **slot; struct reduction_info *new_reduction; @@ -1983,14 +1983,14 @@ set_reduc_phi_uids (reduction_info **slot, void *data ATTRIBUTE_UNUSED) static void gather_scalar_reductions (loop_p loop, reduction_info_table_type reduction_list) { - gimple_stmt_iterator gsi; + gimple_phi_iterator gsi; loop_vec_info simple_loop_info; simple_loop_info = vect_analyze_loop_form (loop); for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); affine_iv iv; tree res = PHI_RESULT (phi); bool double_reduc; @@ -2046,7 +2046,7 @@ try_create_reduction_list (loop_p loop, reduction_info_table_type reduction_list) { edge exit = single_dom_exit (loop); - gimple_stmt_iterator gsi; + gimple_phi_iterator gsi; gcc_assert (exit); @@ -2055,7 +2055,7 @@ try_create_reduction_list (loop_p loop, for (gsi = gsi_start_phis (exit->dest); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); struct reduction_info *red; imm_use_iterator imm_iter; use_operand_p use_p; @@ -2113,7 +2113,7 @@ try_create_reduction_list (loop_p loop, iteration space can be distributed efficiently. */ for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); tree def = PHI_RESULT (phi); affine_iv iv; -- 1.7.11.7
[PATCH 14/16] tree-ssa-loop-niter.c: use gimple_phi in a few places
gcc/ * tree-ssa-loop-niter.c (chain_of_csts_start): Return a gimple_phi rather than a gimple. (get_base_for): Likewise; convert local "phi" to be a gimple_phi. (loop_niter_by_eval): Convert local "phi" to be a gimple_phi. --- gcc/tree-ssa-loop-niter.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 1f94895..ffc651b 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -2147,7 +2147,7 @@ finite_loop_p (struct loop *loop) result by a chain of operations such that all but exactly one of their operands are constants. */ -static gimple +static gimple_phi chain_of_csts_start (struct loop *loop, tree x) { gimple stmt = SSA_NAME_DEF_STMT (x); @@ -2162,7 +2162,7 @@ chain_of_csts_start (struct loop *loop, tree x) if (gimple_code (stmt) == GIMPLE_PHI) { if (bb == loop->header) - return stmt; + return stmt->as_a_gimple_phi (); return NULL; } @@ -2195,10 +2195,10 @@ chain_of_csts_start (struct loop *loop, tree x) If such phi node exists, it is returned, otherwise NULL is returned. */ -static gimple +static gimple_phi get_base_for (struct loop *loop, tree x) { - gimple phi; + gimple_phi phi; tree init, next; if (is_gimple_min_invariant (x)) @@ -2289,7 +2289,8 @@ loop_niter_by_eval (struct loop *loop, edge exit) { tree acnd; tree op[2], val[2], next[2], aval[2]; - gimple phi, cond; + gimple_phi phi; + gimple cond; unsigned i, j; enum tree_code cmp; -- 1.7.11.7
[PATCH 13/16] tree-ssa-phiprop.c: use gimple_phi
gcc/ * tree-ssa-phiprop.c (phiprop_insert_phi): Strengthen types of parameter "phi" and local "new_phi" from gimple to gimple_phi. --- gcc/tree-ssa-phiprop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c index dd84555..8a225a6 100644 --- a/gcc/tree-ssa-phiprop.c +++ b/gcc/tree-ssa-phiprop.c @@ -139,11 +139,11 @@ phivn_valid_p (struct phiprop_d *phivn, tree name, basic_block bb) BB with the virtual operands from USE_STMT. */ static tree -phiprop_insert_phi (basic_block bb, gimple phi, gimple use_stmt, +phiprop_insert_phi (basic_block bb, gimple_phi phi, gimple use_stmt, struct phiprop_d *phivn, size_t n) { tree res; - gimple new_phi; + gimple_phi new_phi; edge_iterator ei; edge e; -- 1.7.11.7
[PATCH 15/16] tree-ssa-loop-manip.c: use gimple_phi in three places
gcc/ * tree-ssa-loop-manip.c (add_exit_phi): Convert local "phi" to be a gimple_phi. (split_loop_exit_edge): Likewise for "phi" and "new_phi". --- gcc/tree-ssa-loop-manip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c index cd5ae3c..893a75c 100644 --- a/gcc/tree-ssa-loop-manip.c +++ b/gcc/tree-ssa-loop-manip.c @@ -276,7 +276,7 @@ compute_live_loop_exits (bitmap live_exits, bitmap use_blocks, static void add_exit_phi (basic_block exit, tree var) { - gimple phi; + gimple_phi phi; edge e; edge_iterator ei; @@ -627,7 +627,7 @@ split_loop_exit_edge (edge exit) { basic_block dest = exit->dest; basic_block bb = split_edge (exit); - gimple phi, new_phi; + gimple_phi phi, new_phi; tree new_name, name; use_operand_p op_p; gimple_phi_iterator psi; -- 1.7.11.7
[PATCH 08/16] Introduce gimple_phi and use it in various places
gcc/ * coretypes.h (gimple_phi): New typedef. (const_gimple_phi): New typedef. * gimple.h (gimple_statement_base::as_a_gimple_phi): New. (gimple_statement_base::dyn_cast_gimple_phi): New. * gdbhooks.py (build_pretty_printer): Add gimple_phi and its variants, using the gimple printer. * gimple.h (gimple_vec): Eliminate thie typedef in the hope of using vecs of more concrete gimple subclasses as appropriate; also the comment is about to become misleading. * gimple.h (gimple_phi_capacity): Use const_gimple_phi typedef rather than spelling out the full type. (gimple_phi_num_args): Likewise. (gimple_phi_result): Likewise. (gimple_phi_result_ptr): Use gimple_phi typedef. (gimple_phi_set_result): Likewise. (gimple_phi_arg): Likewise. (gimple_phi_set_arg): Likewise. * tree-phinodes.c (allocate_phi_node): Likewise. (resize_phi_node): Likewise. (reserve_phi_args_for_new_edge): Likewise. (remove_phi_arg_num): Likewise. * gimple-pretty-print.c (dump_gimple_phi): Require a gimple_phi rather than just a gimple. * tree-into-ssa.c (mark_phi_for_rewrite): Likewise. * tree-phinodes.c (make_phi_node): Return a gimple_phi rather than just a gimple. (create_phi_node): Likewise. * tree-phinodes.h (create_phi_node): Likewise. * trans-mem.c (struct struct tm_log_entry): Replace use of now-removed gimple_vec with a plain vec. * tree-into-ssa.c (phis_to_rewrite): Strengthen from a vec to a vec< vec >. * tree-into-ssa.c (insert_phi_nodes_for): Update local to be a gimple_phi. * tree-into-ssa.c (rewrite_update_phi_arguments): Strengthen local "phis" from a gimple_vec to a vec, and local "phi" to a gimple_phi. * tree-into-ssa.c (delete_update_ssa): Strengthen local "phis" from a gimple_vec to a vec. * gimple-pretty-print.c (pp_gimple_stmt_1): Add checked cast to gimple_phi in regions where a stmt is known to have code GIMPLE_PHI. * tree-into-ssa.c (mark_use_interesting): Likewise. --- gcc/coretypes.h | 4 gcc/gdbhooks.py | 4 +++- gcc/gimple-pretty-print.c | 6 +++--- gcc/gimple.h | 30 +++--- gcc/trans-mem.c | 2 +- gcc/tree-into-ssa.c | 16 gcc/tree-phinodes.c | 26 +- gcc/tree-phinodes.h | 2 +- 8 files changed, 52 insertions(+), 38 deletions(-) diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 57db319..f3945b9 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -94,6 +94,10 @@ struct gimple_statement_bind; typedef struct gimple_statement_bind *gimple_bind; typedef const struct gimple_statement_bind *const_gimple_bind; +struct gimple_statement_phi; +typedef struct gimple_statement_phi *gimple_phi; +typedef const struct gimple_statement_phi *const_gimple_phi; + union section; typedef union section section; struct gcc_options; diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index 9f28c4e..ef41bad 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -468,7 +468,9 @@ def build_pretty_printer(): 'gimple_assign', 'const_gimple_assign', 'gimple_statement_assign *', 'gimple_bind', 'const_gimple_bind', - 'gimple_statement_bind *'], + 'gimple_statement_bind *', + 'gimple_phi', 'const_gimple_phi', + 'gimple_statement_phi *'], 'gimple', GimplePrinter) diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index aa7c148..505006a 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -1791,7 +1791,7 @@ dump_ssaname_info (pretty_printer *buffer, tree node, int spc) pretty printer. If COMMENT is true, print this after #. */ static void -dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, bool comment, +dump_gimple_phi (pretty_printer *buffer, gimple_phi phi, int spc, bool comment, int flags) { size_t i; @@ -2134,7 +2134,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags) break; case GIMPLE_PHI: - dump_gimple_phi (buffer, gs, spc, false, flags); + dump_gimple_phi (buffer, gs->as_a_gimple_phi (), spc, false, flags); break; case GIMPLE_OMP_PARALLEL: @@ -2310,7 +2310,7 @@ dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags) if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS)) { INDENT (indent); - dump_gimple_phi (buffer, phi, indent, true, flags); + dump_gimple_phi (buf
[PATCH 12/16] tree-predcom.c: use gimple_phi in various places
gcc/ * tree-predcom.c (find_looparound_phi): Return a gimple_phi rather than just a gimple. (insert_looparound_copy): Require a gimple_phi rather than just a gimple. (add_looparound_copies): Convert local "phi" to be a gimple_phi. (initialize_root_vars): Likewise. (initialize_root_vars_lm): Likewise. --- gcc/tree-predcom.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c index e367b5c..4226543 100644 --- a/gcc/tree-predcom.c +++ b/gcc/tree-predcom.c @@ -1082,7 +1082,7 @@ valid_initializer_p (struct data_reference *ref, iteration), returns the phi node. Otherwise, NULL_TREE is returned. ROOT is the root of the current chain. */ -static gimple +static gimple_phi find_looparound_phi (struct loop *loop, dref ref, dref root) { tree name, init, init_ref; @@ -1144,7 +1144,7 @@ find_looparound_phi (struct loop *loop, dref ref, dref root) /* Adds a reference for the looparound copy of REF in PHI to CHAIN. */ static void -insert_looparound_copy (chain_p chain, dref ref, gimple phi) +insert_looparound_copy (chain_p chain, dref ref, gimple_phi phi) { dref nw = XCNEW (struct dref_d), aref; unsigned i; @@ -1175,7 +1175,7 @@ add_looparound_copies (struct loop *loop, chain_p chain) { unsigned i; dref ref, root = get_chain_root (chain); - gimple phi; + gimple_phi phi; FOR_EACH_VEC_ELT (chain->refs, i, ref) { @@ -1427,7 +1427,7 @@ initialize_root_vars (struct loop *loop, chain_p chain, bitmap tmp_vars) dref root = get_chain_root (chain); bool reuse_first = !chain->has_max_use_after; tree ref, init, var, next; - gimple phi; + gimple_phi phi; gimple_seq stmts; edge entry = loop_preheader_edge (loop), latch = loop_latch_edge (loop); @@ -1501,7 +1501,7 @@ initialize_root_vars_lm (struct loop *loop, dref root, bool written, unsigned i; tree ref = DR_REF (root->ref), init, var, next; gimple_seq stmts; - gimple phi; + gimple_phi phi; edge entry = loop_preheader_edge (loop), latch = loop_latch_edge (loop); /* Find the initializer for the variable, and check that it cannot -- 1.7.11.7
[testsuite] Fix g++.dg/cilk-plus/cilk-plus.exp
Unfortunately, the g++.dg/cilk-plus testsuite repeated many of the errors that have already been fixed in its gcc.dg counterpart: not properly setting ld_library_path (setting instead of appending, which causes all 64-bit tests to FAIL on Solaris 10/x86) and using ALWAYS_CFLAGS (leads to build directory names in make check output). The following patch fixes both issues. Tested with the appropriate runtest invocation, will commit once a full bootstrap has completed. The only failures remaining now are (32-bit only): FAIL: g++.dg/cilk-plus/CK/catch_exc.cc -fcilkplus execution test FAIL: g++.dg/cilk-plus/CK/catch_exc.cc -O1 -fcilkplus execution test FAIL: g++.dg/cilk-plus/CK/catch_exc.cc -O2 -fcilkplus execution test FAIL: g++.dg/cilk-plus/CK/catch_exc.cc -O3 -fcilkplus execution test FAIL: g++.dg/cilk-plus/CK/catch_exc.cc -g -fcilkplus execution test FAIL: g++.dg/cilk-plus/CK/catch_exc.cc -g -O2 -fcilkplus execution test FAIL: g++.dg/cilk-plus/CK/catch_exc.cc -g -O3 -fcilkplus execution test Rainer 2013-12-13 Rainer Orth * g++.dg/cilk-plus/cilk-plus.exp: Properly set ld_library_path. Use TEST_EXTRA_LIBS instead of ALWAYS_CFLAGS. diff --git a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp --- a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp +++ b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp @@ -25,10 +25,11 @@ if { ![check_effective_target_cilkplus] verbose "$tool $libdir" 1 set library_var "[get_multilibs]" # Pointing the ld_library_path to the Cilk Runtime library binaries. -set ld_library_path "$[get_multilibs]/libcilkrts/.libs" +append ld_library_path ":${library_var}/libcilkrts/.libs" +set_ld_library_path_env_vars -set ALWAYS_CFLAGS "" -lappend ALWAYS_CFLAGS "-L${library_var}/libcilkrts/.libs" +global TEST_EXTRA_LIBS +set TEST_EXTRA_LIBS "-L${library_var}/libcilkrts/.libs" dg-init # Run the tests that are shared with C. @@ -72,22 +73,22 @@ dg-runtest [lsort [glob -nocomplain $src dg-finish dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -fcilkplus $ALWAYS_CFLAGS" " " -dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -O1 -fcilkplus $ALWAYS_CFLAGS" " " -dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -O2 -fcilkplus $ALWAYS_CFLAGS" " " -dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -O3 -fcilkplus $ALWAYS_CFLAGS" " " -dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -g -fcilkplus $ALWAYS_CFLAGS" " " -dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -g -O2 -fcilkplus $ALWAYS_CFLAGS" " " -dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -g -O3 -fcilkplus $ALWAYS_CFLAGS" " " +dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -O1 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -O2 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -O3 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -g -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -g -O2 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/CK/*.cc]] " -g -O3 -fcilkplus" " " dg-finish dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus $ALWAYS_CFLAGS" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O1 -fcilkplus $ALWAYS_CFLAGS" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O2 -fcilkplus $ALWAYS_CFLAGS" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O3 -fcilkplus $ALWAYS_CFLAGS" " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O1 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O2 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O3 -fcilkplus" " " dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -fcilkplus" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -O2 -fcilkplus $ALWAYS_CFLAGS" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -O3 -fcilkplus $ALWAYS_CFLAGS" " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -O2 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -O3 -fcilkplus" " " dg-finish unset TEST_EXTRA_LIBS -- - Rainer Orth, Center for
Re: [PATCH] Strict volatile bit-fields clean-up, Take 2
> Then I think we can put all bits together now: > > 1. Let Sandra apply her Bit-fields patch "reimplement > -fstrict-volatile-bitfields v4, part 1/2" which was > posted here: http://gcc.gnu.org/ml/gcc-patches/2013-09/msg02058.html > and approved here: http://gcc.gnu.org/ml/gcc-patches/2013-10/msg01476.html > > 2. As follow-Up I'd like to apply this update-patch, which fixes the > recursion in the extract_split_bit_field and fixes the C++ memory > model for -fstrict-volatile-bitfields: > > which was posted here: > http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02046.html and approved here: > http://gcc.gnu.org/ml/gcc-patches/2013-12/msg00091.html > > 3. Then this patch itself "Strict volatile bit-fields clean-up, Take 2". > > 4. And finally the Clean-up patch: "Strict volatile bit-fields clean-up" > which removes the dependencies on > the variable flag_strict_volatile_bitfields > from expand_assignment and expand_expr_real_1. And uses the access mode > of the field > instead of the structure mode. > > which was posted here: > http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02479.html and approved here: > http://gcc.gnu.org/ml/gcc-patches/2013-12/msg00086.html Nice work btw, no regressions (at least in C and Ada) on x86, x86-64, PowerPC, IA-64, SPARC and SPARC64, which was not a given thing IMO. -- Eric Botcazou
RE: [PING]: [GOMP4] [PATCH] SIMD-Enabled Functions (formerly Elemental functions) for C
> -Original Message- > From: Aldy Hernandez [mailto:al...@redhat.com] > Sent: Thursday, December 12, 2013 3:29 PM > To: Iyer, Balaji V > Cc: Jakub Jelinek; 'gcc-patches@gcc.gnu.org' > Subject: Re: [PING]: [GOMP4] [PATCH] SIMD-Enabled Functions (formerly > Elemental functions) for C > > On 12/12/13 07:56, Iyer, Balaji V wrote: > > > Will it be Ok if I don’t mark them as cilk simd function but just keep > > it as omp declare simd from the start? That should get around this > > issue. > > No, because then we won't be able to distinguish between OMP and Cilk > Plus clones. This is something we do here: > >/* To distinguish from an OpenMP simd clone, Cilk Plus functions to > be cloned have a distinctive artificial label in addition to "omp > declare simd". */ >bool cilk_clone > = (flag_enable_cilkplus > && lookup_attribute ("cilk plus elemental", > DECL_ATTRIBUTES (node->decl))); > >/* Allocate one more than needed just in case this is an in-branch > clone which will require a mask argument. */ >struct cgraph_simd_clone *clone_info = simd_clone_struct_alloc (n + 1); >clone_info->nargs = n; >clone_info->cilk_elemental = cilk_clone; > Ok. I found the bug and fixed it. It was looking for cilk plus elemental and now that we renamed it to cilk simd function it was cloning a whole bunch of them. It is fixed and now giving the correct behavior. It passes all the tests in my x86_64 machine. Is it OK to install in GOMP4/Trunk? Here are the Changelog entries: Gcc/ChangeLog 2013-12-13 Balaji V. Iyer * omp-low.c (simd_clone_clauses_extract): Replaced the string "cilk simd elemental" with "cilk simd function." Gcc/c/ChangeLog 2013-12-13 Balaji V. Iyer * c-parser.c (struct c_parser::cilk_simd_fn_tokens): Added new field. (c_parser_declaration_or_fndef): Added a check if cilk_simd_fn_tokens field in parser is not empty. If not-empty, call the function c_parser_finish_omp_declare_simd. (c_parser_cilk_clause_vectorlength): Modified function to be shared between SIMD-enabled functions and #pragma simd. Changed return-type to bool and added new parameter. (c_parser_cilk_all_clauses): Modified the usage of the function c_parser_cilk_clause_vectorlength as mentioned above. (c_parser_cilk_simd_fn_vector_attrs): New function. (c_finish_cilk_simd_fn_tokens): Likewise. (c_parser_attributes): Added a cilk_simd_fn_tokens parameter. Added a check for vector attribute and if so call the function c_parser_cilk_simd_fn_vector_attrs. Also, when Cilk plus is enabled, called the function c_finish_cilk_simd_fn_tokens. (c_finish_omp_declare_simd): Added a check if cilk_simd_fn_tokens in parser field is non-empty. If so, parse them as you would parse the omp declare simd pragma. Gcc/testsuite/ChangeLog 2013-12-13 Balaji V. Iyer * c-c++-common/cilk-plus/SE/ef_test.c: New test. * c-c++-common/cilk-plus/SE/ef_test2.c: Likewise. * c-c++-common/cilk-plus/SE/vlength_errors.c: Likewise. * c-c++-common/cilk-plus/SE/ef_error.c: Likewise. * c-c++-common/cilk-plus/SE/ef_error2.c: Likewise. * gcc.dg/cilk-plus/cilk-plus.exp: Added calls for the above tests. The C++ patch with this fix is coming up ... Thanks, Balaji V. Iyer. Index: gcc/c-family/c-common.c === --- gcc/c-family/c-common.c (revision 205759) +++ gcc/c-family/c-common.c (working copy) @@ -771,6 +771,8 @@ handle_returns_nonnull_attribute, false }, { "omp declare simd", 0, -1, true, false, false, handle_omp_declare_simd_attribute, false }, + { "cilk simd function", 0, -1, true, false, false, + handle_omp_declare_simd_attribute, false }, { "omp declare target", 0, 0, true, false, false, handle_omp_declare_target_attribute, false }, { "bnd_variable_size", 0, 0, true, false, false, Index: gcc/c/c-parser.c === --- gcc/c/c-parser.c(revision 205759) +++ gcc/c/c-parser.c(working copy) @@ -208,6 +208,12 @@ /* True if we are in a context where the Objective-C "Property attribute" keywords are valid. */ BOOL_BITFIELD objc_property_attr_context : 1; + + /* Cilk Plus specific parser/lexer information. */ + + /* Buffer to hold all the tokens from parsing the vector attribute for the + SIMD-enabled functions (formerly known as elemental functions). */ + vec *cilk_simd_fn_tokens; } c_parser; @@ -1246,6 +1252,7 @@ static void c_parser_cilk_simd (c_parser *); static bool c_parser_cilk_verify_simd (c_parser *, enum pragma_context); static tree c_parser_array_notation
Re: [trunk]: Patch to move BITS_PER_UNIT to be available for genmodes.c
committed as revision 205964 with updated comment. kenny 2013-12-13 Kenneth Zadeck * config/arc/arc.h (BITS_PER_UNIT): Removed. * config/bfin/bfin.h (BITS_PER_UNIT): Removed. * config/lm32/lm32.h (BITS_PER_UNIT): Removed. * config/m32c/m32c.h (BITS_PER_UNIT): Removed. * config/microblaze/microblaze.h (BITS_PER_UNIT): Removed. * config/picochip/picochip.h (BITS_PER_UNIT): Removed. * config/spu/spu.h (BITS_PER_UNIT): Removed. * defaults.h (BITS_PER_UNIT): Removed. * config/i386/i386-modes.def (MAX_BITSIZE_MODE_ANY_INT): New. * doc/rtl (BITS_PER_UNIT): Moved from tm.texi. (MAX_BITSIZE_MODE_ANY_INT): Updated. * doc/tm.texi (BITS_PER_UNIT): Removed. * doc/tm.texi.in (BITS_PER_UNIT): Removed. * genmodes.c (bits_per_unit, max_bitsize_mode_any_int): New. (create_modes): Added code to set bits_per_unit and max_bitsize_mode_any_int. (emit_max_int): Changed code generation. * mkconfig.sh: Added insn-modes.h. On 12/13/2013 06:11 AM, Richard Biener wrote: On Fri, 13 Dec 2013, Uros Bizjak wrote: Hello! In addition, this target also changes the way that MAX_BITSIZE_MODE_ANY_INT is calculated. The value is heavily used on the wide-int branch to allocate buffers that are used to hold large integer values. The change in the way it is computed was motivated by the i386 port, but there may be other ports that have the same problem. The i386 port defines two very large integer modes that are only used as containers for large vectors. They are never used for large integers. The new way of computing this allows a port to say (very early) that some of these integer modes are never used to hold numbers and so smaller buffers can be used for integer calculations. Other ports that play the same game should follow suit. Index: gcc/config/i386/i386-modes.def === --- gcc/config/i386/i386-modes.def (revision 205895) +++ gcc/config/i386/i386-modes.def (working copy) @@ -90,5 +90,10 @@ VECTOR_MODE (INT, QI, 2); /* INT_MODE (OI, 32); INT_MODE (XI, 64); +/* Keep the OI and XI modes from confusing the compiler into thinking + that these modes could actually be used for computation. They are + only holders for vectors during data movement. */ +#define MAX_BITSIZE_MODE_ANY_INT (128) + /* The symbol Pmode stands for one of the above machine modes (usually SImode). The tm.h file specifies which one. It is not a distinct mode. */ __int128 is avaialble only for x86_64 - 64bit targets, so: #define MAX_BITSIZE_MODE_ANY_INT (TARGET_64BIT ? 128 : 64) It needs to be a compile-time constant. Richard. Index: gcc/ChangeLog === --- gcc/ChangeLog (revision 205962) +++ gcc/ChangeLog (working copy) @@ -1,3 +1,24 @@ +2013-12-13 Kenneth Zadeck + + * config/arc/arc.h (BITS_PER_UNIT): Removed. + * config/bfin/bfin.h (BITS_PER_UNIT): Removed. + * config/lm32/lm32.h (BITS_PER_UNIT): Removed. + * config/m32c/m32c.h (BITS_PER_UNIT): Removed. + * config/microblaze/microblaze.h (BITS_PER_UNIT): Removed. + * config/picochip/picochip.h (BITS_PER_UNIT): Removed. + * config/spu/spu.h (BITS_PER_UNIT): Removed. + * defaults.h (BITS_PER_UNIT): Removed. + * config/i386/i386-modes.def (MAX_BITSIZE_MODE_ANY_INT): New. + * doc/rtl (BITS_PER_UNIT): Moved from tm.texi. + (MAX_BITSIZE_MODE_ANY_INT): Updated. + * doc/tm.texi (BITS_PER_UNIT): Removed. + * doc/tm.texi.in (BITS_PER_UNIT): Removed. + * genmodes.c (bits_per_unit, max_bitsize_mode_any_int): New. + (create_modes): Added code to set bits_per_unit and + max_bitsize_mode_any_int. + (emit_max_int): Changed code generation. + * mkconfig.sh: Added insn-modes.h. + 2013-12-13 Yuri Rumyantsev * config/i386/i386.c (slm_cost): Fix imul cost for HI. Index: gcc/config/arc/arc.h === --- gcc/config/arc/arc.h (revision 205962) +++ gcc/config/arc/arc.h (working copy) @@ -303,9 +303,6 @@ along with GCC; see the file COPYING3. numbered. */ #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN) -/* Number of bits in an addressable storage unit. */ -#define BITS_PER_UNIT 8 - /* Width in bits of a "word", which is the contents of a machine register. Note that this is not necessarily the width of data type `int'; if using 16-bit ints on a 68000, this would still be 32. Index: gcc/config/bfin/bfin.h === --- gcc/config/bfin/bfin.h (revision 205962) +++ gcc/config/bfin/bfin.h (working copy) @@ -859,9 +859,6 @@ typedef struct { /* Define this if most significant word of a multiword number is numbered. */ #define WORDS_BIG_ENDIAN 0 -/* number of bits in an addressable storage unit */ -#define BITS_PER_UNIT 8 - /* Width in bits of a "word", which is the contents of a machine register. Note that this is not necessarily the width of data type `int';
Re: [PATCH 14/16] tree-ssa-loop-niter.c: use gimple_phi in a few places
On 12/13/2013 10:58 AM, David Malcolm wrote: { gimple stmt = SSA_NAME_DEF_STMT (x); @@ -2162,7 +2162,7 @@ chain_of_csts_start (struct loop *loop, tree x) if (gimple_code (stmt) == GIMPLE_PHI) { if (bb == loop->header) - return stmt; + return stmt->as_a_gimple_phi (); return NULL; } @@ -2195,10 +2195,10 @@ chain_of_csts_start (struct loop *loop, tree x) If such phi node exists, it is returned, otherwise NULL is returned. */ I dislike separating the checking of gimple_code () and the following as_a. I rather envisioned this sort of thing as being more of an abstraction improvement if we never have to check gimple_code()... Then you are also less locked into a specific implementation. So something more like: if (gimple_phi phi = stmt->dyncast_gimple_phi ()) { if (bb == loop->header) return phi; } IMO anyway... Andrew
Re: [PING]: [GOMP4] [PATCH] SIMD-Enabled Functions (formerly Elemental functions) for C
+ /* Two CPP_EOF token is added as a safety-net since the normal C + front-end has two token look-ahead. */ "Two CPP_EOF tokens are added"... Also, "safety net" are two words, not one hyphenated one. Otherwise, I'm fine with the present patch. It's up to Jakub or another global reviewer to give the final approval. Aldy
Re: [testsuite] Fix g++.dg/cilk-plus/cilk-plus.exp
Rainer Orth writes: > diff --git a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp > b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp > --- a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp > +++ b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp > @@ -25,10 +25,11 @@ if { ![check_effective_target_cilkplus] > verbose "$tool $libdir" 1 > set library_var "[get_multilibs]" > # Pointing the ld_library_path to the Cilk Runtime library binaries. > -set ld_library_path "$[get_multilibs]/libcilkrts/.libs" > +append ld_library_path ":${library_var}/libcilkrts/.libs" > +set_ld_library_path_env_vars > > -set ALWAYS_CFLAGS "" > -lappend ALWAYS_CFLAGS "-L${library_var}/libcilkrts/.libs" > +global TEST_EXTRA_LIBS > +set TEST_EXTRA_LIBS "-L${library_var}/libcilkrts/.libs" There is no point in doing this twice. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: [testsuite] Fix g++.dg/cilk-plus/cilk-plus.exp
Andreas Schwab writes: > Rainer Orth writes: > >> diff --git a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp >> b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp >> --- a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp >> +++ b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp >> @@ -25,10 +25,11 @@ if { ![check_effective_target_cilkplus] >> verbose "$tool $libdir" 1 >> set library_var "[get_multilibs]" >> # Pointing the ld_library_path to the Cilk Runtime library binaries. >> -set ld_library_path "$[get_multilibs]/libcilkrts/.libs" >> +append ld_library_path ":${library_var}/libcilkrts/.libs" >> +set_ld_library_path_env_vars >> >> -set ALWAYS_CFLAGS "" >> -lappend ALWAYS_CFLAGS "-L${library_var}/libcilkrts/.libs" >> +global TEST_EXTRA_LIBS >> +set TEST_EXTRA_LIBS "-L${library_var}/libcilkrts/.libs" > > There is no point in doing this twice. What are you talking about? ld_library_path and its corresponding environment variables are used by the runtime linker (ld.so.1 or whatever), while the -L flags are for ld. Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
RE: [PING]: [GOMP4] [PATCH] SIMD-Enabled Functions (formerly Elemental functions) for C
> -Original Message- > From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches- > ow...@gcc.gnu.org] On Behalf Of Aldy Hernandez > Sent: Friday, December 13, 2013 12:40 PM > To: Iyer, Balaji V > Cc: Jakub Jelinek; 'gcc-patches@gcc.gnu.org' > Subject: Re: [PING]: [GOMP4] [PATCH] SIMD-Enabled Functions (formerly > Elemental functions) for C > > > + /* Two CPP_EOF token is added as a safety-net since the normal C > > + front-end has two token look-ahead. */ > > "Two CPP_EOF tokens are added"... Also, "safety net" are two words, not > one hyphenated one. > > Otherwise, I'm fine with the present patch. It's up to Jakub or another > global > reviewer to give the final approval. Here is the fixed patch with the above changes. So, is it OK for trunk/branch? Thanks, Balaji V. Iyer. > > Aldy Index: gcc/c-family/c-common.c === --- gcc/c-family/c-common.c (revision 205759) +++ gcc/c-family/c-common.c (working copy) @@ -771,6 +771,8 @@ handle_returns_nonnull_attribute, false }, { "omp declare simd", 0, -1, true, false, false, handle_omp_declare_simd_attribute, false }, + { "cilk simd function", 0, -1, true, false, false, + handle_omp_declare_simd_attribute, false }, { "omp declare target", 0, 0, true, false, false, handle_omp_declare_target_attribute, false }, { "bnd_variable_size", 0, 0, true, false, false, Index: gcc/c/c-parser.c === --- gcc/c/c-parser.c(revision 205759) +++ gcc/c/c-parser.c(working copy) @@ -208,6 +208,12 @@ /* True if we are in a context where the Objective-C "Property attribute" keywords are valid. */ BOOL_BITFIELD objc_property_attr_context : 1; + + /* Cilk Plus specific parser/lexer information. */ + + /* Buffer to hold all the tokens from parsing the vector attribute for the + SIMD-enabled functions (formerly known as elemental functions). */ + vec *cilk_simd_fn_tokens; } c_parser; @@ -1246,6 +1252,7 @@ static void c_parser_cilk_simd (c_parser *); static bool c_parser_cilk_verify_simd (c_parser *, enum pragma_context); static tree c_parser_array_notation (location_t, c_parser *, tree, tree); +static bool c_parser_cilk_clause_vectorlength (c_parser *, tree *, bool); /* Parse a translation unit (C90 6.7, C99 6.9). @@ -1647,7 +1654,8 @@ C_DTR_NORMAL, &dummy); if (declarator == NULL) { - if (omp_declare_simd_clauses.exists ()) + if (omp_declare_simd_clauses.exists () + || !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) c_finish_omp_declare_simd (parser, NULL_TREE, NULL_TREE, omp_declare_simd_clauses); c_parser_skip_to_end_of_block_or_statement (parser); @@ -1734,7 +1742,8 @@ chainon (postfix_attrs, all_prefix_attrs)); if (!d) d = error_mark_node; - if (omp_declare_simd_clauses.exists ()) + if (omp_declare_simd_clauses.exists () + || !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) c_finish_omp_declare_simd (parser, d, NULL_TREE, omp_declare_simd_clauses); } @@ -1746,7 +1755,8 @@ chainon (postfix_attrs, all_prefix_attrs)); if (!d) d = error_mark_node; - if (omp_declare_simd_clauses.exists ()) + if (omp_declare_simd_clauses.exists () + || !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) c_finish_omp_declare_simd (parser, d, NULL_TREE, omp_declare_simd_clauses); start_init (d, asm_name, global_bindings_p ()); @@ -1774,7 +1784,8 @@ tree d = start_decl (declarator, specs, false, chainon (postfix_attrs, all_prefix_attrs)); - if (omp_declare_simd_clauses.exists ()) + if (omp_declare_simd_clauses.exists () + || !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) { tree parms = NULL_TREE; if (d && TREE_CODE (d) == FUNCTION_DECL) @@ -1902,7 +1913,8 @@ c_parser_declaration_or_fndef (parser, false, false, false, true, false, NULL, vNULL); store_parm_decls (); - if (omp_declare_simd_clauses.exists ()) + if (omp_declare_simd_clauses.exists () + || !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) c_finish_omp_declare_simd (parser, current_function_d
Re: [testsuite] Fix g++.dg/cilk-plus/cilk-plus.exp
> Unfortunately, the g++.dg/cilk-plus testsuite repeated many of the > errors that have already been fixed in its gcc.dg counterpart: not > properly setting ld_library_path (setting instead of appending, which > causes all 64-bit tests to FAIL on Solaris 10/x86) and using > ALWAYS_CFLAGS (leads to build directory names in make check output). Same on Solaris 10/SPARC. > 2013-12-13 Rainer Orth > > * g++.dg/cilk-plus/cilk-plus.exp: Properly set ld_library_path. > Use TEST_EXTRA_LIBS instead of ALWAYS_CFLAGS. Works on Solaris 10/SPARC as well, thanks. -- Eric Botcazou
[trunk] added missing parenthesis to #defines generated by gen-modes.c
committed as revision 205970 as obvious. kenny Index: gcc/genmodes.c === --- gcc/genmodes.c (revision 205967) +++ gcc/genmodes.c (working copy) @@ -891,7 +891,7 @@ emit_max_int (void) max = i->bytesize; if (max > mmax) mmax = max; - printf ("#define MAX_BITSIZE_MODE_ANY_INT %d*BITS_PER_UNIT\n", mmax); + printf ("#define MAX_BITSIZE_MODE_ANY_INT (%d*BITS_PER_UNIT)\n", mmax); } else printf ("#define MAX_BITSIZE_MODE_ANY_INT %d\n", max_bitsize_mode_any_int); @@ -901,7 +901,7 @@ emit_max_int (void) for (i = modes[j]; i; i = i->next) if (mmax < i->bytesize) mmax = i->bytesize; - printf ("#define MAX_BITSIZE_MODE_ANY_MODE %d*BITS_PER_UNIT\n", mmax); + printf ("#define MAX_BITSIZE_MODE_ANY_MODE (%d*BITS_PER_UNIT)\n", mmax); } static void
[wide-int] Resolve merge conflicts.
Here are some soft merge conflict resolutions…. I've checked them in to fix the build. Ok? Index: ChangeLog.wide-int === --- ChangeLog.wide-int (revision 205969) +++ ChangeLog.wide-int (working copy) @@ -524,6 +524,7 @@ (aff_combination_constant_multiple_p): Likewise. (get_inner_reference_aff): Likewise. (aff_comb_cannot_overlap_p): Likewise. + (aff_combination_zero_p): Use wide-int interfaces. * tree.c: Include tree.h. (init_ttree): Use make_int_cst. (tree_code_size): Removed code for INTEGER_CST case. @@ -768,6 +769,8 @@ (scev_probably_wraps_p): Likewise. * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Update calls to real_to_integer. + * tree-scalar-evolution.c: + (simplify_peeled_chrec): Use wide-int interfaces. * tree-ssanames.c (set_range_info): Use wide_int_refs rather than double_ints. Adjust for trailing_wide_ints <3> representation. @@ -866,6 +869,7 @@ (output_constructor_bitfield): Likewise. * var-tracking.c (loc_cmp): Handle CONST_WIDE_INT. + * mkconfig.sh: Define BITS_PER_UNIT for GENERATOR_FILEs. * wide-int.cc: New. * wide-int.h: New. * wide-int-print.cc: New. Index: mkconfig.sh === --- mkconfig.sh (revision 205969) +++ mkconfig.sh (working copy) @@ -100,6 +100,9 @@ case $output in #if defined IN_GCC && !defined GENERATOR_FILE # include "insn-modes.h" #endif +#if defined IN_GCC && defined GENERATOR_FILE +# define BITS_PER_UNIT 8 +#endif EOF ;; esac Index: tree-affine.h === --- tree-affine.h (revision 205969) +++ tree-affine.h (working copy) @@ -91,7 +91,7 @@ aff_combination_zero_p (aff_tree *aff) if (!aff) return true; - if (aff->n == 0 && aff->offset.is_zero ()) + if (aff->n == 0 && aff->offset == 0) return true; return false; Index: tree-scalar-evolution.c === --- tree-scalar-evolution.c (revision 205969) +++ tree-scalar-evolution.c (working copy) @@ -1426,7 +1426,7 @@ simplify_peeled_chrec (struct loop *loop tree_to_aff_combination_expand (left, type, &aff1, &peeled_chrec_map); tree_to_aff_combination_expand (step_val, type, &aff2, &peeled_chrec_map); free_affine_expand_cache (&peeled_chrec_map); - aff_combination_scale (&aff2, double_int_minus_one); + aff_combination_scale (&aff2, -1); aff_combination_add (&aff1, &aff2); /* Transform (init, {left, right}_LOOP)_LOOP to {init, right}_LOOP Index: tree-ssa-loop-niter.c === --- tree-ssa-loop-niter.c (revision 205969) +++ tree-ssa-loop-niter.c (working copy) @@ -175,7 +175,7 @@ determine_value_range (struct loop *loop the VAR range, give up on looking at the PHI results. This can happen if VR_UNDEFINED is involved. */ - if (wi::gt_p (minv, maxv)) + if (wi::gt_p (minv, maxv, sgn)) { rtype = get_range_info (var, &minv, &maxv); break;
[patch] remove gate for ipa_inline pass
I'm fixing something completely unrelated, and noticed this... Perhaps I'm missing something, but why do we need a gate when it always returns true? Now that we have this `pass_data' business, we can set has_gate to false. I also fixed a minor typo in a comment. Tested on x86-64 Linux. OK? commit a89f826a3c832da2d572bee9608d407b338efe9f Author: Aldy Hernandez Date: Thu Dec 12 15:14:28 2013 -0800 * ipa-inline.c (gate_ipa_inline): Remove. (const pass_data pass_data_ipa_inline): Unset has_gate. (class pass_ipa_inline): Remove gate() method. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 715b3a2..dd5d86e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-12-12 Aldy Hernandez + + * ipa-inline.c (gate_ipa_inline): Remove. + (const pass_data pass_data_ipa_inline): Unset has_gate. + (class pass_ipa_inline): Remove gate() method. + 2013-12-09 Richard Biener PR middle-end/38474 diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 38157ca..9fd5d41 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -2339,19 +2339,6 @@ make_pass_early_inline (gcc::context *ctxt) return new pass_early_inline (ctxt); } - -/* When to run IPA inlining. Inlining of always-inline functions - happens during early inlining. - - Enable inlining unconditoinally, because callgraph redirection - happens here. */ - -static bool -gate_ipa_inline (void) -{ - return true; -} - namespace { const pass_data pass_data_ipa_inline = @@ -2359,7 +2346,7 @@ const pass_data pass_data_ipa_inline = IPA_PASS, /* type */ "inline", /* name */ OPTGROUP_INLINE, /* optinfo_flags */ - true, /* has_gate */ + false, /* has_gate */ true, /* has_execute */ TV_IPA_INLINING, /* tv_id */ 0, /* properties_required */ @@ -2386,7 +2373,6 @@ public: {} /* opt_pass methods: */ - bool gate () { return gate_ipa_inline (); } unsigned int execute () { return ipa_inline (); } }; // class pass_ipa_inline diff --git a/gcc/tree-inline.h b/gcc/tree-inline.h index d871fc4..741d6eb 100644 --- a/gcc/tree-inline.h +++ b/gcc/tree-inline.h @@ -162,8 +162,8 @@ typedef struct eni_weights_d /* Cost of return. */ unsigned return_cost; - /* True when time of statemnt should be estimated. Thus i.e - cost of switch statement is logarithmic rather than linear in number + /* True when time of statement should be estimated. Thus, the + cost of a switch statement is logarithmic rather than linear in number of cases. */ bool time_based; } eni_weights;
patch to fix arm testsuite regression
The following patch should fix arm test regressions after committing sp elimination patch. The patch was bootstrapped and tested on x86/x86-64. Committed as rev. 205974. 2013-12-12 Vladimir Makarov * ira.h (struct ira_reg_equiv): Rename to ira_reg_equiv_s. * ira.c: Ditto. * lra-int.h (lra_init_equiv): New prototype. * lra-constraints.c (lra_init_equiv, update_equiv): New functions. (loc_equivalence_callback): Use the 3rd arg. (lra_constraints): Update equivalences. Pass curr_insn to simplify_replace_fn_rtx. * lra.c (lra): Call lra_init_equiv. Index: ira.c === --- ira.c (revision 205954) +++ ira.c (working copy) @@ -2976,7 +2976,7 @@ int ira_reg_equiv_len; /* Info about equiv. info for each register. */ -struct ira_reg_equiv *ira_reg_equiv; +struct ira_reg_equiv_s *ira_reg_equiv; /* Expand ira_reg_equiv if necessary. */ void @@ -2988,12 +2988,12 @@ return; ira_reg_equiv_len = max_reg_num () * 3 / 2 + 1; ira_reg_equiv -= (struct ira_reg_equiv *) xrealloc (ira_reg_equiv, += (struct ira_reg_equiv_s *) xrealloc (ira_reg_equiv, ira_reg_equiv_len -* sizeof (struct ira_reg_equiv)); +* sizeof (struct ira_reg_equiv_s)); gcc_assert (old < ira_reg_equiv_len); memset (ira_reg_equiv + old, 0, - sizeof (struct ira_reg_equiv) * (ira_reg_equiv_len - old)); + sizeof (struct ira_reg_equiv_s) * (ira_reg_equiv_len - old)); } static void Index: ira.h === --- ira.h (revision 205954) +++ ira.h (working copy) @@ -154,7 +154,7 @@ (this_target_ira->x_ira_no_alloc_regs) /* Major structure describing equivalence info for a pseudo. */ -struct ira_reg_equiv +struct ira_reg_equiv_s { /* True if we can use this equivalence. */ bool defined_p; @@ -173,7 +173,7 @@ extern int ira_reg_equiv_len; /* Info about equiv. info for each register. */ -extern struct ira_reg_equiv *ira_reg_equiv; +extern struct ira_reg_equiv_s *ira_reg_equiv; extern void ira_init_once (void); extern void ira_init (void); Index: lra-constraints.c === --- lra-constraints.c (revision 205954) +++ lra-constraints.c (working copy) @@ -317,6 +317,44 @@ return get_reg_class (regno) == NO_REGS; } +/* Initiate equivalences for LRA. As we keep original equivalences + before any elimination, we need to make copies otherwise any change + in insns might change the equivalences. */ +void +lra_init_equiv (void) +{ + ira_expand_reg_equiv (); + for (int i = FIRST_PSEUDO_REGISTER; i < max_reg_num (); i++) +{ + rtx res; + + if ((res = ira_reg_equiv[i].memory) != NULL_RTX) + ira_reg_equiv[i].memory = copy_rtx (res); + if ((res = ira_reg_equiv[i].invariant) != NULL_RTX) + ira_reg_equiv[i].invariant = copy_rtx (res); +} +} + +static rtx loc_equivalence_callback (rtx, const_rtx, void *); + +/* Update equivalence for REGNO. We need to this as the equivalence + might contain other pseudos which are changed by their + equivalences. */ +static void +update_equiv (int regno) +{ + rtx x; + + if ((x = ira_reg_equiv[regno].memory) != NULL_RTX) +ira_reg_equiv[regno].memory + = simplify_replace_fn_rtx (x, NULL_RTX, loc_equivalence_callback, +NULL_RTX); + if ((x = ira_reg_equiv[regno].invariant) != NULL_RTX) +ira_reg_equiv[regno].invariant + = simplify_replace_fn_rtx (x, NULL_RTX, loc_equivalence_callback, +NULL_RTX); +} + /* If we have decided to substitute X with another value, return that value, otherwise return X. */ static rtx @@ -3694,14 +3732,16 @@ } /* Similar to loc_equivalence_change_p, but for use as - simplify_replace_fn_rtx callback. */ + simplify_replace_fn_rtx callback. DATA is insn for which the + elimination is done. If it null we don't do the elimination. */ static rtx -loc_equivalence_callback (rtx loc, const_rtx, void *) +loc_equivalence_callback (rtx loc, const_rtx, void *data) { if (!REG_P (loc)) return NULL_RTX; - rtx subst = get_equiv_with_elimination (loc, curr_insn); + rtx subst = (data == NULL + ? get_equiv (loc) : get_equiv_with_elimination (loc, (rtx) data)); if (subst != loc) return subst; @@ -3946,6 +3986,8 @@ bitmap_ior_into (&equiv_insn_bitmap, &lra_reg_info[i].insn_bitmap); } } + for (i = FIRST_PSEUDO_REGISTER; i < new_regno_start; i++) +update_equiv (i); /* We should add all insns containing pseudos which should be substituted by their equivalences. */ EXECUTE_IF_SET_IN_BITMAP (&equiv_insn_bitmap, 0, uid, bi) @@ -3984,7 +4026,7 @@
Re: C++ edge_iterator (was: Re: [SH] PR 53976 - Add RTL pass to eliminate clrt, sett insns)
On Thu, 2013-12-12 at 03:13 -0500, Trevor Saunders wrote: > On Wed, Dec 11, 2013 at 06:47:37PM +0100, Oleg Endo wrote: > > On Thu, 2013-11-21 at 00:04 +0100, Steven Bosscher wrote: > > > Declaring the edge_iterator inside the for() is not a good argument > > > against FOR_EACH_EDGE. Of course, brownie points are up for grabs for > > > the brave soul daring enough to make edge iterators be proper C++ > > > iterators... ;-) > > so, as a first question why do we have a special edge iterator at all? it > seems like we could just have a vec iterator and use that removing a > bunch of indirection that seems pretty useless. I don't know why it's there. Looks like a remainder from the pre-C++ code, as the conversion is being done step by step. > > > So, I gave it a try -- see the attached patch. > > It allows edge iteration to look more like STL container iteration: > > > > for (basic_block::edge_iterator ei = bb->pred_edges ().begin (); > > ei != bb->pred_edges ().end (); ++ei) > > { > > basic_block pred_bb = (*ei)->src; > > ... > > } > > personally I'm not really a fan of overloading ++ / * that way, but I > can't speak for anyone else. I'd prefer something like > > for (vec_iterator i = vec.forward_iterator (); !i.done (); i.next ()) > and > for (backward_vec_iterator i = vec.backward_iterator (); !i.done (); i.next > ()) > > but that might break range base for loops? Right, that doesn't work with range-based for loops, since it doesn't follow the standard concept of iteration. For a more detailed explanation, see also for example http://www.codesynthesis.com/~boris/blog/2012/05/16/cxx11-range-based-for-loop/ BTW, if you look at the patch, I haven't overloaded any ++ operators: Index: gcc/vec.h === --- gcc/vec.h (revision 205866) +++ gcc/vec.h (working copy) @@ -482,6 +482,15 @@ void quick_grow (unsigned len); void quick_grow_cleared (unsigned len); + /* STL like iterator interface. */ + typedef T* iterator; + typedef const T* const_iterator; + + iterator begin (void) { return &m_vecdata[0]; } + iterator end (void) { return &m_vecdata[m_vecpfx.m_num]; } + const_iterator begin (void) const { return &m_vecdata[0]; } + const_iterator end (void) const { &m_vecdata[m_vecpfx.m_num]; } This is because raw pointers can be used as random access iterators. > > Then the > > typedef struct basic_block_def* basic_block; > > > > is replaced with a wrapper class 'basic_block', which is just a simple > > POD wrapper around a basic_block_def*. There should be no penalties > > compared to passing/storing raw pointers. Because of the union with > > constructor restriction of C++98 an additional wrapper class > > 'basic_block_in_union' is required, which doesn't have any constructors > > defined. > > > > Having 'basic_block' as a class allows putting typedefs for the edge > > iterator types in there (initially I tried putting the typedefs into > > struct basic_block_def, but gengtype would bail out). > > namespacing like that seems a little messy, but so is vec_iterator or > such I guess. I'm not sure which part of the namespacing you're referring to exactly. The basic_block::edge_iterator thing? Usually the iterator type is defined in the container type. In this case it would be vec. The choice of the container type for storing edges is done in basic_block_def. Thus, ideally the iterator type should be obtained from the basic_block_def class somehow. A more bureaucratic way would be to have a typedef inside basic_block_def (which is not possible because of gengtype as mentioned before, so let's assume it's in basic_block)... class basic_block { public: typedef vec edge_container; edge_container& pred_edges (void); edge_container& succ_edges (void); ... }; and then access the iterator via for (basic_block::edge_container::iterator i = bb->bb->pred_edges ().begin (); ...) Having to type out iterator types is a well known annoyance of C++98. Of course it's shorter to write for (edge_iterator i = ...) but that means, that there can be only one type of edge container ever. > > It would also be possible to have a free standing definition / typedef > > of edge_iterator, but it would conflict with the existing one and > > require too many changes at once. Moreover, the iterator type actually > > I bet it'll be a lot of work but changing everything seems nice so maybe > its worth just sitting down for a couple days and banging it out if it > gives nicer names? Nicer names than "edge_iterator" you mean? I can't think of any at the moment... > > > depends on the container type, which is vec, and the > > container type is defined/selected by the basic_block class. > > I don't see how this is relevent I hope that the explanation above makes it somewhat clearer. > > > The following > > basic_block pred_bb = (*ei)->src; > > > > can also be written as > > basic_block pred_bb = ei->src; > > > >
Re: patch to fix arm testsuite regression
On Fri, Dec 13, 2013 at 03:48:25PM -0500, Vladimir Makarov wrote: > 2013-12-12 Vladimir Makarov > > * ira.h (struct ira_reg_equiv): Rename to ira_reg_equiv_s. > * ira.c: Ditto. > * lra-int.h (lra_init_equiv): New prototype. > * lra-constraints.c (lra_init_equiv, update_equiv): New functions. > (loc_equivalence_callback): Use the 3rd arg. > (lra_constraints): Update equivalences. Pass curr_insn to > simplify_replace_fn_rtx. > * lra.c (lra): Call lra_init_equiv. > @@ -2988,12 +2988,12 @@ > return; >ira_reg_equiv_len = max_reg_num () * 3 / 2 + 1; >ira_reg_equiv > -= (struct ira_reg_equiv *) xrealloc (ira_reg_equiv, > += (struct ira_reg_equiv_s *) xrealloc (ira_reg_equiv, >ira_reg_equiv_len > - * sizeof (struct ira_reg_equiv)); > + * sizeof (struct ira_reg_equiv_s)); ira_reg_equiv = XRESIZEVEC (struct ira_reg_equiv_s, ira_reg_equiv, ira_reg_equiv_len); instead? Jakub
Re: patch to fix arm testsuite regression
On 12/13/2013, 4:02 PM, Jakub Jelinek wrote: On Fri, Dec 13, 2013 at 03:48:25PM -0500, Vladimir Makarov wrote: 2013-12-12 Vladimir Makarov * ira.h (struct ira_reg_equiv): Rename to ira_reg_equiv_s. * ira.c: Ditto. * lra-int.h (lra_init_equiv): New prototype. * lra-constraints.c (lra_init_equiv, update_equiv): New functions. (loc_equivalence_callback): Use the 3rd arg. (lra_constraints): Update equivalences. Pass curr_insn to simplify_replace_fn_rtx. * lra.c (lra): Call lra_init_equiv. @@ -2988,12 +2988,12 @@ return; ira_reg_equiv_len = max_reg_num () * 3 / 2 + 1; ira_reg_equiv -= (struct ira_reg_equiv *) xrealloc (ira_reg_equiv, += (struct ira_reg_equiv_s *) xrealloc (ira_reg_equiv, ira_reg_equiv_len -* sizeof (struct ira_reg_equiv)); +* sizeof (struct ira_reg_equiv_s)); ira_reg_equiv = XRESIZEVEC (struct ira_reg_equiv_s, ira_reg_equiv, ira_reg_equiv_len); instead? Yes, it is shorter. Thanks, Jakub. I'll commit it in my next patch.
Re: [RFC, patch] Detect lack of 32-bit devel environment on x86_64-linux targets
> The patch is okay, but if other architecture maintainers could add > similar checks for their ports (SPARC and PPC, I guess), it would be nice. Thanks, committed as rev. 205975 Adding other systems to the list of checks will be easy, once the maintainers confirm that they want to opt in into it. FX
[msp430] support volatile mems in more patterns
I went through all the patterns in the msp430 backend and converted all those that are volatile-safe to allow volatile MEM operands. Committed. * config/msp430/msp430.md (movqi): replace general_operand with msp_general_operand and nonimmediate_operand with msp_nonimmediate_operand to allow volatile operands. (movhi): Likewise. (movpsi): Likewise. (addpsi3): Likewise. (addhi3): Likewise. (addhi3_cy): Likewise. (addchi4_cy): Likewise. (xor3): Likewise. (ome_cmpl2): Likewise. (extendqihi2): Likewise. (zero_extendqihi2): Likewise. (zero_extendhipsi2): Likewise. (truncpsihi2): Likewise. (srai_1): Likewise. Index: gcc/config/msp430/msp430.md === --- gcc/config/msp430/msp430.md (revision 205974) +++ gcc/config/msp430/msp430.md (working copy) @@ -172,8 +172,8 @@ ) (define_insn "movqi" - [(set (match_operand:QI 0 "nonimmediate_operand" "=rYs,rm") - (match_operand:QI 1 "general_operand" "riYs,rmi"))] + [(set (match_operand:QI 0 "msp_nonimmediate_operand" "=rYs,rm") + (match_operand:QI 1 "msp_general_operand" "riYs,rmi"))] "" "@ MOV.B\t%1, %0 @@ -181,8 +181,8 @@ ) (define_insn "movhi" - [(set (match_operand:HI 0 "nonimmediate_operand" "=rYs,rm") - (match_operand:HI 1 "general_operand" "riYs,rmi"))] + [(set (match_operand:HI 0 "msp_nonimmediate_operand" "=rYs,rm") + (match_operand:HI 1 "msp_general_operand" "riYs,rmi"))] "" "@ MOV.W\t%1, %0 @@ -211,8 +211,8 @@ ;; Some MOVX.A cases can be done with MOVA, this is only a few of them. (define_insn "movpsi" - [(set (match_operand:PSI 0 "nonimmediate_operand" "=r,Ya,rm") - (match_operand:PSI 1 "general_operand" "riYa,r,rmi"))] + [(set (match_operand:PSI 0 "msp_nonimmediate_operand" "=r,Ya,rm") + (match_operand:PSI 1 "msp_general_operand" "riYa,r,rmi"))] "" "@ MOV%A0\t%1, %0 @@ -237,9 +237,9 @@ ;; Math (define_insn "addpsi3" - [(set (match_operand:PSI 0 "nonimmediate_operand" "=r,rm") - (plus:PSI (match_operand:PSI 1 "nonimmediate_operand" "%0,0") - (match_operand:PSI 2 "general_operand" "rLs,rmi")))] + [(set (match_operand:PSI 0 "msp_nonimmediate_operand" "=r,rm") + (plus:PSI (match_operand:PSI 1 "msp_nonimmediate_operand" "%0,0") + (match_operand:PSI 2 "msp_general_operand" "rLs,rmi")))] "" "@ ADDA\t%2, %0 @@ -247,9 +247,9 @@ ) (define_insn "addqi3" - [(set (match_operand:QI 0 "nonimmediate_operand" "=rYs,rm") - (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0") -(match_operand:QI 2 "general_operand" "riYs,rmi")))] + [(set (match_operand:QI 0 "msp_nonimmediate_operand" "=rYs,rm") + (plus:QI (match_operand:QI 1 "msp_nonimmediate_operand" "%0,0") +(match_operand:QI 2 "msp_general_operand" "riYs,rmi")))] "" "@ ADD.B\t%2, %0 @@ -257,9 +257,9 @@ ) (define_insn "addhi3" - [(set (match_operand:HI 0 "nonimmediate_operand" "=rYs,rm") - (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0") - (match_operand:HI 2 "general_operand" "riYs,rmi")))] + [(set (match_operand:HI 0 "msp_nonimmediate_operand" "=rYs,rm") + (plus:HI (match_operand:HI 1 "msp_nonimmediate_operand" "%0,0") + (match_operand:HI 2 "msp_general_operand" "riYs,rmi")))] "" "@ ADD.W\t%2, %0 @@ -316,9 +316,9 @@ ; that are not single_set() very well. (define_insn "addhi3_cy" - [(set (match_operand:HI 0 "nonimmediate_operand" "=r,rm") - (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0") -(match_operand:HI 2 "general_operand" "r,rm"))) + [(set (match_operand:HI 0 "msp_nonimmediate_operand" "=r,rm") + (plus:HI (match_operand:HI 1 "msp_nonimmediate_operand" "%0,0") +(match_operand:HI 2 "msp_general_operand" "r,rm"))) (set (reg:BI CARRY) (truncate:BI (lshiftrt:SI (plus:SI (zero_extend:SI (match_dup 1)) (zero_extend:SI (match_dup 2))) @@ -347,9 +347,9 @@ ; Version of addhi that adds the carry, for SImode adds. (define_insn "addchi4_cy" - [(set (match_operand:HI 0 "nonimmediate_operand" "=r,rm") - (plus:HI (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0") - (match_operand:HI 2 "general_operand" "ri,rmi")) + [(set (match_operand:HI 0 "msp_nonimmediate_operand" "=r,rm") + (plus:HI (plus:HI (match_operand:HI 1 "msp_nonimmediate_operand" "%0,0") + (match_operand:HI 2 "msp_general_operand" "ri,rmi")) (zero_extend:HI (reg:BI CARRY ] "" @@ -487,9 +487,9 @@ ) (define_insn "xor3" - [(set (match_operand:QHI 0 "nonimmediate_operand" "=rYs,rm") - (xor:QHI (match_operan
Re: [testsuite] Fix g++.dg/cilk-plus/cilk-plus.exp
Rainer Orth writes: > Andreas Schwab writes: > >> Rainer Orth writes: >> >>> diff --git a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp >>> b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp >>> --- a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp >>> +++ b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp >>> @@ -25,10 +25,11 @@ if { ![check_effective_target_cilkplus] >>> verbose "$tool $libdir" 1 >>> set library_var "[get_multilibs]" >>> # Pointing the ld_library_path to the Cilk Runtime library binaries. >>> -set ld_library_path "$[get_multilibs]/libcilkrts/.libs" >>> +append ld_library_path ":${library_var}/libcilkrts/.libs" >>> +set_ld_library_path_env_vars >>> >>> -set ALWAYS_CFLAGS "" >>> -lappend ALWAYS_CFLAGS "-L${library_var}/libcilkrts/.libs" >>> +global TEST_EXTRA_LIBS >>> +set TEST_EXTRA_LIBS "-L${library_var}/libcilkrts/.libs" >> >> There is no point in doing this twice. > > What are you talking about? Look down the file. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: C++ edge_iterator (was: Re: [SH] PR 53976 - Add RTL pass to eliminate clrt, sett insns)
On Fri, 2013-12-13 at 10:38 +0100, Richard Biener wrote: > Apart from the issues raised by Trevor I want to question if we want > to transition > to STL-like iterators (yeah, I know, the gsi_ ones are already > similar). I think it's easier to read and -- more importantly -- understand "foreign" code if that code is using well established names and semantics for doing common trivial things. Iterating over containers is one such thing. Moreover, STL usage is allowed in GCC and adopting STL container semantics will make it easier to switch container implementations (e.g. try using std::vector instead of vec) and have a more consistent way of doing such common things. > An obvious > cleanup to the existing FOR_EACH machinery is to declare the iterator inside > the FOR_EACH, thus make it an implementation detail (like I did with the loop > iterator). I think variable declarations with hard coded names hidden in macros are not always straight forward to follow. If there was a common way of iterating over stuff, something like boost's FOR_EACH could be added instead, although I don't think it's worth the effort to re-implement it. Cheers, Oleg
Re: [msp430] support volatile mems in more patterns
On Dec 13, 2013, at 1:59 PM, DJ Delorie wrote: > I went through all the patterns in the msp430 backend and converted > all those that are volatile-safe to allow volatile MEM operands. > Committed. > > * config/msp430/msp430.md (movqi): replace general_operand with > msp_general_operand and nonimmediate_operand with > msp_nonimmediate_operand to allow volatile operands. Oohh, Ahhh… Nice.
[PATCH] Use correct optab when expanding a binop (PR sanitizer/59503)
I noticed this bug a while ago on ppc64 and now I reproduced it even on x86_64 with -m32. The problem was that we were using add_optab even when dealing with MINUS_EXPR; we should use sub_optab instead. Regtested on x86_64-linux (with both -m32/-m64), ok for trunk? 2013-12-14 Marek Polacek PR sanitizer/59503 * internal-fn.c (ubsan_expand_si_overflow_addsub_check): Call expand_binop with correct optab depending on code. testsuite/ * c-c++-common/ubsan/pr59503.c: New test. --- gcc/internal-fn.c.mp2013-12-14 00:43:47.621016850 +0100 +++ gcc/internal-fn.c 2013-12-14 01:25:37.274728223 +0100 @@ -214,14 +214,14 @@ ubsan_expand_si_overflow_addsub_check (t /* Compute the operation. On RTL level, the addition is always unsigned. */ - res = expand_binop (mode, add_optab, op0, op1, - NULL_RTX, false, OPTAB_LIB_WIDEN); + res = expand_binop (mode, code == PLUS_EXPR ? add_optab : sub_optab, + op0, op1, NULL_RTX, false, OPTAB_LIB_WIDEN); /* If the op1 is negative, we have to use a different check. */ emit_cmp_and_jump_insns (op1, const0_rtx, LT, NULL_RTX, mode, false, sub_check, PROB_EVEN); - /* Compare the result of the addition with one of the operands. */ + /* Compare the result of the operation with one of the operands. */ emit_cmp_and_jump_insns (res, op0, code == PLUS_EXPR ? GE : LE, NULL_RTX, mode, false, done_label, PROB_VERY_LIKELY); --- gcc/testsuite/c-c++-common/ubsan/pr59503.c.mp 2013-12-14 02:04:14.209620616 +0100 +++ gcc/testsuite/c-c++-common/ubsan/pr59503.c 2013-12-14 02:18:32.681699158 +0100 @@ -0,0 +1,14 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=signed-integer-overflow" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ + +int +main (void) +{ + long long int a = 14; + long int b = 9; + asm volatile ("" : "+r" (a), "+r" (b)); + if ((a - b) != 5) +__builtin_abort (); + return 0; +} Marek
[rl78] fix constant in pattern
This was causing the final pattern to not match. Committed. * config/rl78/rl78-expand.md (one_cmplqi2): Make constant signed. Index: config/rl78/rl78-expand.md === --- config/rl78/rl78-expand.md (revision 205980) +++ config/rl78/rl78-expand.md (working copy) @@ -174,13 +174,13 @@ DONE;" ) (define_expand "one_cmplqi2" [(set (match_operand:QI 0 "nonimmediate_operand") (xor:QI (match_operand:QI 1 "general_operand") - (const_int 255))) + (const_int -1))) ] "" "if (rl78_force_nonfar_2 (operands, gen_one_cmplqi2)) DONE;" )
Re: [Patch, Fortran, OOP] PR 59450: ICE for type-bound-procedure expression in module procedure interface
Hi Janus, This review bounced of gnu-central because it had mime content - back to plain text! I am somewhat startled that this was so "easy" to fix (ie. the patch looks easy but I'll bet that find the fix was not!). OK for trunk. I think that MOD_VERSION does need bumping but I would bow to good negative arguments from others. Thanks for the patch. Paul
Re: [PATCH] Use correct optab when expanding a binop (PR sanitizer/59503)
On Sat, Dec 14, 2013 at 02:38:31AM +0100, Marek Polacek wrote: > I noticed this bug a while ago on ppc64 and now I reproduced it even > on x86_64 with -m32. The problem was that we were using add_optab even > when dealing with MINUS_EXPR; we should use sub_optab instead. > > Regtested on x86_64-linux (with both -m32/-m64), ok for trunk? > > 2013-12-14 Marek Polacek > > PR sanitizer/59503 > * internal-fn.c (ubsan_expand_si_overflow_addsub_check): Call > expand_binop with correct optab depending on code. > testsuite/ > * c-c++-common/ubsan/pr59503.c: New test. Sure. Jakub
[PATCH] Finish up -fsanitize=signed-integer-overflow multiplication handling
Hi! This patch on top of the http://gcc.gnu.org/ml/gcc-patches/2013-12/msg00500.html patch adds multiplication overflow checking for the missing cases (modes which don't have 2x wider supported mode so we can't do a widening multiply to the wider mode or full wider mode multiplication, but we at least have 2x narrower mode). Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2013-12-14 Jakub Jelinek * predict.h (PROB_LIKELY): Fix the value. * internal-fn.c (ubsan_expand_si_overflow_mul_check): Add support for overflow checking for modes without 2xwider supported mode, if the mode has 2xnarrower mode. * c-c++-common/ubsan/overflow-mul-3.c: New test. * c-c++-common/ubsan/overflow-mul-4.c: New test. --- gcc/predict.h.jj2013-12-12 18:48:44.892011631 +0100 +++ gcc/predict.h 2013-12-12 20:28:09.927588762 +0100 @@ -28,7 +28,7 @@ along with GCC; see the file COPYING3. #define PROB_VERY_LIKELY (REG_BR_PROB_BASE - PROB_VERY_UNLIKELY) #define PROB_ALWAYS(REG_BR_PROB_BASE) #define PROB_UNLIKELY (REG_BR_PROB_BASE / 5 - 1) -#define PROB_LIKELY (PROB_ALWAYS - PROB_VERY_LIKELY) +#define PROB_LIKELY (REG_BR_PROB_BASE - PROB_UNLIKELY) #define DEF_PREDICTOR(ENUM, NAME, HITRATE, FLAGS) ENUM, enum br_predictor --- gcc/internal-fn.c.jj2013-12-12 20:28:04.558615203 +0100 +++ gcc/internal-fn.c 2013-12-13 14:26:43.060339323 +0100 @@ -436,6 +436,8 @@ ubsan_expand_si_overflow_mul_check (gimp if (icode == CODE_FOR_nothing) { struct separate_ops ops; + enum machine_mode hmode + = mode_for_size (GET_MODE_PRECISION (mode) / 2, MODE_INT, 1); ops.op0 = arg0; ops.op1 = arg1; ops.op2 = NULL_TREE; @@ -462,10 +464,295 @@ ubsan_expand_si_overflow_mul_check (gimp emit_cmp_and_jump_insns (signbit, hipart, EQ, NULL_RTX, mode, false, done_label, PROB_VERY_LIKELY); } + else if (hmode != BLKmode + && 2 * GET_MODE_PRECISION (hmode) == GET_MODE_PRECISION (mode)) + { + rtx large_op0 = gen_label_rtx (); + rtx small_op0_large_op1 = gen_label_rtx (); + rtx one_small_one_large = gen_label_rtx (); + rtx both_ops_large = gen_label_rtx (); + rtx after_hipart_neg = gen_label_rtx (); + rtx after_lopart_neg = gen_label_rtx (); + rtx do_overflow = gen_label_rtx (); + rtx hipart_different = gen_label_rtx (); + + int hprec = GET_MODE_PRECISION (hmode); + rtx hipart0 = expand_shift (RSHIFT_EXPR, mode, op0, hprec, + NULL_RTX, 0); + hipart0 = gen_lowpart (hmode, hipart0); + rtx lopart0 = gen_lowpart (hmode, op0); + rtx signbit0 = expand_shift (RSHIFT_EXPR, hmode, lopart0, hprec - 1, + NULL_RTX, 0); + rtx hipart1 = expand_shift (RSHIFT_EXPR, mode, op1, hprec, + NULL_RTX, 0); + hipart1 = gen_lowpart (hmode, hipart1); + rtx lopart1 = gen_lowpart (hmode, op1); + rtx signbit1 = expand_shift (RSHIFT_EXPR, hmode, lopart1, hprec - 1, + NULL_RTX, 0); + + res = gen_reg_rtx (mode); + + /* True if op0 resp. op1 are known to be in the range of +halfstype. */ + bool op0_small_p = false; + bool op1_small_p = false; + /* True if op0 resp. op1 are known to have all zeros or all ones +in the upper half of bits, but are not known to be +op{0,1}_small_p. */ + bool op0_medium_p = false; + bool op1_medium_p = false; + /* -1 if op{0,1} is known to be negative, 0 if it is known to be +nonnegative, 1 if unknown. */ + int op0_sign = 1; + int op1_sign = 1; + + if (TREE_CODE (arg0) == SSA_NAME) + { + double_int arg0_min, arg0_max; + if (get_range_info (arg0, &arg0_min, &arg0_max) == VR_RANGE) + { + if (arg0_max.sle (double_int::max_value (hprec, false)) + && double_int::min_value (hprec, false).sle (arg0_min)) + op0_small_p = true; + else if (arg0_max.sle (double_int::max_value (hprec, true)) + && (~double_int::max_value (hprec, + true)).sle (arg0_min)) + op0_medium_p = true; + if (!arg0_min.is_negative ()) + op0_sign = 0; + else if (arg0_max.is_negative ()) + op0_sign = -1; + } + } + if (TREE_CODE (arg1) == SSA_NAME) + { + double_int arg1_min, arg1_max; + if (get_range_info (arg1, &arg1_min, &arg1_max) == VR_RANGE) + { + if (arg1_max.sle