RE: [Ping] [PATCH, 1/10] two hooks for conditional compare (ccmp)

2014-10-27 Thread Zhenqiang Chen
Thanks for the comments. All comments are accepted and the updated patch is
attached.

-Zhenqiang

> -Original Message-
> From: Richard Henderson [mailto:r...@redhat.com]
> Sent: Saturday, October 11, 2014 11:00 PM
> To: Zhenqiang Chen; gcc-patches@gcc.gnu.org
> Subject: Re: [Ping] [PATCH, 1/10] two hooks for conditional compare (ccmp)
> 
> On 09/22/2014 11:43 PM, Zhenqiang Chen wrote:
> >
> > +@cindex @code{ccmp} instruction pattern @item @samp{ccmp}
> Conditional
> > +compare instruction.  Operand 2 and 5 are RTLs which perform two
> > +comparisons.  Operand 1 is AND or IOR, which operates on the result
> > +of operand 2 and 5.
> > +It uses recursive method to support more than two compares.  e.g.
> > +
> > +  CC0 = CMP (a, b);
> > +  CC1 = CCMP (NE (CC0, 0), CMP (e, f));  ...
> > +  CCn = CCMP (NE (CCn-1, 0), CMP (...));
> > +
> > +Two target hooks are used to generate conditional compares.
> > +GEN_CCMP_FISRT is used to generate the first CMP.  And
> GEN_CCMP_NEXT
> > +is used to generate the following CCMPs.  Operand 1 is AND or IOR.
> > +Operand 3 is the result of GEN_CCMP_FISRT or a previous
> GEN_CCMP_NEXT.  Operand 2 is NE.
> > +Operand 4, 5 and 6 is another compare expression.
> > +
> > +A typical CCMP pattern looks like
> > +
> > +@smallexample
> > +(define_insn "*ccmp_and_ior"
> > +  [(set (match_operand 0 "dominant_cc_register" "")
> > +(compare
> > + (match_operator 1
> > +  (match_operator 2 "comparison_operator"
> > +   [(match_operand 3 "dominant_cc_register")
> > +(const_int 0)])
> > +  (match_operator 4 "comparison_operator"
> > +   [(match_operand 5 "register_operand")
> > +(match_operand 6 "compare_operand"]))
> > + (const_int 0)))]
> > +  ""
> > +  "@dots{}")
> > +@end smallexample
> > +
> 
> This whole section should be removed.  You do not have a named ccmp
> pattern.
> Even your example below is an *unnamed pattern.  This is an
> implementation detail of the aarch64 backend.
> 
> Named patterns are used when that is the interface the middle-end uses to
> emit code.  But you're not using named patterns, you're using:
> 
> >
> > +@deftypefn {Target Hook} rtx TARGET_GEN_CCMP_FIRST (int
> @var{code},
> > +rtx @var{op0}, rtx @var{op1}) This function emits a comparison insn
> > +for the first of a sequence of  conditional comparisions.  It returns
> > +a comparison expression appropriate  for passing to
> @code{gen_ccmp_next} or to @code{cbranch_optab}.
> > + @code{unsignedp} is used when converting @code{op0} and
> @code{op1}'s mode.
> > +@end deftypefn
> > +
> > +@deftypefn {Target Hook} rtx TARGET_GEN_CCMP_NEXT (rtx @var{prev},
> > +int @var{cmp_code}, rtx @var{op0}, rtx @var{op1}, int @var{bit_code})
> > +This function emits a conditional comparison within a sequence of
> > +conditional comparisons.  The @code{prev} expression is the result of
> > +a  prior call to @code{gen_ccmp_first} or @code{gen_ccmp_next}.  It
> > +may return  @code{NULL} if the combination of @code{prev} and this
> > +comparison is  not supported, otherwise the result must be
> > +appropriate for passing to  @code{gen_ccmp_next} or
> @code{cbranch_optab}.  @code{bit_code}  is AND or IOR, which is the op on
> the two compares.
> > +@end deftypefn
> 
> Every place above where you refer to the arguments of the function should
> use @var; you're using @code for most of them.  Use @code{AND} and
> @code{IOR}.
> 
> 
> r~


1-hooks.patch
Description: Binary data


RE: [Ping] [PATCH, 5/10] aarch64: add ccmp operand predicate

2014-10-27 Thread Zhenqiang Chen
Thanks for the comments. All comments are accepted and the updated patch is
attached.

-Zhenqiang

> -Original Message-
> From: Richard Henderson [mailto:r...@redhat.com]
> Sent: Saturday, October 11, 2014 11:22 PM
> To: Zhenqiang Chen; gcc-patches@gcc.gnu.org
> Subject: Re: [Ping] [PATCH, 5/10] aarch64: add ccmp operand predicate
> 
> On 09/22/2014 11:44 PM, Zhenqiang Chen wrote:
> > +/* Return true if val can be encoded as a 5-bit unsigned immediate.
> > +*/ bool
> > +aarch64_uimm5 (HOST_WIDE_INT val)
> > +{
> > +  return (val & (HOST_WIDE_INT) 0x1f) == val; }
> 
> This is just silly.
> 
> > +(define_constraint "Usn"
> > + "A constant that can be used with a CCMN operation (once negated)."
> > + (and (match_code "const_int")
> > +  (match_test "aarch64_uimm5 (-ival)")))
> 
> (match_test "IN_RANGE (ival, -31, 0)")
> 
> > +(define_predicate "aarch64_ccmp_immediate"
> > +  (and (match_code "const_int")
> > +   (ior (match_test "aarch64_uimm5 (INTVAL (op))")
> > +   (match_test "aarch64_uimm5 (-INTVAL (op))"
> 
> (and (match_code "const_int")
>  (match_test "IN_RANGE (INTVAL (op), -31, 31)"))
> 
> 
> r~


5-ccmp-operants.patch
Description: Binary data


RE: [Ping] [PATCH, 2/10] prepare ccmp

2014-10-27 Thread Zhenqiang Chen
Thanks for the comments. Patch is updated.

-Zhenqiang

> -Original Message-
> From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-
> ow...@gcc.gnu.org] On Behalf Of Richard Henderson
> Sent: Saturday, October 11, 2014 11:03 PM
> To: Zhenqiang Chen; gcc-patches@gcc.gnu.org
> Subject: Re: [Ping] [PATCH, 2/10] prepare ccmp
> 
> On 09/22/2014 11:43 PM, Zhenqiang Chen wrote:
> > + /* If jumps are cheap and the target does not support conditional
> > +compare, turn some more codes into jumpy sequences.  */
> > + else if (BRANCH_COST (optimize_insn_for_speed_p (), false) < 4
> > +  && (targetm.gen_ccmp_first == NULL))
> 
> Don't add unnecessary parenthesis around the == expression.
> 
> Otherwise ok.
> 
> 
> r~


2-prepare.patch
Description: Binary data


RE: [Ping] [PATCH, 6/10] aarch64: add ccmp CC mode

2014-10-27 Thread Zhenqiang Chen

> -Original Message-
> From: Richard Henderson [mailto:r...@redhat.com]
> Sent: Saturday, October 11, 2014 11:32 PM
> To: Zhenqiang Chen; gcc-patches@gcc.gnu.org
> Subject: Re: [Ping] [PATCH, 6/10] aarch64: add ccmp CC mode
> 
> On 09/22/2014 11:44 PM, Zhenqiang Chen wrote:
> > +case CC_DNEmode:
> > +  return comp_code == NE ? AARCH64_NE : AARCH64_EQ;
> > +case CC_DEQmode:
> > +  return comp_code == NE ? AARCH64_EQ : AARCH64_NE;
> > +case CC_DGEmode:
> > +  return comp_code == NE ? AARCH64_GE : AARCH64_LT;
> > +case CC_DLTmode:
> > +  return comp_code == NE ? AARCH64_LT : AARCH64_GE;
> > +case CC_DGTmode:
> > +  return comp_code == NE ? AARCH64_GT : AARCH64_LE;
> > +case CC_DLEmode:
> > +  return comp_code == NE ? AARCH64_LE : AARCH64_GT;
> > +case CC_DGEUmode:
> > +  return comp_code == NE ? AARCH64_CS : AARCH64_CC;
> > +case CC_DLTUmode:
> > +  return comp_code == NE ? AARCH64_CC : AARCH64_CS;
> > +case CC_DGTUmode:
> > +  return comp_code == NE ? AARCH64_HI : AARCH64_LS;
> > +case CC_DLEUmode:
> > +  return comp_code == NE ? AARCH64_LS : AARCH64_HI;
> 
> I think these should return -1 if comp_code is not EQ.  Like the CC_Zmode
> case below.

Since the code can not guarantee that the CC is used in cbranchcc insns when
expand, it maybe in a tmp register. After some optimizations the CC is
forwarded in cbranchcc insn. So the comp_code might be any legal COMPARE.

And ccmp CC mode has the flag based on NE, so the patch reverts the flag if
not NE.

> Perhaps you can share some code to make the whole thing less bulky.  E.g.
> 
>   ...
>   case CC_DLEUmode:
> ne = AARCH64_LS;
> eq = AARCH64_HI;
> break;
>   case CC_Zmode:
> ne = AARCH64_NE;
> eq = AARCH64_EQ;
> break;
> }
>   if (code == NE)
>   return ne;
>   if (code == EQ)
>   return eq;
>   return -1;

Thanks for the comments. Patch is updated.
 
> This does beg the question of whether you need both CC_Zmode and
> CC_DNEmode.
> I'll leave it to an ARM maintainer to say which one of the two should be
kept.
> 
> 
> r~


6-ccmp-cc-mode.patch
Description: Binary data


RE: [Ping] [PATCH, 7/10] aarch64: add function to output ccmp insn

2014-10-27 Thread Zhenqiang Chen


> -Original Message-
> From: Richard Henderson [mailto:r...@redhat.com]
> Sent: Sunday, October 12, 2014 12:52 PM
> To: Zhenqiang Chen; gcc-patches@gcc.gnu.org
> Subject: Re: [Ping] [PATCH, 7/10] aarch64: add function to output ccmp
insn
> 
> On 10/11/2014 09:11 AM, Richard Henderson wrote:
> > On 09/22/2014 11:45 PM, Zhenqiang Chen wrote:
> >> +static unsigned int
> >> +aarch64_code_to_nzcv (enum rtx_code code, bool inverse) {
> >> +  switch (code)
> >> +{
> >> +case NE: /* NE, Z == 0.  */
> >> +  return inverse ? AARCH64_CC_Z : 0;
> >> +case EQ: /* EQ, Z == 1.  */
> >> +  return inverse ? 0 : AARCH64_CC_Z;
> >> +case LE: /* LE, !(Z == 0 && N == V).  */
> >> +  return inverse ? AARCH64_CC_N | AARCH64_CC_V : AARCH64_CC_Z;
> >> +case GT: /* GT, Z == 0 && N == V.  */
> >> +  return inverse ? AARCH64_CC_Z : AARCH64_CC_N | AARCH64_CC_V;
> >> +case LT: /* LT, N != V.  */
> >> +  return inverse ? AARCH64_CC_N | AARCH64_CC_V : AARCH64_CC_N;
> >> +case GE: /* GE, N == V.  */
> >> +  return inverse ? AARCH64_CC_N : AARCH64_CC_N | AARCH64_CC_V;
> >> +case LEU: /* LS, !(C == 1 && Z == 0).  */
> >> +  return inverse ? AARCH64_CC_C: AARCH64_CC_Z;
> >> +case GTU: /* HI, C ==1 && Z == 0.  */
> >> +  return inverse ? AARCH64_CC_Z : AARCH64_CC_C;
> >> +case LTU: /* CC, C == 0.  */
> >> +  return inverse ? AARCH64_CC_C : 0;
> >> +case GEU: /* CS, C == 1.  */
> >> +  return inverse ? 0 : AARCH64_CC_C;
> >> +default:
> >> +  gcc_unreachable ();
> >> +  return 0;
> >> +}
> >> +}
> >> +
> >
> > I'm not overly fond of this, since "code" doesn't map 1-1.  It needs
> > the context of a mode to provide a unique mapping.
> >
> > I think it would be better to rearrange the existing aarch64_cond_code
> > enum such that AARCH64_NE et al are meaningful wrt NZCV.  Then you can
> > use
> > aarch64_get_condition_code_1 to get this mapping.
>
> Slight mistake in the advice here.  I think you should use
> aarch64_get_conditional_code_1 to get an aarch64_cond_code, and use that
> to index an array to get the nzcv bits.

Thanks for the comments. Patch is updated.
 
> Further, does it actually make sense to store both nzcv and its inverse,
or
> does it work to use nzcv and ~nzcv?
 
Flag GE checks N == V and LT checks N != V. We can no distinguish them with
nzcv and ~nzcv

Since aarch64_output_ccmp is removed as your comments, the patch is combined
with [PATCH, 8/10] aarch64: ccmp insn patterns. Please find the updated
patch in later email.

Thanks!
-Zhenqiang






RE: [Ping] [PATCH, 8/10] aarch64: ccmp insn patterns

2014-10-27 Thread Zhenqiang Chen


> -Original Message-
> From: Richard Henderson [mailto:r...@redhat.com]
> Sent: Sunday, October 12, 2014 4:12 AM
> To: Zhenqiang Chen; gcc-patches@gcc.gnu.org
> Subject: Re: [Ping] [PATCH, 8/10] aarch64: ccmp insn patterns
> 
> On 09/22/2014 11:45 PM, Zhenqiang Chen wrote:
> > +(define_expand "cbranchcc4"
> > +  [(set (pc) (if_then_else
> > + (match_operator 0 "aarch64_comparison_operator"
> > +  [(match_operand 1 "cc_register" "")
> > +   (const_int 0)])
> > + (label_ref (match_operand 3 "" ""))
> > + (pc)))]
> > +  ""
> > +  " ")
> 
> Extra space.

Updated.
 
> > +(define_insn "*ccmp_and"
> > +  [(set (match_operand 6 "ccmp_cc_register" "")
> > +   (compare
> > +(and:SI
> > + (match_operator 4 "aarch64_comparison_operator"
> > +  [(match_operand 0 "ccmp_cc_register" "")
> > +   (match_operand 1 "aarch64_plus_operand" "")])
> > + (match_operator 5 "aarch64_comparison_operator"
> > +  [(match_operand:GPI 2 "register_operand" "r,r,r")
> > +   (match_operand:GPI 3 "aarch64_ccmp_operand" "r,Uss,Usn")]))
> > +(const_int 0)))]
> > +  ""
> > +  {
> > +return aarch64_output_ccmp (operands, true, which_alternative);
> > +  }
> > +  [(set_attr "type" "alus_sreg,alus_imm,alus_imm")]
> > +)
> > +
> > +(define_insn "*ccmp_ior"
> > +  [(set (match_operand 6 "ccmp_cc_register" "")
> > +   (compare
> > +(ior:SI
> > + (match_operator 4 "aarch64_comparison_operator"
> > +  [(match_operand 0 "ccmp_cc_register" "")
> > +   (match_operand 1 "aarch64_plus_operand" "")])
> > + (match_operator 5 "aarch64_comparison_operator"
> > +  [(match_operand:GPI 2 "register_operand" "r,r,r")
> > +   (match_operand:GPI 3 "aarch64_ccmp_operand" "r,Uss,Usn")]))
> > +(const_int 0)))]
> > +  ""
> > +  {
> > +return aarch64_output_ccmp (operands, false, which_alternative);
> > +  }
> > +  [(set_attr "type" "alus_sreg,alus_imm,alus_imm")]
> 
> Surely not aarch64_plus_operand for operand 1.  That's a comparison with
> the flags register.  Surely (const_int 0) is the only valid operand there.
> 
> These could be combined with a code iterator, and thus there would be
> exactly one call to aarch64_output_ccmp, and thus inlined.  Although...
> 
> It seems to me that you don't need a function call at all.  How about
> 
> AND
>   "@
>ccmp\\t%2, %3, %K5, %m4
>ccmp\\t%2, %3, %K5, %m4
>ccmn\\t%2, #%n3, %K5, %m4"
> 
> IOR
>   "@
>ccmp\\t%2, %3, %k5, %M4
>ccmp\\t%2, %3, %k5, %M4
>ccmn\\t%2, #%n3, %k5, %M4"
> 
> where 'k' and 'K' are new print_operand codes that output the nzcv (or its
> inverse) integer for the comparison, much like 'm' and 'M' print the name
of
> the comparison.

Updated with a bit change.

+   ccmp\\t%2, %3, %z5, %k4
+   ccmp\\t%2, %3, %z5, %k4
+   ccmn\\t%2, #%n3, %z5, %k4"

z/Z is the k/K as you suggested. I can not reuse m/M since they are special
for cbranchcc (with CCMP). So I use new added k/K.

Thanks!
-Zhenqiang


7-8-ccmp-patterns.patch
Description: Binary data


RE: [Ping] [PATCH, 9/10] aarch64: generate conditional compare instructions

2014-10-27 Thread Zhenqiang Chen


> -Original Message-
> From: Richard Henderson [mailto:r...@redhat.com]
> Sent: Sunday, October 12, 2014 4:46 AM
> To: Zhenqiang Chen; gcc-patches@gcc.gnu.org
> Subject: Re: [Ping] [PATCH, 9/10] aarch64: generate conditional compare
> instructions
> 
> On 09/22/2014 11:46 PM, Zhenqiang Chen wrote:
> > +static bool
> > +aarch64_convert_mode (rtx* op0, rtx* op1, int unsignedp) {
> > +  enum machine_mode mode;
> > +
> > +  mode = GET_MODE (*op0);
> > +  if (mode == VOIDmode)
> > +mode = GET_MODE (*op1);
> > +
> > +  if (mode == QImode || mode == HImode)
> > +{
> > +  *op0 = convert_modes (SImode, mode, *op0, unsignedp);
> > +  *op1 = convert_modes (SImode, mode, *op1, unsignedp);
> > +}
> > +  else if (mode != SImode && mode != DImode)
> > +return false;
> > +
> > +  return true;
> > +}
> 
> Hum.  I'd rather not replicate too much of the expander logic here.
> 
> We could avoid that by using struct expand_operand, create_input_operand
> et al, then expand_insn.  That does require that the target hooks be given
> trees rather than rtl as input.

I had tried to use tree/gimple as input. But the codes was more complexity
than current one.

And comments in https://gcc.gnu.org/ml/gcc-patches/2014-06/msg02027.html
" I suspect it might be better to just hoist any preparation operations
above the entire conditional compare sequence, so that by the time we
start the ccmp expansion we're dealing with operands that are in the
'natural' sizes for the machine (breaking up the conditional compare
sequence for what are almost side-effect operations sounds like a source
of potential bugs).  This would also ensure that the back-end can safely
re-order at least some comparison operations if this leads a workable
conditional compare sequence. "

I think the mode conversion (to SImode or DImode) is target dependent.

Thanks!
-Zhenqiang





RE: [Ping] [PATCH, 10/10] aarch64: Handle ccmp in ifcvt to make it work with cmov

2014-10-27 Thread Zhenqiang Chen


> -Original Message-
> From: Richard Henderson [mailto:r...@redhat.com]
> Sent: Sunday, October 12, 2014 5:40 AM
> To: Zhenqiang Chen; gcc-patches@gcc.gnu.org
> Subject: Re: [Ping] [PATCH, 10/10] aarch64: Handle ccmp in ifcvt to make
it
> work with cmov
> 
> On 09/22/2014 11:46 PM, Zhenqiang Chen wrote:
> > @@ -2375,10 +2387,21 @@ noce_get_condition (rtx_insn *jump, rtx_insn
> **earliest, bool then_else_reversed
> >return cond;
> >  }
> >
> > +  /* For conditional compare, set ALLOW_CC_MODE to TRUE.  */
> > +  if (targetm.gen_ccmp_first)
> > +{
> > +  rtx prev = prev_nonnote_nondebug_insn (jump);
> > +  if (prev
> > + && NONJUMP_INSN_P (prev)
> > + && BLOCK_FOR_INSN (prev) == BLOCK_FOR_INSN (jump)
> > + && ccmp_insn_p (prev))
> > +   allow_cc_mode = true;
> > +}
> > +
> >/* Otherwise, fall back on canonicalize_condition to do the dirty
> >   work of manipulating MODE_CC values and COMPARE rtx codes.  */
> >tmp = canonicalize_condition (jump, cond, reverse, earliest,
> > -   NULL_RTX, false, true);
> > +   NULL_RTX, allow_cc_mode, true);
> 
> This needs a lot more explanation.  Why it it ok to allow a cc_mode when
the
> source is a ccmp, and not for any other comparison?
> 
> The issue is going to be how we use the comparison once we've finished
with
> the transformation.  Is it going to be able to be properly handled by
> emit_conditional_move?
> 
> If the target doesn't have cbranchcc4, I think that prep_cmp_insn will
fail.
> But as you show from

Good point. It is not ccmp special. It is cbranchcc4 related. If I
understand correct, without cbranchcc4, we need put the result to  a tmp
register and generate additional compares, which is not good for
performance.

I update the patch to check

+#if HAVE_cbranchcc4
+  allow_cc_mode = true;
+#endif

Thanks!
-Zhenqiang

> > +++ b/gcc/config/aarch64/aarch64.md
> > @@ -2589,15 +2589,19 @@
> >(match_operand:ALLI 3 "register_operand" "")))]
> >""
> >{
> > -rtx ccreg;
> >  enum rtx_code code = GET_CODE (operands[1]);
> >
> >  if (code == UNEQ || code == LTGT)
> >FAIL;
> >
> > -ccreg = aarch64_gen_compare_reg (code, XEXP (operands[1], 0),
> > - XEXP (operands[1], 1));
> > -operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx);
> > +if (!ccmp_cc_register (XEXP (operands[1], 0),
> > +  GET_MODE (XEXP (operands[1], 0
> > +  {
> > +   rtx ccreg;
> > +   ccreg = aarch64_gen_compare_reg (code, XEXP (operands[1], 0),
> > +XEXP (operands[1], 1));
> > +   operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx);
> > +  }
> 
> this change, even more than that may be required.
> 
> 
> r~


10-ifcvt.patch
Description: Binary data


Re: [PATCH x86] Increase PARAM_MAX_COMPLETELY_PEELED_INSNS when branch is costly

2014-10-27 Thread Evgeny Stupachenko
The results are the same for Silvermont.
There are no significant changes on Haswell.
So I agree with Richard, let's enable this x86 wide.

Bootstrap/ passed.
Make check in progress.
Is it ok?

2014-10-25  Evgeny Stupachenko  
* config/i386/i386.c (ix86_option_override_internal): Increase
PARAM_MAX_COMPLETELY_PEELED_INSNS.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 6337aa5..5ac10eb 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -4081,6 +4081,12 @@ ix86_option_override_internal (bool main_args_p,
 opts->x_param_values,
 opts_set->x_param_values);

+  /* Extend full peel max insns parameter for x86.  */
+  maybe_set_param_value (PARAM_MAX_COMPLETELY_PEELED_INSNS,
+120,
+opts->x_param_values,
+opts_set->x_param_values);
+
   /* Enable sw prefetching at -O3 for CPUS that prefetching is helpful.  */
   if (opts->x_flag_prefetch_loop_arrays < 0
   && HAVE_prefetch

On Mon, Oct 13, 2014 at 4:23 PM, Jan Hubicka  wrote:
>> On Fri, Oct 10, 2014 at 5:40 PM, Evgeny Stupachenko  
>> wrote:
>> > Hi,
>> >
>> > The patch increase PARAM_MAX_COMPLETELY_PEELED_INSNS for CPUs with
>> > high branch cost.
>> > Bootstrap and make check are in progress.
>> > The patch boosts (up to 2,5 times improve) several benchmarks compiled
>> > with "-Ofast" on Silvermont
>> > Spec2000:
>> > +5% gain on 173.applu
>> > +1% gain on 255.vortex
>> >
>> > Is it ok for trunk when pass bootstrap and make check?
>>
>> This is only a 20% increase - from 100 to 120.  I would instead suggest
>> to explore doing this change unconditionally if it helps that much.
>
> Agreed, I think the value of 100 was set decade ago by Zdenek and me 
> completely
> artifically. I do not recall any serious tuning of this flag.
>
> Note that I plan to update
> https://gcc.gnu.org/ml/gcc-patches/2013-11/msg02270.html to current tree so
> PARAM_MAX_COMPLETELY_PEELED_INSNS will be used at gimple level rather than 
> tree
> changing its meaning somewhat.
>
> Perhaps I could try to find time this or next week to update the patch so we 
> do
> not need to do the tuning twice.
>
> Honza
>
>>
>> Richard.
>>
>> > Thanks,
>> > Evgeny
>> >
>> > 2014-10-10  Evgeny Stupachenko  
>> > * config/i386/i386.c (ix86_option_override_internal): Increase
>> > PARAM_MAX_COMPLETELY_PEELED_INSNS for CPUs with high branch cost.
>> > * config/i386/i386.h (TARGET_HIGH_BRANCH_COST): New.
>> > * config/i386/x86-tune.def (X86_TUNE_HIGH_BRANCH_COST): Indicates
>> > CPUs with high branch cost.
>> >
>> > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
>> > index 6337aa5..5ac10eb 100644
>> > --- a/gcc/config/i386/i386.c
>> > +++ b/gcc/config/i386/i386.c
>> > @@ -4081,6 +4081,14 @@ ix86_option_override_internal (bool main_args_p,
>> >  opts->x_param_values,
>> >  opts_set->x_param_values);
>> >
>> > +  /* Extend full peel max insns parameter for CPUs with high branch cost. 
>> >  */
>> > +  if (TARGET_HIGH_BRANCH_COST)
>> > +maybe_set_param_value (PARAM_MAX_COMPLETELY_PEELED_INSNS,
>> > +  120,
>> > +  opts->x_param_values,
>> > +  opts_set->x_param_values);
>> > +
>> > +
>> >/* Enable sw prefetching at -O3 for CPUS that prefetching is helpful.  
>> > */
>> >if (opts->x_flag_prefetch_loop_arrays < 0
>> >&& HAVE_prefetch
>> > diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
>> > index 2c64162..da0c57b 100644
>> > --- a/gcc/config/i386/i386.h
>> > +++ b/gcc/config/i386/i386.h
>> > @@ -415,6 +415,7 @@ extern unsigned char ix86_tune_features[X86_TUNE_LAST];
>> >  #define TARGET_INTER_UNIT_CONVERSIONS \
>> > ix86_tune_features[X86_TUNE_INTER_UNIT_CONVERSIONS]
>> >  #define TARGET_FOUR_JUMP_LIMIT 
>> > ix86_tune_features[X86_TUNE_FOUR_JUMP_LIMIT]
>> > +#define TARGET_HIGH_BRANCH_COST
>> > ix86_tune_features[X86_TUNE_HIGH_BRANCH_COST]
>> >  #define TARGET_SCHEDULE
>> > ix86_tune_features[X86_TUNE_SCHEDULE]
>> >  #define TARGET_USE_BT  ix86_tune_features[X86_TUNE_USE_BT]
>> >  #define TARGET_USE_INCDEC  ix86_tune_features[X86_TUNE_USE_INCDEC]
>> > diff --git a/gcc/config/i386/x86-tune.def b/gcc/config/i386/x86-tune.def
>> > index b6b210e..04d8bf8 100644
>> > --- a/gcc/config/i386/x86-tune.def
>> > +++ b/gcc/config/i386/x86-tune.def
>> > @@ -208,6 +208,11 @@ DEF_TUNE (X86_TUNE_FOUR_JUMP_LIMIT, "four_jump_limit",
>> >m_PPRO | m_P4_NOCONA | m_BONNELL | m_SILVERMONT | m_INTEL |
>> >   m_ATHLON_K8 | m_AMDFAM10)
>> >
>> > +/* X86_TUNE_HIGH_BRANCH_COST: Some CPUs have higher branch cost.  This 
>> > could be
>> > +   used to tune unroll, if-cvt, inline... heuristics.  */
>> > +DEF_TUNE (X86_TUNE_HIGH_BRANCH_COST, "high_branch_cost",
>> > +  m_BONNELL | m_SILVERMONT | m_INTEL

RE: [PING**2] [PATCH] Fix PR ipa/61190, 2nd edition‏

2014-10-27 Thread Bernd Edlinger

Ping again...

Thanks.


> From: bernd.edlin...@hotmail.de
> To: hubi...@ucw.cz
> CC: gcc-patches@gcc.gnu.org; richard.guent...@gmail.com
> Subject: [PING] [PATCH] Fix PR ipa/61190, 2nd edition‏
> Date: Tue, 14 Oct 2014 11:40:56 +0200
>
> Ping...
>
> see: https://gcc.gnu.org/ml/gcc-patches/2014-10/msg00536.html
>
>> Hi Honza,
>>
>>
>> as you know, we have a wrong code bug, when a pure or const method is called 
>> via a virtual thunk.
>> I had some more Ideas, how to fix that, but all of them had some serious 
>> draw-backs, so I leave the details out...
>>
>>
>> But now I have a new insight, why the "obvious" fix for this serious code 
>> generation bug did not work
>> in the first place.
>>
>>
>> And the reason was, that if ipa-pure-const.c calls set_const_flag or 
>> set_pure_flag for a thunk, it calls the same
>> function later for the called method, and this overwrites the flags of _all_ 
>> associated thunks and aliases.
>> However that should at least not be done for virtual thunks, as these need 
>> to be IPA_NEITHER, even if
>> the method itself has different attributes, that is because the assembler 
>> thunk accesses the vtable, while
>> other thunks do not.
>>
>>
>> So I re-factored set_const_flag and set_pure_flag to exclude the virtual 
>> thunks, taking care that other
>> users of call_for_symbol_thunks_and_aliases do not get a different behavior 
>> than before this patch.
>>
>>
>> The attached patch was boot-strapped and
>> regression-tested on x86_64-linux-gnu.
>> Ok for trunk?
>>
>>
>> PS: As a side-note, there are two identical functions, named 
>> "call_for_symbol_and_aliases", in
>> class symtab_node and in class cgraph_node, which inherits from symtab_node. 
>> Both functions are
>> not declared virtual. Is that what's intended? Usually this could lead to 
>> errors, or at least some serious
>> compiler warnings.
>>
>>
>> Thanks
>> Bernd.
>>
>
  

Re: [s390] RFA: Use new rtl iterators in s390_loop_unroll_adjust

2014-10-27 Thread Andreas Krebbel
On 10/25/2014 12:10 PM, Richard Sandiford wrote:
> This is part of a series to remove uses of for_each_rtx from the ports.
> I think we only want to consider MEMs in patterns here, not MEMs in notes etc.
> (Not sure why I "fixed" it for s390 but not for x86...)
> 
> Tested by making sure there were no code changes for gcc.dg, gcc.c-torture
> and g++.dg for s390x-linux-gnu.  OK to install?

Ok. Thanks!

-Andreas-

> 
> Thanks,
> Richard
> 
> 
> gcc/
>   * config/s390/s390.c: Include rtl-iter.h.
>   (check_dpu): Delete.
>   (s390_loop_unroll_adjust): Only iterate over patterns.
>   Use FOR_EACH_SUBRTX.
> 
> Index: gcc/config/s390/s390.c
> ===
> --- gcc/config/s390/s390.c2014-10-25 09:40:37.948516349 +0100
> +++ gcc/config/s390/s390.c2014-10-25 09:51:28.229908359 +0100
> @@ -74,6 +74,7 @@ Software Foundation; either version 3, o
>  #include "tree-pass.h"
>  #include "context.h"
>  #include "builtins.h"
> +#include "rtl-iter.h"
> 
>  /* Define the specific costs for a given cpu.  */
> 
> @@ -11749,19 +11750,6 @@ s390_sched_init (FILE *file ATTRIBUTE_UN
>s390_sched_state = 0;
>  }
> 
> -/* This function checks the whole of insn X for memory references. The
> -   function always returns zero because the framework it is called
> -   from would stop recursively analyzing the insn upon a return value
> -   other than zero. The real result of this function is updating
> -   counter variable MEM_COUNT.  */
> -static int
> -check_dpu (rtx *x, unsigned *mem_count)
> -{
> -  if (*x != NULL_RTX && MEM_P (*x))
> -(*mem_count)++;
> -  return 0;
> -}
> -
>  /* This target hook implementation for TARGET_LOOP_UNROLL_ADJUST calculates
> a new number struct loop *loop should be unrolled if tuned for cpus with
> a built-in stride prefetcher.
> @@ -11784,12 +11772,13 @@ s390_loop_unroll_adjust (unsigned nunrol
> 
>/* Count the number of memory references within the loop body.  */
>bbs = get_loop_body (loop);
> +  subrtx_iterator::array_type array;
>for (i = 0; i < loop->num_nodes; i++)
> -{
> -  for (insn = BB_HEAD (bbs[i]); insn != BB_END (bbs[i]); insn = 
> NEXT_INSN (insn))
> - if (INSN_P (insn) && INSN_CODE (insn) != -1)
> -for_each_rtx_in_insn (&insn, (rtx_function) check_dpu, 
> &mem_count);
> -}
> +FOR_BB_INSNS (bbs[i], insn)
> +  if (INSN_P (insn) && INSN_CODE (insn) != -1)
> + FOR_EACH_SUBRTX (iter, array, PATTERN (insn), NONCONST)
> +   if (MEM_P (*iter))
> + mem_count += 1;
>free (bbs);
> 
>/* Prevent division by zero, and we do not need to adjust nunroll in this 
> case.  */
> 



Re: [PATCH] PR58867 ASan and UBSan tests not run for installed testing.

2014-10-27 Thread Eric Botcazou
> do you have any other (system) version of GCC, configured without
> --disable-libsanitizer?

Nope.

> 2) Make check_effective_target_fsanitize_address not only link dummy
> executable, but also run it and verify that exit code equals zero.

Yes, probably something along these lines, or restore the previous logic.

-- 
Eric Botcazou


Re: [RFC PATCH, AARCH64] Add support for -mlong-calls option

2014-10-27 Thread Yangfei (Felix)
> +/* Handle pragmas for compatibility with Intel's compilers.  */
> +#define REGISTER_TARGET_PRAGMAS() do {   
> \
> +  c_register_pragma (0, "long_calls", aarch64_pr_long_calls);
> \
> +  c_register_pragma (0, "no_long_calls", aarch64_pr_no_long_calls);  
> \
> +  c_register_pragma (0, "long_calls_off", aarch64_pr_long_calls_off);
> \
> +} while (0)
> +
>  #define FUNCTION_ARG_PADDING(MODE, TYPE) \
>(aarch64_pad_arg_upward (MODE, TYPE) ? upward : downward)


Hi,

  I updated the patch with the following two changes:
1. Add one entry in ChangeLog for this patch;
2. Enable this feature for sibling calls too.

  Assuming no issues pop up, OK for trunk?


Index: gcc/ChangeLog
===
--- gcc/ChangeLog   (revision 216558)
+++ gcc/ChangeLog   (working copy)
@@ -1,3 +1,26 @@
+2014-10-27  Felix Yang  
+   Haijian Zhang  
+
+   * config/aarch64/aarch64.opt (mlong-calls): New option.
+   * config/aarch64/aarch64.h (REGISTER_TARGET_PRAGMAS): Define.
+   * config/aarch64/aarch64.c (aarch64_set_default_type_attributes,
+   aarch64_attribute_table, aarch64_comp_type_attributes,
+   aarch64_decl_is_long_call_p, aarch64_function_in_section_p,
+   aarch64_pr_long_calls, aarch64_pr_no_long_calls,
+   aarch64_pr_long_calls_off): New functions.
+   (TARGET_SET_DEFAULT_TYPE_ATTRIBUTES): Define as
+   aarch64_set_default_type_attributes.
+   (TARGET_ATTRIBUTE_TABLE): Define as aarch64_attribute_table.
+   (TARGET_COMP_TYPE_ATTRIBUTES): Define as aarch64_comp_type_attribute.
+   (aarch64_pragma_enum): New enum.
+   (aarch64_attribute_table): New attribute table.
+   * config/aarch64/aarch64-protos.h (aarch64_pr_long_calls,
+   aarch64_pr_no_long_calls, aarch64_pr_long_calls_off): New declarations.
+   * config/aarch64/aarch64.md (sibcall, sibcall_value): Modified to
+   generate indirect call for sibling call when needed.
+   * config/aarch64/predicate.md (aarch64_call_insn_operand): Modified to
+   exclude a symbol_ref for an indirect call.
+
 2014-10-22  Richard Sandiford  
 
* lra.c (lra): Remove call to recog_init.
Index: gcc/config/aarch64/predicates.md
===
--- gcc/config/aarch64/predicates.md(revision 216558)
+++ gcc/config/aarch64/predicates.md(working copy)
@@ -27,7 +27,8 @@
 )
 
 (define_predicate "aarch64_call_insn_operand"
-  (ior (match_code "symbol_ref")
+  (ior (and (match_code "symbol_ref")
+   (match_test "!aarch64_is_long_call_p (op)"))
(match_operand 0 "register_operand")))
 
 (define_predicate "aarch64_simd_register"
Index: gcc/config/aarch64/aarch64.md
===
--- gcc/config/aarch64/aarch64.md   (revision 216558)
+++ gcc/config/aarch64/aarch64.md   (working copy)
@@ -581,11 +581,13 @@
  (use (match_operand 2 "" ""))])]
   ""
   {
-rtx pat;
+rtx callee, pat;
 
-if (!REG_P (XEXP (operands[0], 0))
-   && (GET_CODE (XEXP (operands[0], 0)) != SYMBOL_REF))
- XEXP (operands[0], 0) = force_reg (Pmode, XEXP (operands[0], 0));
+callee = XEXP (operands[0], 0);
+if (GET_CODE (callee) == SYMBOL_REF
+? aarch64_is_long_call_p (callee)
+: !REG_P (callee))
+  XEXP (operands[0], 0) = force_reg (Pmode, callee);
 
 if (operands[2] == NULL_RTX)
   operands[2] = const0_rtx;
@@ -611,11 +613,13 @@
  (use (match_operand 3 "" ""))])]
   ""
   {
-rtx pat;
+rtx callee, pat;
 
-if (!REG_P (XEXP (operands[1], 0))
-   && (GET_CODE (XEXP (operands[1], 0)) != SYMBOL_REF))
- XEXP (operands[1], 0) = force_reg (Pmode, XEXP (operands[1], 0));
+callee = XEXP (operands[1], 0);
+if (GET_CODE (callee) == SYMBOL_REF
+? aarch64_is_long_call_p (callee)
+: !REG_P (callee))
+  XEXP (operands[1], 0) = force_reg (Pmode, callee);
 
 if (operands[3] == NULL_RTX)
   operands[3] = const0_rtx;
Index: gcc/config/aarch64/aarch64.opt
===
--- gcc/config/aarch64/aarch64.opt  (revision 216558)
+++ gcc/config/aarch64/aarch64.opt  (working copy)
@@ -75,6 +75,10 @@ mlittle-endian
 Target Report RejectNegative InverseMask(BIG_END)
 Assume target CPU is configured as little endian
 
+mlong-calls
+Target Report Mask(LONG_CALLS)
+Generate call insns as indirect calls, if necessary
+
 mcmodel=
 Target RejectNegative Joined Enum(cmodel) Var(aarch64_cmodel_var) 
Init(AARCH64_CMODEL_SMALL)
 Specify the code model
Index: gcc/config/aarch64/aarch64-protos.h
===
--- gcc/config/aarch64/aarch64-protos.h (revision 216558)
+++ gcc/config/aarch64/aarch64-protos.h (working copy)
@@ -217,6 +217,10 @@ bool aarch64_use_return_insn_p

[PATCH] Fix PR63649

2014-10-27 Thread Markus Trippelsdorf
When assigning symbols to sections in ipa-comdats.c we currently
segfault when val is NULL. Fix by guarding against this case.

Tested on powerpc64-unknown-linux-gnu.
OK for trunk?

2014-10-27  Markus Trippelsdorf   

PR ipa/63649
* ipa-comdats.c (ipa_comdats): Guard against NULL.

PR ipa/63649
* g++.dg/ipa/pr63649.C: New test.

diff --git a/gcc/ipa-comdats.c b/gcc/ipa-comdats.c
index b270d9717b27..8843410545e0 100644
--- a/gcc/ipa-comdats.c
+++ b/gcc/ipa-comdats.c
@@ -317,8 +317,11 @@ ipa_comdats (void)
  && !symbol->alias
  && symbol->real_symbol_p ())
{
- tree group = *map.get (symbol);
+ tree *val = map.get (symbol);
+ if (!val)
+   continue;
 
+ group = *val;
  if (group == error_mark_node)
continue;
  if (dump_file)
diff --git a/gcc/testsuite/g++.dg/ipa/pr63649.C 
b/gcc/testsuite/g++.dg/ipa/pr63649.C
new file mode 100644
index ..1bd1d13aaaf3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr63649.C
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -std=c++11"  } */
+struct A
+{
+  typedef void Func ();
+  A () = default;
+  void *_base;
+};
+class B
+{
+  struct
+  {
+void m_fn1 (A::Func);
+  } static b;
+};
+template  class C : B
+{
+public:
+  C ();
+  static void
+  m_fn2 ()
+  {
+  }
+};
+
+A c;
+__attribute__ ((init_priority (0xfffe))) C a;
+template  C::C () { b.m_fn1 (m_fn2); }
-- 
Markus


Re: [x86] RFA: Use new rtl iterators in ix86_check_avx256_register

2014-10-27 Thread Uros Bizjak
On Sat, Oct 25, 2014 at 11:01 AM, Richard Sandiford
 wrote:
> This is part of a series to remove uses of for_each_rtx from the ports.
>
> Tested by making sure there were no code changes for gcc.dg, gcc.c-torture
> and g++.dg for x86_64-linux-gnu, and also by a boostrap.  OK to install?
>
> Thanks,
> Richard
>
>
> gcc/
> * config/i386/i386.c: Include rtl-iter.h
> (ix86_check_avx256_register): Take a const_rtx and return a bool.
> (ix86_check_avx256_stores): Update call accordingly.
> (ix86_avx_u128_mode_entry, ix86_avx_u128_mode_exit): Likewise.
> (ix86_avx_u128_mode_needed): Likewise.  Use FOR_EACH_SUBRTX.

OK.

Thanks,
Uros.


Re: [x86] RFA: Use new rtl iterators in x86_extended_reg_mentioned_p

2014-10-27 Thread Uros Bizjak
On Sat, Oct 25, 2014 at 11:03 AM, Richard Sandiford
 wrote:
> This is part of a series to remove uses of for_each_rtx from the ports.
>
> Tested by making sure there were no code changes for gcc.dg, gcc.c-torture
> and g++.dg for x86_64-linux-gnu, and also by a boostrap.  OK to install?
>
> Thanks,
> Richard
>
>
> gcc/
> * config/i386/i386.c (extended_reg_mentioned_1): Delete.
> (x86_extended_reg_mentioned_p): Use FOR_EACH_SUBRTX.

OK.

Thanks,
Uros.


Re: [x86] RFA: Use new rtl iterators in find_constant

2014-10-27 Thread Uros Bizjak
On Sat, Oct 25, 2014 at 11:07 AM, Richard Sandiford
 wrote:
> This is part of a series to remove uses of for_each_rtx from the ports.
> It's a bit hard to read, so I've attached a -b version too.
>
> Tested by making sure there were no code changes for gcc.dg, gcc.c-torture
> and g++.dg for x86_64-linux-gnu, and also by a boostrap.  OK to install?
>
> Thanks,
> Richard
>
>
> gcc/
> * config/i386/i386.c (find_constant_1): Delete.
> (find_constant): Use FOR_EACH_SUBRTX.

OK.

Thanks,
Uros.


Re: [x86] RFA: Use new rtl iterators in ix86_loop_unroll_adjust

2014-10-27 Thread Uros Bizjak
On Sat, Oct 25, 2014 at 11:11 AM, Richard Sandiford
 wrote:
> This is part of a series to remove uses of for_each_rtx from the ports.
>
> It looks like this code should be iterating over the pattern rather than
> the full insn, or do MEMs in notes really count?  If we iterate over the
> pattern then there should be no need for the test for null.
>
> Tested by making sure there were no code changes for gcc.dg, gcc.c-torture
> and g++.dg for x86_64-linux-gnu, and also by a boostrap.  OK to install?
>
> Thanks,
> Richard
>
>
> gcc/
> * config/i386/i386.c (ix86_loop_memcount): Delete.
> (ix86_loop_unroll_adjust): Use FOR_EACH_SUBRTX.


Please also move the following comment to new place instead of removing it:

-/* This function gives out the number of memory references.
-   This value determines the unrolling factor for
-   bdver3 and bdver4 architectures. */

OK with this change.

Thanks,
Uros.


Re: [spu] RFA: Use new rtl iterators in ea_symbol_ref_p

2014-10-27 Thread Ulrich Weigand
Richard Sandiford wrote:

> gcc/
>   * config/spu/spu.c: Include rtl-iter.h
>   (ea_symbol_ref): Replace with...
>   (ea_symbol_ref_p): ...this new function.
>   (spu_legitimate_address_p): Update call accordingly.
>   (spu_legitimate_constant_p): Likewise.  Use FOR_EACH_SUBRTX.

This is OK.

Thanks,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  ulrich.weig...@de.ibm.com



Re: [PATCH 6/n] OpenMP 4.0 offloading infrastructure: option handling

2014-10-27 Thread Bernd Schmidt

On 10/15/2014 03:52 PM, Richard Biener wrote:


I'd say that we eventually should have a type flag that says
"this is a va-list type".  If we really need to know that - because
I don't understand why we need to do this - the context should
tell us exactly whether we deal with a va_list object or not ...


How about just an internal attribute?


Bernd




[Ada] Fix overflow with entry queue

2014-10-27 Thread Eric Botcazou
This is a regression present on the mainline and 4.9 branch: declaring an 
array of entries of a protected object results in an size overflow for the 
array.  There is a known overflow issue with entry families for protected 
objects, which is papered over in the FE (see the top of Exp_Ch9), but the 
trick has been silently disabled.

Tested on x86_64-suse-linux, applied on mainline and 4.9 branch.


2014-10-27  Eric Botcazou  

* gcc-interface/decl.c (gnat_to_gnu_entity) : Remove
superfluous computation for the max size.
: Likewise.  Make sure that the max size calculation
does not overflow at compile time.


2014-10-27  Eric Botcazou  

* gnat.dg/entry_queues2.adb: New test.


-- 
Eric BotcazouIndex: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 216612)
+++ gcc-interface/decl.c	(working copy)
@@ -2127,11 +2127,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 		tree gnu_max
 		  = convert (sizetype, TYPE_MAX_VALUE (gnu_index_type));
 		tree gnu_this_max
-		  = size_binop (MAX_EXPR,
-size_binop (PLUS_EXPR, size_one_node,
-	size_binop (MINUS_EXPR,
-			gnu_max, gnu_min)),
-size_zero_node);
+		  = size_binop (PLUS_EXPR, size_one_node,
+size_binop (MINUS_EXPR, gnu_max, gnu_min));
 
 		if (TREE_CODE (gnu_this_max) == INTEGER_CST
 		&& TREE_OVERFLOW (gnu_this_max))
@@ -2464,20 +2461,26 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 		gnu_max_size = NULL_TREE;
 		  else
 		{
-		  tree gnu_this_max
-			= size_binop (MAX_EXPR,
-  size_binop (PLUS_EXPR, size_one_node,
-		  size_binop (MINUS_EXPR,
-			  gnu_base_max,
-			  gnu_base_min)),
-  size_zero_node);
+		  tree gnu_this_max;
 
-		  if (TREE_CODE (gnu_this_max) == INTEGER_CST
-			  && TREE_OVERFLOW (gnu_this_max))
-			gnu_max_size = NULL_TREE;
+		  /* Use int_const_binop if the bounds are constant to
+			 avoid any unwanted overflow.  */
+		  if (TREE_CODE (gnu_base_min) == INTEGER_CST
+			  && TREE_CODE (gnu_base_max) == INTEGER_CST)
+			gnu_this_max
+			  = int_const_binop (PLUS_EXPR, size_one_node,
+	 int_const_binop (MINUS_EXPR,
+			  gnu_base_max,
+			  gnu_base_min));
 		  else
-			gnu_max_size
-			  = size_binop (MULT_EXPR, gnu_max_size, gnu_this_max);
+			gnu_this_max
+			  = size_binop (PLUS_EXPR, size_one_node,
+	size_binop (MINUS_EXPR,
+		gnu_base_max,
+		gnu_base_min));
+
+		  gnu_max_size
+			= size_binop (MULT_EXPR, gnu_max_size, gnu_this_max);
 		}
 		}
 
-- { dg-do compile }

procedure Entry_Queues2 is

F1 : Integer := 17;

generic
type T is limited private;
procedure Check;

procedure Check is
begin
declare
type Poe is new T;
begin
declare
type Arr is array (1 .. 2) of Poe;
X : Arr;
pragma Unreferenced (X);
begin
null;
end;
end;
end;

begin

declare
protected type Poe (D3 : Integer := F1) is
entry E (D3 .. F1);-- F1 evaluated
end Poe;
protected body Poe is
entry E (for I in D3 .. F1) when True is
begin
null;
end E;
end Poe;

procedure Chk is new Check (Poe);

begin
Chk;
end;

end;


Ping: PR 63340: Avoid harmful union classes in ira-costs.c

2014-10-27 Thread Richard Sandiford
Two-patch IRA series to fix PR 63340:

https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02636.html
https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02637.html

It also fixes PR 63403.

Thanks,
Richard





Re: [Patch] Cleanup widest_int_mode_for_size

2014-10-27 Thread James Greenhalgh
On Tue, Sep 30, 2014 at 09:37:12AM +0100, James Greenhalgh wrote:
> *ping*

*pingx2*

Cheers,
James

> 
> Thanks,
> James
> 
> On Tue, Sep 23, 2014 at 10:17:21AM +0100, James Greenhalgh wrote:
> >
> > Hi,
> >
> > The comment on widest_int_mode_for_size claims that it returns the
> > widest integer mode no wider than size. The implementation looks more
> > like it finds the widest integer mode smaller than size. Everywhere it
> > is used, the mode it is looking for is ultimately checked against an
> > expected alignment or is used for heuristics that should be thinking
> > about that check, so pull it in to here.
> >
> > Throughout expr.c corrections are made for this fact - adding one to
> > the size passed to this function. This feels a bit backwards to me.
> >
> > This patch fixes that, and then fixes the fallout throughout expr.c.
> > Generally, this means simplifying a bunch of move_by_pieces style copy
> > code.
> >
> > Bootstrapped on x86_64, arm and AArch64 with no issues.
> >
> > OK for trunk?
> >
> > Thanks,
> > James
> >
> > 2014-09-23  James Greenhalgh  
> >
> >   * expr.c (MOVE_BY_PIECES_P): Remove off-by-one correction to
> >   move_by_pieces_ninsns.
> >   (CLEAR_BY_PIECES_P): Likewise.
> >   (SET_BY_PIECES_P): Likewise.
> >   (STORE_BY_PIECES_P): Likwise.
> >   (widest_int_mode_for_size): Return the widest mode in which the
> >   given size fits.
> >   (move_by_pieces): Remove off-by-one correction for max_size,
> >   simplify copy loop body.
> >   (move_by_pieces_ninsns): Simplify copy body.
> >   (can_store_by_pieces): Remove off-by-one correction for max_size,
> >   simplify copy body.
> >   (store_by_pieces_1): Likewise.
> >
> 
> > diff --git a/gcc/expr.c b/gcc/expr.c
> > index a6233f3..0af9b9a 100644
> > --- a/gcc/expr.c
> > +++ b/gcc/expr.c
> > @@ -161,7 +161,7 @@ static void write_complex_part (rtx, rtx, bool);
> > to perform a structure copy.  */
> >  #ifndef MOVE_BY_PIECES_P
> >  #define MOVE_BY_PIECES_P(SIZE, ALIGN) \
> > -  (move_by_pieces_ninsns (SIZE, ALIGN, MOVE_MAX_PIECES + 1) \
> > +  (move_by_pieces_ninsns (SIZE, ALIGN, MOVE_MAX_PIECES) \
> > < (unsigned int) MOVE_RATIO (optimize_insn_for_speed_p ()))
> >  #endif
> >
> > @@ -169,7 +169,7 @@ static void write_complex_part (rtx, rtx, bool);
> > called to clear storage.  */
> >  #ifndef CLEAR_BY_PIECES_P
> >  #define CLEAR_BY_PIECES_P(SIZE, ALIGN) \
> > -  (move_by_pieces_ninsns (SIZE, ALIGN, STORE_MAX_PIECES + 1) \
> > +  (move_by_pieces_ninsns (SIZE, ALIGN, STORE_MAX_PIECES) \
> > < (unsigned int) CLEAR_RATIO (optimize_insn_for_speed_p ()))
> >  #endif
> >
> > @@ -177,7 +177,7 @@ static void write_complex_part (rtx, rtx, bool);
> > called to "memset" storage with byte values other than zero.  */
> >  #ifndef SET_BY_PIECES_P
> >  #define SET_BY_PIECES_P(SIZE, ALIGN) \
> > -  (move_by_pieces_ninsns (SIZE, ALIGN, STORE_MAX_PIECES + 1) \
> > +  (move_by_pieces_ninsns (SIZE, ALIGN, STORE_MAX_PIECES) \
> > < (unsigned int) SET_RATIO (optimize_insn_for_speed_p ()))
> >  #endif
> >
> > @@ -185,7 +185,7 @@ static void write_complex_part (rtx, rtx, bool);
> > called to "memcpy" storage when the source is a constant string.  */
> >  #ifndef STORE_BY_PIECES_P
> >  #define STORE_BY_PIECES_P(SIZE, ALIGN) \
> > -  (move_by_pieces_ninsns (SIZE, ALIGN, STORE_MAX_PIECES + 1) \
> > +  (move_by_pieces_ninsns (SIZE, ALIGN, STORE_MAX_PIECES) \
> > < (unsigned int) MOVE_RATIO (optimize_insn_for_speed_p ()))
> >  #endif
> >
> > @@ -801,18 +801,23 @@ alignment_for_piecewise_move (unsigned int 
> > max_pieces, unsigned int align)
> >return align;
> >  }
> >
> > -/* Return the widest integer mode no wider than SIZE.  If no such mode
> > -   can be found, return VOIDmode.  */
> > +/* Return the widest integer mode no wider than SIZE which can be accessed
> > +   at the given ALIGNMENT.  If no such mode can be found, return VOIDmode.
> > +   If SIZE would fit exactly in a mode, return that mode. */
> >
> >  static enum machine_mode
> > -widest_int_mode_for_size (unsigned int size)
> > +widest_int_mode_for_size_and_alignment (unsigned int size,
> > + unsigned int align)
> >  {
> >enum machine_mode tmode, mode = VOIDmode;
> >
> >for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT);
> > tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode))
> > -if (GET_MODE_SIZE (tmode) < size)
> > -  mode = tmode;
> > +{
> > +  if (GET_MODE_SIZE (tmode) <= size
> > +   && align >= GET_MODE_ALIGNMENT (mode))
> > + mode = tmode;
> > +}
> >
> >return mode;
> >  }
> > @@ -855,7 +860,7 @@ move_by_pieces (rtx to, rtx from, unsigned 
> > HOST_WIDE_INT len,
> >enum machine_mode to_addr_mode;
> >enum machine_mode from_addr_mode = get_address_mode (from);
> >rtx to_addr, from_addr = XEXP (from, 0);
> > -  unsigned int max_size = MOVE_MAX_PIECES + 1;
> > +  unsigned int max_size = MOVE_MAX_PIECES;
> >e

[Ada] Fix ICE on instantiated packed array type

2014-10-27 Thread Eric Botcazou
This fixes an assertion failure in relate_alias_sets on an instantiated packed 
array type, because of a missing test before invoking the function.

Tested on x86_64-suse-linux, applied on mainline.


2014-10-27  Eric Botcazou  

* gcc-interface/decl.c (gnat_to_gnu_entity): Apply special treatment
of derived packed array types to constrained subtypes only.


2014-10-27  Eric Botcazou  

* gnat.dg/specs/pack10.ads: New test.
* gnat.dg/specs/pack10_pkg.ad[sb]: New helper.


-- 
Eric Botcazou-- { dg-do compile }

with Pack10_Pkg; use Pack10_Pkg;

package Pack10 is

   type Boolean_Vector is array (Positive range <>) of Boolean;

   type Packed_Boolean_Vector is new Boolean_Vector;
   pragma Pack (Packed_Boolean_Vector);

   procedure My_Proc is new Proc (Packed_Boolean_Vector);

end Pack10;
package body Pack10_Pkg is

   procedure Proc is begin null; end;

end Pack10_Pkg;
-- { dg-excess-errors "cannot generate code" }

package Pack10_Pkg is

   generic
  type Vector_Type (<>) is private;
   procedure Proc;

end Pack10_Pkg;
Index: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 216725)
+++ gcc-interface/decl.c	(working copy)
@@ -5083,8 +5083,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
   if (Is_Derived_Type (gnat_entity) && !type_annotate_only)
 	{
 	  Entity_Id gnat_parent_type = Underlying_Type (Etype (gnat_entity));
-	  /* For packed array subtypes, the implementation type is used.  */
+	  /* For constrained packed array subtypes, the implementation type is
+	 used instead of the nominal type.  */
 	  if (kind == E_Array_Subtype
+	  && Is_Constrained (gnat_entity)
 	  && Present (Packed_Array_Impl_Type (gnat_parent_type)))
 	gnat_parent_type = Packed_Array_Impl_Type (gnat_parent_type);
 	  relate_alias_sets (gnu_type, gnat_to_gnu_type (gnat_parent_type),


Re: [PATCH][6/n] Merge from match-and-simplify, make forwprop fold all stmts

2014-10-27 Thread Richard Biener
On Fri, 24 Oct 2014, Jeff Law wrote:

> On 10/24/14 07:16, Richard Biener wrote:
> > 
> > This patch makes GIMPLE forwprop fold all statements, following
> > single-use SSA edges only (as suggested by Jeff and certainly
> > how this will regress the least until we replace manual
> > simplification code that does not restrict itself this way).
> > 
> > forwprop is run up to 4 times at the moment (once only for -Og,
> > not at all for -O0), which still seems reasonable.  IMHO the
> > forwprop pass immediately after inlining is somewhat superfluous,
> > it was added there just for its ADDR_EXPR propagation.  We should
> > eventually split this pass into two.
> > 
> > Note that just folding what we propagated into (like the SSA
> > propagators do during substitute-and-fold phase) will miss
> > cases where we propagate into a stmt feeding the one we could
> > simplify.  Unless we always fold all single-use (and their use)
> > stmts we have to fold everything from time to time.  Changing
> > how / when we fold stuff is certainly sth to look after with
> > fold_stmt now being able to follow SSA edges.
> > 
> > Bootstrapped on x86_64-unknown-linux-gnu, testing still in progress.
> > 
> >  From earlier testing I remember I need to adjust a few testcases
> > that don't expect the early folding - notably two strlenopt cases
> > (previously XFAILed but then PASSed again).
> > 
> > I also expect to massage the single-use heuristic as I get to
> > merging the patterns I added for the various forwprop manual
> > pattern matchings to trunk (a lot of them do not restrict themselves
> > this way).
> > 
> > Does this otherwise look ok?
> > 
> > Thanks,
> > Richard.
> > 
> > 2014-10-24  Richard Biener  
> > 
> > * tree-ssa-forwprop.c: Include tree-cfgcleanup.h and tree-into-ssa.h.
> > (lattice): New global.
> > (fwprop_ssa_val): New function.
> > (fold_all_stmts): Likewise.
> > (pass_forwprop::execute): Finally fold all stmts.
> Seems reasonable.  After all, we can iterate on the single-use heuristic.

The following is what I applied - two testcases needed adjustments,
the forwprop-6.c one already has in its comments that the transform
we look for happens during CCP1 already.  strlenopt-8.c fails to
optimize a strlen because it cannot handle 2-byte loads/stores
in its analysis and we now inline-expand the 2-byte memcpy earlier.

Thanks,
Richard.

2014-10-27  Richard Biener  

* tree-ssa-forwprop.c: Include tree-cfgcleanup.h and tree-into-ssa.h.
(lattice): New global.
(fwprop_ssa_val): New function.
(fold_all_stmts): Likewise.
(pass_forwprop::execute): Finally fold all stmts.

* gcc.dg/tree-ssa/forwprop-6.c: Scan ccp1 dump instead.
* gcc.dg/strlenopt-8.c: Adjust and XFAIL for non_strict_align
target due to memcpy inline-expansion.

Index: gcc/tree-ssa-forwprop.c
===
*** gcc/tree-ssa-forwprop.c.orig2014-10-20 14:39:23.998954586 +0200
--- gcc/tree-ssa-forwprop.c 2014-10-27 12:07:48.489693195 +0100
*** along with GCC; see the file COPYING3.
*** 54,59 
--- 54,61 
  #include "tree-ssa-propagate.h"
  #include "tree-ssa-dom.h"
  #include "builtins.h"
+ #include "tree-cfgcleanup.h"
+ #include "tree-into-ssa.h"
  
  /* This pass propagates the RHS of assignment statements into use
 sites of the LHS of the assignment.  It's basically a specialized
*** simplify_mult (gimple_stmt_iterator *gsi
*** 3586,3591 
--- 3588,3680 
  
return false;
  }
+ 
+ 
+ /* Const-and-copy lattice for fold_all_stmts.  */
+ static vec lattice;
+ 
+ /* Primitive "lattice" function for gimple_simplify.  */
+ 
+ static tree
+ fwprop_ssa_val (tree name)
+ {
+   /* First valueize NAME.  */
+   if (TREE_CODE (name) == SSA_NAME
+   && SSA_NAME_VERSION (name) < lattice.length ())
+ {
+   tree val = lattice[SSA_NAME_VERSION (name)];
+   if (val)
+   name = val;
+ }
+   /* If NAME is not the only use signal we don't want to continue
+  matching into its definition.  */
+   if (TREE_CODE (name) == SSA_NAME
+   && !has_single_use (name))
+ return NULL_TREE;
+   return name;
+ }
+ 
+ /* Fold all stmts using fold_stmt following only single-use chains
+and using a simple const-and-copy lattice.  */
+ 
+ static bool
+ fold_all_stmts (struct function *fun)
+ {
+   bool cfg_changed = false;
+ 
+   /* Combine stmts with the stmts defining their operands.  Do that
+  in an order that guarantees visiting SSA defs before SSA uses.  */
+   lattice.create (num_ssa_names);
+   lattice.quick_grow_cleared (num_ssa_names);
+   int *postorder = XNEWVEC (int, n_basic_blocks_for_fn (fun));
+   int postorder_num = inverted_post_order_compute (postorder);
+   for (int i = 0; i < postorder_num; ++i)
+ {
+   basic_block bb = BASIC_BLOCK_FOR_FN (fun, postorder[i]);
+   for (gimple_stmt_iterator gsi = gsi_start_bb (bb);
+  !gsi_e

[Ada] Fix ICE on string concatenation with -gnatd.h

2014-10-27 Thread Eric Botcazou
This fixes an ICE on a string concatenation with the -gnatd.h switch, which 
causes TREE_PUBLIC to be set on a local temporary 

Tested on x86_64-suse-linux, applied on mainline.


2014-10-27  Eric Botcazou  

* gcc-interface/utils.c (create_var_decl_1): For a variable declared
in the unit, set TREE_PUBLIC only if it has static storage duration.


2014-10-27  Eric Botcazou  

* gnat.dg/specs/concat1.ads: New test.
* gnat.dg/specs/concat1_pkg.ads: New helper.


-- 
Eric BotcazouIndex: gcc-interface/utils.c
===
--- gcc-interface/utils.c	(revision 216612)
+++ gcc-interface/utils.c	(working copy)
@@ -2309,25 +2309,30 @@ create_var_decl_1 (tree var_name, tree a
 		   bool static_flag, bool const_decl_allowed_p,
 		   struct attrib *attr_list, Node_Id gnat_node)
 {
-  /* Whether the initializer is a constant initializer.  At the global level
- or for an external object or an object to be allocated in static memory,
- we check that it is a valid constant expression for use in initializing
- a static variable; otherwise, we only check that it is constant.  */
-  bool init_const
-= (var_init != 0
+  /* Whether the object has static storage duration, either explicitly or by
+ virtue of being declared at the global level.  */
+  const bool static_storage = static_flag || global_bindings_p ();
+
+  /* Whether the initializer is constant: for an external object or an object
+ with static storage duration, we check that the initializer is a valid
+ constant expression for initializing a static variable; otherwise, we
+ only check that it is constant.  */
+  const bool init_const
+= (var_init
&& gnat_types_compatible_p (type, TREE_TYPE (var_init))
-   && (global_bindings_p () || extern_flag || static_flag
-	   ? initializer_constant_valid_p (var_init, TREE_TYPE (var_init)) != 0
+   && (extern_flag || static_storage
+	   ? initializer_constant_valid_p (var_init, TREE_TYPE (var_init))
+	 != NULL_TREE
 	   : TREE_CONSTANT (var_init)));
 
   /* Whether we will make TREE_CONSTANT the DECL we produce here, in which
- case the initializer may be used in-lieu of the DECL node (as done in
+ case the initializer may be used in lieu of the DECL node (as done in
  Identifier_to_gnu).  This is useful to prevent the need of elaboration
- code when an identifier for which such a decl is made is in turn used as
- an initializer.  We used to rely on CONST vs VAR_DECL for this purpose,
- but extra constraints apply to this choice (see below) and are not
- relevant to the distinction we wish to make. */
-  bool constant_p = const_flag && init_const;
+ code when an identifier for which such a DECL is made is in turn used
+ as an initializer.  We used to rely on CONST_DECL vs VAR_DECL for this,
+ but extra constraints apply to this choice (see below) and they are not
+ relevant to the distinction we wish to make.  */
+  const bool constant_p = const_flag && init_const;
 
   /* The actual DECL node.  CONST_DECL was initially intended for enumerals
  and may be used for scalars in general but not for aggregates.  */
@@ -2347,19 +2352,24 @@ create_var_decl_1 (tree var_name, tree a
   || (type_annotate_only && var_init && !TREE_CONSTANT (var_init)))
 var_init = NULL_TREE;
 
-  /* At the global level, an initializer requiring code to be generated
- produces elaboration statements.  Check that such statements are allowed,
- that is, not violating a No_Elaboration_Code restriction.  */
-  if (global_bindings_p () && var_init != 0 && !init_const)
+  /* At the global level, a non-constant initializer generates elaboration
+ statements.  Check that such statements are allowed, that is to say,
+ not violating a No_Elaboration_Code restriction.  */
+  if (var_init && !init_const && global_bindings_p ())
 Check_Elaboration_Code_Allowed (gnat_node);
 
   DECL_INITIAL  (var_decl) = var_init;
   TREE_READONLY (var_decl) = const_flag;
   DECL_EXTERNAL (var_decl) = extern_flag;
-  TREE_PUBLIC   (var_decl) = public_flag || extern_flag;
   TREE_CONSTANT (var_decl) = constant_p;
-  TREE_THIS_VOLATILE (var_decl) = TREE_SIDE_EFFECTS (var_decl)
-= TYPE_VOLATILE (type);
+
+  /* We need to allocate static storage for an object with static storage
+ duration if it isn't external.  */
+  TREE_STATIC (var_decl) = !extern_flag && static_storage;
+
+  /* The object is public if it is external or if it is declared public
+ and has static storage duration.  */
+  TREE_PUBLIC (var_decl) = extern_flag || (public_flag && static_storage);
 
   /* Ada doesn't feature Fortran-like COMMON variables so we shouldn't
  try to fiddle with DECL_COMMON.  However, on platforms that don't
@@ -2371,12 +2381,6 @@ create_var_decl_1 (tree var_name, tree a
   && !have_global_bss_p ())
 DECL_COMMON (var_decl) = 1;
 
-  /* At the global binding lev

[Ada] Minor gigi tweaks

2014-10-27 Thread Eric Botcazou
Tested on x86_64-suse-linux, applied on mainline.


2014-10-27  Eric Botcazou  

* gcc-interface/trans.c (gnat_to_gnu) : Minor tweaks.


-- 
Eric BotcazouIndex: gcc-interface/trans.c
===
--- gcc-interface/trans.c	(revision 216612)
+++ gcc-interface/trans.c	(working copy)
@@ -5330,8 +5330,8 @@ gnat_to_gnu (Node_Id gnat_node)
 case N_Real_Literal:
   gnu_result_type = get_unpadded_type (Etype (gnat_node));
 
-  /* If this is of a fixed-point type, the value we want is the
-	 value of the corresponding integer.  */
+  /* If this is of a fixed-point type, the value we want is the value of
+	 the corresponding integer.  */
   if (IN (Ekind (Underlying_Type (Etype (gnat_node))), Fixed_Point_Kind))
 	{
 	  gnu_result = UI_To_gnu (Corresponding_Integer_Value (gnat_node),
@@ -5343,10 +5343,9 @@ gnat_to_gnu (Node_Id gnat_node)
 	{
 	  Ureal ur_realval = Realval (gnat_node);
 
-	  /* First convert the real value to a machine number if it isn't
-	 already. That forces BASE to 2 for non-zero values and simplifies
- the rest of our logic.  */
-
+	  /* First convert the value to a machine number if it isn't already.
+	 That will force the base to 2 for non-zero values and simplify
+	 the rest of the logic.  */
 	  if (!Is_Machine_Number (gnat_node))
 	ur_realval
 	  = Machine (Base_Type (Underlying_Type (Etype (gnat_node))),
@@ -5358,13 +5357,11 @@ gnat_to_gnu (Node_Id gnat_node)
 	{
 	  REAL_VALUE_TYPE tmp;
 
-	  gnu_result
-		= UI_To_gnu (Numerator (ur_realval), gnu_result_type);
+	  gnu_result = UI_To_gnu (Numerator (ur_realval), gnu_result_type);
 
 	  /* The base must be 2 as Machine guarantees this, so we scale
- the value, which we know can fit in the mantissa of the type
- (hence the use of that type above).  */
-
+		 the value, which we know can fit in the mantissa of the type
+		 (hence the use of that type above).  */
 	  gcc_assert (Rbase (ur_realval) == 2);
 	  real_ldexp (&tmp, &TREE_REAL_CST (gnu_result),
 			  - UI_To_Int (Denominator (ur_realval)));


Re: [AArch64] Add --enable-fix-cortex-a53-835769 configure-time option

2014-10-27 Thread Gerald Pfeifer
Hi Kyrill,

On Monday 2014-10-20 10:41, Kyrill Tkachov wrote:
>> Thank you.  Can you please also update gcc-5/changes.html on the
>> web side of things?
> Sure, but I'm not sure how to get access to the web pages cvs.
> Could you point me to the magic runes please?

does https://gcc.gnu.org/about.html help?

I'd really love to migrate the pages to SVN as well, but haven't
had much time lately and importing the tree with history also seems
a bit tricky.  Any volunteers for that?

Gerald


Re: [PATCH v2 0-6/11] Fix PR/61114, make direct vector reductions endianness-neutral

2014-10-27 Thread Richard Biener
On Fri, Oct 24, 2014 at 5:17 PM, Matthew Fortune
 wrote:
> Alan Lawrence  writes:
>> Patches 7-11 migrate migrate ARM, x86, IA64 (I think), and mostly PowerPC,
>> to
>> the new reduc_(plus|[us](min|max))_scal_optab. I have not managed to work
>> out
>> how to do the same for MIPS (specifically what I need to add to
>> mips_expand_vec_reduc), and have had no response from the maintainers, so
>> am
>
> Sorry, I was looking at this but failed to send an email saying so. The lack
> of vec_extract appears to be the stumbling point here so at the very least
> we need to add a naïve version of that I believe.
>
>> (2) also renaming reduc_..._scal_optab back to reduc_..._optab; would
>> break the
>> MIPS backend if something were not done with it's existing patterns.
>
> I suspect we can deal with this in time to make a rename OK.
>
> One thing occurred to me about this change in general which is that on the
> whole the reduction to a scalar seems good for an epilogue but is there
> a problem if the result is then replicated across a vector for further
> processing. I.e. a vector is reduced to a scalar, which moves the value
> from a SIMD register to a GP register (because scalar modes are not
> supported in SIMD registers generally) and then gets moved back to a
> SIMD register to form part of a new vector? Would you expect the
> redundant moves to get eliminated?

Combine should be able to do this if you help it (it of course depends
on what your actual processor instruction doing the reduction does).

Richard.

> Thanks,
> Matthew


Re: [AArch64] Add --enable-fix-cortex-a53-835769 configure-time option

2014-10-27 Thread Kyrill Tkachov


On 27/10/14 11:41, Gerald Pfeifer wrote:

Hi Kyrill,

On Monday 2014-10-20 10:41, Kyrill Tkachov wrote:

Thank you.  Can you please also update gcc-5/changes.html on the
web side of things?

Sure, but I'm not sure how to get access to the web pages cvs.
Could you point me to the magic runes please?

does https://gcc.gnu.org/about.html help?


Thanks, that helps. I'll whip something up.

Kyrill



I'd really love to migrate the pages to SVN as well, but haven't
had much time lately and importing the tree with history also seems
a bit tricky.  Any volunteers for that?

Gerald






Re: [PATCH 6/n] OpenMP 4.0 offloading infrastructure: option handling

2014-10-27 Thread Ilya Verbin
On 24 Oct 20:33, Jakub Jelinek wrote:
> On Fri, Oct 24, 2014 at 10:29:50PM +0400, Ilya Verbin wrote:
> > diff --git a/gcc/opts.c b/gcc/opts.c
> > index 9b2e1af..d1a626c 100644
> > --- a/gcc/opts.c
> > +++ b/gcc/opts.c
> > @@ -1732,6 +1732,13 @@ common_handle_option (struct gcc_options *opts,
> >/* Deferred.  */
> >break;
> >  
> > +#ifndef ACCEL_COMPILER
> 
> ifndef ?  I would have expected ifdef.
> 
> > +case OPT_foffload_abi_:
> > +  error_at (loc, "-foffload-abi option can be specified only for "
> > +   "offload compiler");
> > +  break;
> > +#endif
> > +
> >  case OPT_fpack_struct_:
> >if (value <= 0 || (value & (value - 1)) || value > 16)
> > error_at (loc,

-foffload-abi option is intended only for the offload compiler, but we can't put
the option under ifdef in common.opt, therefore I added error_at under ifndef.

  -- Ilya


RE: [PATCH] Fix PR63266: Keep track of impact of sign extension in bswap

2014-10-27 Thread Thomas Preud'homme
> From: Christophe Lyon [mailto:christophe.l...@linaro.org]
> Sent: Sunday, October 26, 2014 4:40 PM
> I tried to modify check_effective_target_bswap
> and added:
> +   } else {
> +   if { [istarget arm*-*-*]
> +&& [check_no_compiler_messages_nocache arm_v6_or_later
> object {
> +#if __ARM_ARCH < 6
> +#error not armv6 or later
> +#endif
> +int i;
> +} ""] } {
> +   set et_bswap_saved 1
> +   }
> since the rev* instructions appeared in v6.
> 
> Regarding the testsuite, it moves the tests to UNSUPPORTED vs a mix of
> PASS/FAIL/XFAIL

[SNIP PASS/FAIL/XFAIL changes]

> 
> The PASS seems not very informative, so it may not be a problem to
> loose these few PASS/XFAIL.

Agreed. A FAIL would only mean that the test was badly written. Only
the dump is relevant to tell whether the bswap pass did its job or not.

> 
> We can also explicitly skip optimize-bswaphi-1 when ARM_ARCH < 6.
> 
> Not sure what's preferred?

I prefer changing the effective target as it could be reused for some other 
tests
eventually. It also reflects better the reason why the test is disabled: no 
16-bit
bswap.

Best regards,

Thomas






Re: [PATCH 3/4] Add libgomp plugin for Intel MIC

2014-10-27 Thread Ilya Verbin
On 24 Oct 17:18, Jakub Jelinek wrote:
> On Fri, Oct 24, 2014 at 07:08:44PM +0400, Ilya Verbin wrote:
> > On 24 Oct 16:35, Jakub Jelinek wrote:
> > > On Thu, Oct 23, 2014 at 07:41:12PM +0400, Ilya Verbin wrote:
> > > > > malloc can fail, SIGSEGV in response to that is not desirable.
> > > > > Can't you fallback to alloca, or use just alloca, or use alloca
> > > > > with malloc fallback?
> > > > 
> > > > I replaced it with alloca.
> > > 
> > > There is a risk if a suid or otherwise priviledge escalated program
> > > uses it and attacker passes huge env vars.
> > > Perhaps use alloca if it is <= 2KB and malloc otherwise, and in that case
> > > if malloc fails, just do a fatal error?
> > 
> > Why is this more preferable than just a malloc + fatal error?
> > This function is executed only once at plugin initialization, therefore no 
> > real
> > performance gain could be achived.
> 
> Even if it is executed once, using malloc for short env vars that will be
> the 99% of all cases sounds like waste of resources to me.
> You already know the strlen of the vars, so it is just a matter of
> comparing that and setting a bool flag.

Done.  Is it ok?

Thanks,
  -- Ilya


---

diff --git a/liboffloadmic/configure.ac b/liboffloadmic/configure.ac
index fb575b3..81fae8f 100644
--- a/liboffloadmic/configure.ac
+++ b/liboffloadmic/configure.ac
@@ -42,6 +42,7 @@ AC_PROG_CC
 AC_PROG_CXX
 AC_CONFIG_FILES([Makefile liboffloadmic_host.spec liboffloadmic_target.spec])
 AM_ENABLE_MULTILIB(, ..)
+AC_CONFIG_SUBDIRS(plugin)
 AC_FUNC_ALLOCA
 AC_CHECK_HEADERS([mm_malloc.h], [], [AC_MSG_ERROR(["Couldn't find 
mm_malloc.h"])])
 AC_CHECK_FUNCS([__secure_getenv secure_getenv])
diff --git a/liboffloadmic/plugin/Makefile.am b/liboffloadmic/plugin/Makefile.am
new file mode 100644
index 000..0baf70d
--- /dev/null
+++ b/liboffloadmic/plugin/Makefile.am
@@ -0,0 +1,123 @@
+# Plugin for offload execution on Intel MIC devices.
+#
+# Copyright (C) 2014 Free Software Foundation, Inc.
+#
+# Contributed by Ilya Verbin  and
+# Andrey Turetskiy .
+#
+# This file is part of the GNU OpenMP Library (libgomp).
+#
+# Libgomp is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+# more details.
+#
+# Under Section 7 of GPL version 3, you are granted additional
+# permissions described in the GCC Runtime Library Exception, version
+# 3.1, as published by the Free Software Foundation.
+#
+# You should have received a copy of the GNU General Public License and
+# a copy of the GCC Runtime Library Exception along with this program;
+# see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+# .
+
+
+AUTOMAKE_OPTIONS = foreign
+ACLOCAL_AMFLAGS = -I ../.. -I ../../config
+
+# Directories
+build_dir = $(top_builddir)
+source_dir = $(top_srcdir)
+coi_inc_dir = $(top_srcdir)/../include/coi
+myo_inc_dir = $(top_srcdir)/../include/myo
+libgomp_src_dir = $(top_srcdir)/../../libgomp
+libgomp_dir = $(build_dir)/../../libgomp
+liboffload_src_dir = $(top_srcdir)/../runtime
+liboffload_dir = $(top_builddir)/..
+
+# May be used by toolexeclibdir.
+gcc_version := $(shell cat $(top_srcdir)/../../gcc/BASE-VER)
+libsubincludedir = 
$(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/include
+# Search for main_target_image.h in these directories
+target_prefix_dir = $(libdir)/gcc/$(accel_target)/$(gcc_version)$(MULTISUBDIR)
+target_build_dir = 
$(accel_search_dir)/$(accel_target)$(MULTISUBDIR)/liboffloadmic/plugin
+target_install_dir = 
$(accel_search_dir)/lib/gcc/$(accel_target)/$(gcc_version)$(MULTISUBDIR)
+
+if PLUGIN_HOST
+  toolexeclib_LTLIBRARIES = libgomp-plugin-intelmic.la
+  libgomp_plugin_intelmic_la_SOURCES = libgomp-plugin-intelmic.cpp
+  libgomp_plugin_intelmic_la_CPPFLAGS = $(CPPFLAGS) -DLINUX 
-DCOI_LIBRARY_VERSION=2 -DMYO_SUPPORT -DOFFLOAD_DEBUG=1 -DSEP_SUPPORT 
-DTIMING_SUPPORT -DHOST_LIBRARY=1 -I$(coi_inc_dir) -I$(myo_inc_dir) 
-I$(liboffload_src_dir) -I$(libgomp_src_dir) -I$(libgomp_dir) 
-I$(target_prefix_dir)/include -I$(target_build_dir) 
-I$(target_install_dir)/include
+  libgomp_plugin_intelmic_la_LDFLAGS = -L$(liboffload_dir)/.libs 
-loffloadmic_host -version-info 1:0:0
+else # PLUGIN_TARGET
+  plugin_includedir = $(libsubincludedir)
+  plugin_include_HEADERS = main_target_image.h
+  AM_CPPFLAGS = $(CPPFLAGS) -DLINUX -DCOI_LIBRARY_VERSION=2 -DMYO_SUPPORT 
-DOFFLOAD_DEBUG=1 -DSEP_SUPPORT -DTIMING_SUPPORT -DHOST_LIBRARY=0 
-I$(coi_inc_dir) -I$(myo_inc_dir) -I$(liboffload_src_dir) -I$(libgomp_dir)
+  AM_CXXFLAGS = $(CXXFLAGS)
+  AM_LDFLAGS = -L$(liboffload_dir)/.libs -L$(libgomp_dir)/.libs 
-loffloadmic_target -lcoi_dev

Re: [PATCH][optabs] PR63442 libgcc_cmp_return_mode not always return word_mode

2014-10-27 Thread Jiong Wang


On 24/10/14 19:41, Jeff Law wrote:

On 10/24/14 08:09, Jiong Wang wrote:

ping~

thanks.

Regards,
Jiong

On 17/10/14 13:04, Jiong Wang wrote:

the cause should be one minor bug in prepare_cmp_insn.

the last mode parameter "pmode" of "prepare_cmp_insn" should match the
mode of the first parameter "x", while during the recursive call of
"prepare_cmp_insn",
x is with mode of targetm.libgcc_cmp_return_mode () and pmode is
assign to word_mode.

generally this is OK, because default libgcc_cmp_return_mode hook
always return word_mode,
but AArch64 has a target private implementation which always return
SImode, so there is a
mismatch which cause a ICE later.

this minor issue is hidding because nearly all other targets use
default hook, and the
compare is rarely invoked.

Thanks

gcc/
 PR target/63442
 * optabs.c (prepare_cmp_insn): Use target hook
"libgcc_cmp_return_mode" instead of word_mode.

This is fine once you have run it through a bootstrap and regression test.

Any reason not to use RET_MODE since that's already set up with the
result of the target hook?


Ah, it's better to reuse ret_mode, thanks for your carefulness.

patch updated, bootstrapping OK on x86-64 (--enable-languages=c,c++), no 
regression. (on top of 216667 which is nearly up-to-date)

ok for trunk?

gcc/
  PR target/63442
  * optabs.c (prepare_cmp_insn): Use "ret_mode" instead of "word_mode".
diff --git a/gcc/optabs.c b/gcc/optabs.c
index 2df84d2..ed415fa 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -4270,7 +4270,7 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx_code comparison, rtx size,
 	y = const0_rtx;
 	}
 
-  *pmode = word_mode;
+  *pmode = ret_mode;
   prepare_cmp_insn (x, y, comparison, NULL_RTX, unsignedp, methods,
 			ptest, pmode);
 }

RE: [PATCH, ifcvt] Check size cost in noce_try_store_flag_mask

2014-10-27 Thread Matthew Fortune
Zhenqiang Chen  writes:
> For CSiBE, ARM Cortex-m0 result is a little better. A little regression
> for
> MIPS. Roughly no change for PowerPC.

Do I take it that a little regression for MIPS is so small it can be
considered noise? I haven't had chance to run CSiBE to see the difference.

Thanks,
Matthew

> 
> OK for trunk?
> 
> Thanks!
> -Zhenqiang
> 
> ChangeLog:
> 2014-10-27  Zhenqiang Chen  
> 
>   * ifcvt.c (noce_try_store_flag_mask): Check rtx cost.
> 
> testsuite/ChangeLog:
> 2014-10-27  Zhenqiang Chen  
> 
>   * gcc.target/arm/ifcvt-size-check.c: New test.
> 
> diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
> index 949d2b4..3abd518 100644
> --- a/gcc/ifcvt.c
> +++ b/gcc/ifcvt.c
> @@ -1393,6 +1393,14 @@ noce_try_store_flag_mask (struct noce_if_info
> *if_info)
> if (!seq)
>   return FALSE;
> 
> +   if (optimize_function_for_size_p (cfun))
> + {
> +   int old_cost = COSTS_N_INSNS (if_info->branch_cost + 1);
> +   int new_cost = seq_cost (seq, 0);
> +   if (new_cost > old_cost)
> + return FALSE;
> + }
> +
> emit_insn_before_setloc (seq, if_info->jump,
>  INSN_LOCATION (if_info->insn_a));
> return TRUE;
> diff --git a/gcc/testsuite/gcc.target/arm/ifcvt-size-check.c
> b/gcc/testsuite/gcc.target/arm/ifcvt-size-check.c
> new file mode 100644
> index 000..43fa16b
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/arm/ifcvt-size-check.c
> @@ -0,0 +1,13 @@
> +/* { dg-do assemble } */
> +/* { dg-options "-mthumb -Os " }  */
> +/* { dg-require-effective-target arm_thumb1_ok } */
> +
> +int
> +test (unsigned char iov_len, int count, int i)
> +{
> +  unsigned char bytes = 0;
> +  if ((unsigned char) ((char) 127 - bytes) < iov_len)
> +return 22;
> +  return 0;
> +}
> +/* { dg-final { object-size text <= 12 } } */
> 
> 



Re: gccgo testcase: binary testdata for libgo/go/debug/elf/file_test.go

2014-10-27 Thread Lynn A. Boger

I will start with the gccgo contribution process from golang.

Thanks!

Lynn

On 10/15/2014 08:26 PM, Ian Lance Taylor wrote:

On Wed, Oct 15, 2014 at 1:41 PM, Lynn A. Boger
 wrote:

I'm working on a patch submission for gccgo to add the R_PPC64 relocation
definitions to libgo/go/debug/elf/elf.go.  Along with this submission I was
going to update the testcase file_test.go from the same directory so it
would test the new defines for ppc64 relocation.  This test currently reads
files from libgo/go/debug/elf/testdata which exist in svn as executable and
relocatable files that were compiled from various gcc versions and on
various platforms.

How should I submit these testdata files, since they are binary files and
not patch files?

Ideally all submissions to gccgo should follow the process described
at http://golang.org/doc/gccgo_contribute.html .  This is not strictly
required in that I will take care of it for you, but it makes life a
lot easier for me if you do it that way.  And as a bonus it handles
binary files just fine.

If that's not going to work just send the binary files to gcc-patches
as an attachment.  Put the patch itself in one attachment, or inline
in the e-mail message, and put the binary files in another.  Please
make sure that all the binaries are compiled from the hello.c file in
that directory; if that is not possible, you will need to provide the
sources that you are compiling, to satisfy Debian's requirements on
binaries in test data.  (And at that point we'll probably have to
start thinking about a README to explain where the files come from.)

Thanks!

Ian





[match-and-simplify] reject conditional convert and commutative ops in result operand

2014-10-27 Thread Prathamesh Kulkarni
I suppose we should reject conditional convert and commutative ops in
result operand ? since it would create 1-n mapping from match ->
result.

* genmatch.c
  (fatal_at): New overloaded function with source_location as first parameter.
  (has_opt_convert_or_commutative_ops): New function.
  (lower): Call has_opt_convert_or_commutative_ops.

Thanks,
Prathamesh
Index: gcc/genmatch.c
===
--- gcc/genmatch.c	(revision 216718)
+++ gcc/genmatch.c	(working copy)
@@ -83,6 +83,18 @@
 #if GCC_VERSION >= 4001
 __attribute__((format (printf, 2, 3)))
 #endif
+fatal_at (source_location src_loc, const char *msg, ...)
+{
+  va_list ap;
+  va_start (ap, msg);
+  error_cb (0, CPP_DL_FATAL, 0, src_loc, 0, msg, &ap);
+  va_end (ap);
+}
+
+static void
+#if GCC_VERSION >= 4001
+__attribute__((format (printf, 2, 3)))
+#endif
 fatal_at (const cpp_token *tk, const char *msg, ...)
 {
   va_list ap;
@@ -877,11 +889,46 @@
 simplifiers.safe_push (worklist[i]);
 }
 
+bool
+has_opt_convert_or_commutative_ops (operand *o)
+{
+  if (!o)
+return false;
+
+  if (capture *c = dyn_cast (o))
+{
+  if (c->what)
+	return has_opt_convert_or_commutative_ops (c->what);
+  else
+	return false;
+}
+
+  expr *e = dyn_cast (o);
+  if (!e)
+return false;
+
+  if (*e->operation == CONVERT0 || *e->operation == CONVERT1
+  || *e->operation == CONVERT2 || e->is_commutative)
+return true;
+
+  for (unsigned i = 0; i < e->ops.length (); ++i)
+if (has_opt_convert_or_commutative_ops (e->ops[i]))
+  return true;
+
+  return false;
+}
+
+  
+
 /* Lower the AST for everything in SIMPLIFIERS.  */
 
 static void
 lower (vec& simplifiers)
 {
+  for (unsigned i = 0; i < simplifiers.length (); ++i)
+if (has_opt_convert_or_commutative_ops (simplifiers[i]->result))
+  fatal_at (simplifiers[i]->result_location, "result operand cannot contain conditional convert or commutative operator");
+
   auto_vec out_simplifiers0;
   for (unsigned i = 0; i < simplifiers.length (); ++i)
 lower_opt_convert (simplifiers[i], out_simplifiers0);


Re: genmatch infinite loop during bootstrap on AIX

2014-10-27 Thread David Edelsohn
On Mon, Oct 27, 2014 at 2:37 AM, Richard Biener
 wrote:
> On October 27, 2014 1:49:54 AM CET, David Edelsohn  wrote:
>>Richi,
>>
>>Does genmatch rely on static constructors or implicitly rely on the
>>order of static constructors? Sometimes those cause problems on AIX.
>
> No, it doesn't.
>
>>Bootstrap on AIX succeeds prior to r216631, e.g., r216624.  It works
>>after your commit r216619 to correct Makefile.in, or prior to that by
>>manually editing Makefile.in to add LIBICONV and LIBINTL.
>
> OK, so this would mean that r216631 causes a miscompile for you. Though that 
> does not match up with you seeing this happening during stage1...

gcc111 uses GCC 4.8.1 as the default version of GCC.  That bootstrap
fails in stage 2.

My internal system has GCC 4.7.3 installed.  That bootstrap fails in stage 1.

>
> Bah.
>
> The place where it is looping is using std::map .

I hope that this isn't a signed char issue.

> Does -static-libstdc++ work for you host compilers?

Yes, GCC uses -static-libstdc++ on AIX.

> Can you try emptying gcc/match.pd for a non-working rev.?

An empty match.pd seems to work.  I will try adding back stanzas and
see where it hangs.

Thanks, David


Re: [GOOGLE] Fix LIPO resolved node reference fixup

2014-10-27 Thread Teresa Johnson
Here is the new patch that walks op looking for the reference to addr.

Passes internal benchmarks and regression tests. Ok for google/4_9?

Thanks,
Teresa

2014-10-27  Teresa Johnson  

Google ref b/18110567.
* cgraphbuild.c (fixup_all_refs_1): New function.
(fixup_all_refs): Ditto.
(fixup_ref): Walk tree to find and replace ref.

Index: cgraphbuild.c
===
--- cgraphbuild.c   (revision 216735)
+++ cgraphbuild.c   (working copy)
@@ -665,6 +665,45 @@ record_references_in_initializer (tree decl, bool
   pointer_set_destroy (visited_nodes);
 }

+typedef struct _fixup_decl_info {
+  tree orig_decl;
+  tree new_decl;
+} fixup_decl_info;
+
+/* Check the tree at TP to see if it contains the original decl stored in
+   DATA and if so replace it with the new decl. If original decl is
+   found set WALK_SUBTREES to 0 so the subtree under TP is not traversed.
+   Returns the updated parent tree T or NULL if no update performed.  */
+
+static tree
+fixup_all_refs_1 (tree *tp, int *walk_subtrees, void *data)
+{
+  tree t = *tp;
+  fixup_decl_info *info = (fixup_decl_info *) data;
+
+  /* The original function decl is always the first tree operand.  */
+  if (TREE_OPERAND (t,0) == info->orig_decl)
+{
+  TREE_OPERAND (t,0) = info->new_decl;
+  *walk_subtrees = 0;
+  return t;
+}
+  return NULL_TREE;
+}
+
+/* Walk the whole tree rooted at TP and invoke fixup_all_refs_1 to
+   replace any references to the original decl with the new decl
+   stored in INFO.  */
+
+static inline void
+fixup_all_refs (tree *tp, fixup_decl_info *info)
+{
+  tree t = walk_tree (tp, fixup_all_refs_1, info, NULL);
+  /* This is invoked when we found the original decl, so we expect
+ to have replaced a reference.  */
+  gcc_assert (t != NULL_TREE);
+}
+
 /* Update any function decl references in base ADDR of operand OP to refer to
the resolved node.  */

@@ -674,13 +713,16 @@ fixup_ref (gimple, tree addr, tree op)
   addr = get_base_address (addr);
   if (addr && TREE_CODE (addr) == FUNCTION_DECL)
 {
-  gcc_assert (TREE_CODE (op) == ADDR_EXPR);
-  gcc_assert (TREE_OPERAND (op,0) == addr);
   struct cgraph_node *real_callee;
   real_callee = cgraph_lipo_get_resolved_node (addr);
   if (addr == real_callee->decl)
 return false;
-  TREE_OPERAND (op,0) = real_callee->decl;
+  /* We need to locate and update the tree operand within OP
+ that contains ADDR and update it to the real callee's decl.  */
+  fixup_decl_info info;
+  info.orig_decl = addr;
+  info.new_decl = real_callee->decl;
+  fixup_all_refs (&op, &info);
 }
   return false;
 }


On Fri, Oct 24, 2014 at 11:46 AM, Teresa Johnson  wrote:
> On Fri, Oct 24, 2014 at 10:55 AM, Xinliang David Li  
> wrote:
>> When orgin_addr == addr, is there a guarantee that this assert:
>>
>>  gcc_assert (TREE_OPERAND (op,0) == addr);
>>
>> is always true?
>
> It should be, that is the assumption of the code that we are trying to
> enforce with the assert.
>
> Teresa
>
>>
>> David
>>
>>
>>
>> On Fri, Oct 24, 2014 at 10:21 AM, Teresa Johnson  
>> wrote:
>>> This patch makes a fix to the reference fixups performed after LIPO
>>> node resolution, to better handle the case where we are updating the
>>> base address of a reference.
>>>
>>> Fixes google benchmark and passes regression tests. Ok for google/4_9?
>>>
>>> Thanks,
>>> Teresa
>>>
>>> 2014-10-24  Teresa Johnson  
>>>
>>> Google ref b/18110567.
>>> * cgraphbuild.c (get_base_address_expr): New function.
>>> (fixup_ref): Update the op expression for new base address.
>>>
>>> Index: cgraphbuild.c
>>> ===
>>> --- cgraphbuild.c   (revision 216667)
>>> +++ cgraphbuild.c   (working copy)
>>> @@ -665,13 +665,35 @@ record_references_in_initializer (tree decl, bool
>>>pointer_set_destroy (visited_nodes);
>>>  }
>>>
>>> +/* Similar to get_base_address but returns the ADDR_EXPR pointing
>>> +   to the base address corresponding to T.  */
>>> +
>>> +static tree
>>> +get_base_address_expr (tree t)
>>> +{
>>> +  while (handled_component_p (t))
>>> +t = TREE_OPERAND (t, 0);
>>> +
>>> +  if ((TREE_CODE (t) == MEM_REF
>>> +   || TREE_CODE (t) == TARGET_MEM_REF)
>>> +  && TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR)
>>> +return TREE_OPERAND (t, 0);
>>> +
>>> +  return NULL_TREE;
>>> +}
>>> +
>>>  /* Update any function decl references in base ADDR of operand OP to refer 
>>> to
>>> the resolved node.  */
>>>
>>>  static bool
>>>  fixup_ref (gimple, tree addr, tree op)
>>>  {
>>> +  tree orig_addr = addr;
>>>addr = get_base_address (addr);
>>> +  /* If the address was changed, update the operand OP to be the
>>> + ADDR_EXPR pointing to the new base address.  */
>>> +  if (orig_addr != addr)
>>> +op = get_base_address_expr (orig_addr);
>>>if (addr 

Re: [PATCHv2] Don't expand string/memory builtins if ASan is enabled.

2014-10-27 Thread Jakub Jelinek
On Thu, Oct 23, 2014 at 12:26:48PM +0400, Yury Gribov wrote:
> On 10/21/2014 05:26 PM, Maxim Ostapenko wrote:
> >Hi,
> >
> >this is the second version of the patch. Here the major changes from the
> >previous one:
> 
> [snip]
> 
> >  case BUILT_IN_BCMP:
> >+  *intercepted_p = false;
> 
> The code which identifies interceptors seems to be duplicated in
> expand_builtin.  What about factoring this out to some is_asan_intercepted()
> in asan.h?

I agree.

BTW, when you handle a builtin, but set *intercepted_p to false, is the
point just that you don't instrument e.g. scalar accesses to that memory
region afterwards?  I mean:
memcpy (p, "abc", 3);
p[0] = 'd';
you don't really have to instrument p[0] store, because supposedly memcpy
call has already verified p[0] through p[2] is writable.

Jakub


Re: genmatch infinite loop during bootstrap on AIX

2014-10-27 Thread David Edelsohn
On Mon, Oct 27, 2014 at 2:37 AM, Richard Biener
 wrote:
> On October 27, 2014 1:49:54 AM CET, David Edelsohn  wrote:
>>Richi,
>>
>>Does genmatch rely on static constructors or implicitly rely on the
>>order of static constructors? Sometimes those cause problems on AIX.
>
> No, it doesn't.
>
>>Bootstrap on AIX succeeds prior to r216631, e.g., r216624.  It works
>>after your commit r216619 to correct Makefile.in, or prior to that by
>>manually editing Makefile.in to add LIBICONV and LIBINTL.
>
> OK, so this would mean that r216631 causes a miscompile for you. Though that 
> does not match up with you seeing this happening during stage1...
>
> Bah.
>
> The place where it is looping is using std::map .
>
> Does -static-libstdc++ work for you host compilers?
>
> Can you try emptying gcc/match.pd for a non-working rev.?

Empty file: success.

Header comment: success.

define_predicates stanza: success.

Any "simplify" stanza (with or without "for" loop): HANG.

- David


Re: [Ping] [PATCH, 1/10] two hooks for conditional compare (ccmp)

2014-10-27 Thread Richard Henderson
On 10/27/2014 12:47 AM, Zhenqiang Chen wrote:
> + @var{NULL} if the combination of @var{prev} and this comparison is\n\

@code{NULL}

Otherwise ok.


r~


Re: [alpha] RFA: Use new rtl iterators in some_small_symbolic_operand_int

2014-10-27 Thread Richard Henderson
On 10/25/2014 03:16 AM, Richard Sandiford wrote:
> gcc/
>   * config/alpha/alpha-protos.h (some_small_symbolic_operand_int):
>   Take an rtx and return a bool.
>   * config/alpha/alpha.c (some_small_symbolic_operand_int): Likewise.
>   Use FOR_EACH_SUBRTX_VAR.
>   * config/alpha/predicates.md (some_small_symbolic_operand): Update
>   accordingly.

Ok.


r~


Re: [alpha] RFA: Use new rtl iterators in alpha_find_lo_sum_using_gp

2014-10-27 Thread Richard Henderson
On 10/25/2014 03:15 AM, Richard Sandiford wrote:
> This is part of a series to remove uses of for_each_rtx from the ports.
> 
> Tested by making sure there were no code changes for gcc.dg, gcc.c-torture
> and g++.dg for alpha-linux-gnu.  OK to install?
> 
> Thanks,
> Richard
> 
> 
> gcc/
>   * config/alpha/alpha-protos.h (alpha_find_lo_sum_using_gp): Return
>   a bool.
>   * config/alpha/alpha.c (find_lo_sum_using_gp): Delete.
>   (alpha_find_lo_sum_using_gp): Use FOR_EACH_SUBRTX.  Return a bool.

Ok.


r~



Re: [alpha] RFA: Use new rtl iterators in alpha_set_memflags

2014-10-27 Thread Richard Henderson
On 10/25/2014 03:14 AM, Richard Sandiford wrote:
> gcc/
>   * config/alpha/alpha.c (alpha_set_memflags_1): Delete.
>   (alpha_set_memflags): Use FOR_EACH_SUBRTX_VAR.

Ok.


r~


Re: Patch RFA: Top-level configure patch: disable go on systems where it doesn't work

2014-10-27 Thread Jan-Benedict Glaw
Hi Ian,

On Wed, 2014-10-22 20:36:53 -0700, Ian Taylor  wrote:
> This patch to the top level GCC configure script disables the go
> languages on some systems where it is known to not work.  Bootstrapped
> on x86_64-unknown-gnu-linux.

I don't have a clue here, but in what way is Go broken for these
targets? Bacause this patch "breaks" a number of targets mentioned in
contrib/config-list.mk.  Maybe Go didn't work on these, but it at
least built.  Is it FUBAR there? Or just little fixes needed?

MfG, JBG

-- 
  Jan-Benedict Glaw  jbg...@lug-owl.de  +49-172-7608481
Signature of:   Warum ist Scheiße braun? ...weil braun schon immer scheiße 
ist!
the second  :


signature.asc
Description: Digital signature


Re: [alpha] RFA: Use new rtl iterators in split_small_symbolic_operand

2014-10-27 Thread Richard Henderson
On 10/25/2014 03:13 AM, Richard Sandiford wrote:
> gcc/
>   * config/alpha/alpha.c: Include rtl-iter.h.
>   (split_small_symbolic_operand_1): Delete.
>   (split_small_symbolic_operand): Use FOR_EACH_SUBRTX_PTR.

Ok.


r~


Re: [libgomp, libiberty, libobjc] Fix gnu11 fallout on Solaris 10+

2014-10-27 Thread Richard Henderson
On 10/24/2014 01:56 AM, Rainer Orth wrote:
> And even with the _XOPEN_SOURCE business out of the way, there's still
> the question what to do about _POSIX_SOURCE in libiberty/sigsetmask.c.
> Given that it was introduced almost 20 years ago, it may well be
> unnecessary for the systems we still care about.

Probably.


r~


Re: [gomp4] Wait directive with async and wait clauses.

2014-10-27 Thread Thomas Schwinge
Hi Jim!

On Wed, 22 Oct 2014 09:46:53 -0500, James Norris  
wrote:
> This patch adds code to handle the OpenACC wait directive and
> the wait and async clauses for the wait directive as well as the
> other directives which support them.
> 
> OK for gomp4 branch?

Yes, thanks!

Please either merge in the following patch, or I'll commit it afterwards:

gcc/ada/
* gcc-interface/utils.c (DEF_FUNCTION_TYPE_10): Remove.
(DEF_FUNCTION_TYPE_VAR_8, DEF_FUNCTION_TYPE_VAR_12): New macros.

--- gcc/ada/gcc-interface/utils.c
+++ gcc/ada/gcc-interface/utils.c
@@ -5328,8 +5328,6 @@ enum c_builtin_type
ARG6, ARG7) NAME,
 #define DEF_FUNCTION_TYPE_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
ARG6, ARG7, ARG8) NAME,
-#define DEF_FUNCTION_TYPE_10(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
-ARG6, ARG7, ARG8, ARG9, ARG10) NAME,
 #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
 #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME,
 #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME,
@@ -5337,6 +5335,12 @@ enum c_builtin_type
 #define DEF_FUNCTION_TYPE_VAR_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
 #define DEF_FUNCTION_TYPE_VAR_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
   NAME,
+#define DEF_FUNCTION_TYPE_VAR_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
+   ARG6, ARG7, ARG8)   \
+  NAME,
+#define DEF_FUNCTION_TYPE_VAR_12(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
+ARG6, ARG7, ARG8, ARG9, ARG10, ARG11, ARG12) \
+  NAME,
 #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
 #include "builtin-types.def"
 #undef DEF_PRIMITIVE_TYPE
@@ -5349,13 +5353,14 @@ enum c_builtin_type
 #undef DEF_FUNCTION_TYPE_6
 #undef DEF_FUNCTION_TYPE_7
 #undef DEF_FUNCTION_TYPE_8
-#undef DEF_FUNCTION_TYPE_10
 #undef DEF_FUNCTION_TYPE_VAR_0
 #undef DEF_FUNCTION_TYPE_VAR_1
 #undef DEF_FUNCTION_TYPE_VAR_2
 #undef DEF_FUNCTION_TYPE_VAR_3
 #undef DEF_FUNCTION_TYPE_VAR_4
 #undef DEF_FUNCTION_TYPE_VAR_5
+#undef DEF_FUNCTION_TYPE_VAR_8
+#undef DEF_FUNCTION_TYPE_VAR_12
 #undef DEF_POINTER_TYPE
   BT_LAST
 };
@@ -5449,10 +5454,6 @@ install_builtin_function_types (void)
ARG6, ARG7, ARG8)   \
   def_fn_type (ENUM, RETURN, 0, 8, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \
   ARG7, ARG8);
-#define DEF_FUNCTION_TYPE_10(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
-ARG6, ARG7, ARG8, ARG9, ARG10) \
-  def_fn_type (ENUM, RETURN, 0, 8, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \
-  ARG7, ARG8, ARG9, ARG10);
 #define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \
   def_fn_type (ENUM, RETURN, 1, 0);
 #define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \
@@ -5465,6 +5466,14 @@ install_builtin_function_types (void)
   def_fn_type (ENUM, RETURN, 1, 4, ARG1, ARG2, ARG3, ARG4);
 #define DEF_FUNCTION_TYPE_VAR_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
   def_fn_type (ENUM, RETURN, 1, 5, ARG1, ARG2, ARG3, ARG4, ARG5);
+#define DEF_FUNCTION_TYPE_VAR_8(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
+   ARG6, ARG7, ARG8)   \
+  def_fn_type (ENUM, RETURN, 1, 5, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \
+  ARG7, ARG8);
+#define DEF_FUNCTION_TYPE_VAR_12(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
+ARG6, ARG7, ARG8, ARG9, ARG10, ARG11, ARG12) \
+  def_fn_type (ENUM, RETURN, 1, 5, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \
+  ARG7, ARG8, ARG9, ARG10, ARG11, ARG12);
 #define DEF_POINTER_TYPE(ENUM, TYPE) \
   builtin_types[(int) ENUM] = build_pointer_type (builtin_types[(int) TYPE]);
 
@@ -5480,13 +5489,14 @@ install_builtin_function_types (void)
 #undef DEF_FUNCTION_TYPE_6
 #undef DEF_FUNCTION_TYPE_7
 #undef DEF_FUNCTION_TYPE_8
-#undef DEF_FUNCTION_TYPE_10
 #undef DEF_FUNCTION_TYPE_VAR_0
 #undef DEF_FUNCTION_TYPE_VAR_1
 #undef DEF_FUNCTION_TYPE_VAR_2
 #undef DEF_FUNCTION_TYPE_VAR_3
 #undef DEF_FUNCTION_TYPE_VAR_4
 #undef DEF_FUNCTION_TYPE_VAR_5
+#undef DEF_FUNCTION_TYPE_VAR_8
+#undef DEF_FUNCTION_TYPE_VAR_12
 #undef DEF_POINTER_TYPE
   builtin_types[(int) BT_LAST] = NULL_TREE;
 }


Grüße,
 Thomas


pgpcVVRRjv1CT.pgp
Description: PGP signature


Re: [Ping] [PATCH, 2/10] prepare ccmp

2014-10-27 Thread Richard Henderson
On 10/27/2014 12:48 AM, Zhenqiang Chen wrote:
>> > On 09/22/2014 11:43 PM, Zhenqiang Chen wrote:
>>> > > + /* If jumps are cheap and the target does not support 
>>> > > conditional
>>> > > +compare, turn some more codes into jumpy sequences.  */
>>> > > + else if (BRANCH_COST (optimize_insn_for_speed_p (), false) < 4
>>> > > +  && (targetm.gen_ccmp_first == NULL))
>> > 
>> > Don't add unnecessary parenthesis around the == expression.
>> > 
>> > Otherwise ok.
>> > 
>> > 
>> > r~
> 
> 2-prepare.patch
> 
> 
> diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
> index 5200053..cfd4070 100644
> --- a/gcc/cfgexpand.c
> +++ b/gcc/cfgexpand.c
> @@ -2115,9 +2115,10 @@ expand_gimple_cond (basic_block bb, gimple stmt)
> op0 = gimple_assign_rhs1 (second);
> op1 = gimple_assign_rhs2 (second);
>   }
> -   /* If jumps are cheap turn some more codes into
> -  jumpy sequences.  */
> -   else if (BRANCH_COST (optimize_insn_for_speed_p (), false) < 4)
> +   /* If jumps are cheap and the target does not support conditional
> +  compare, turn some more codes into jumpy sequences.  */
> +   else if ((BRANCH_COST (optimize_insn_for_speed_p (), false) < 4)
> +&& (!targetm.gen_ccmp_first))

Did you not understand what I meant by parenthesis?


r~


Re: [Ping] [PATCH, 5/10] aarch64: add ccmp operand predicate

2014-10-27 Thread Richard Henderson
On 10/27/2014 12:48 AM, Zhenqiang Chen wrote:
> Thanks for the comments. All comments are accepted and the updated patch is
> attached.
> 
> -Zhenqiang

New patch looks good.


r~


Re: Patch RFA: Top-level configure patch: disable go on systems where it doesn't work

2014-10-27 Thread Ian Taylor
On Mon, Oct 27, 2014 at 8:06 AM, Jan-Benedict Glaw  wrote:
>
> On Wed, 2014-10-22 20:36:53 -0700, Ian Taylor  wrote:
>> This patch to the top level GCC configure script disables the go
>> languages on some systems where it is known to not work.  Bootstrapped
>> on x86_64-unknown-gnu-linux.
>
> I don't have a clue here, but in what way is Go broken for these
> targets? Bacause this patch "breaks" a number of targets mentioned in
> contrib/config-list.mk.  Maybe Go didn't work on these, but it at
> least built.  Is it FUBAR there? Or just little fixes needed?

I'm not sure exactly what you mean by "breaks," here, as Go is never
in the set of default languages.  It should only break builds that are
using --enable-languages=go.  And for those targets, the Go support
has never worked, so they were already broken.

For Darwin I expect that only small fixes are needed.  This is
http://gcc.gnu.org/PR46986.

For Windows the compiler probably only needs small fixes, but the
libgo build will need a bunch of support, particularly in the syscall
package.  The support for Windows is mostly there in the code, because
it is in the master Go library, but it's not being built for libgo.

For AIX I'm not sure.  It's probably not too much work.

Ian


Re: [Ping] [PATCH, 6/10] aarch64: add ccmp CC mode

2014-10-27 Thread Richard Henderson
On 10/27/2014 12:48 AM, Zhenqiang Chen wrote:
> 
>> -Original Message-
>> From: Richard Henderson [mailto:r...@redhat.com]
>> Sent: Saturday, October 11, 2014 11:32 PM
>> To: Zhenqiang Chen; gcc-patches@gcc.gnu.org
>> Subject: Re: [Ping] [PATCH, 6/10] aarch64: add ccmp CC mode
>>
>> On 09/22/2014 11:44 PM, Zhenqiang Chen wrote:
>>> +case CC_DNEmode:
>>> +  return comp_code == NE ? AARCH64_NE : AARCH64_EQ;
>>> +case CC_DEQmode:
>>> +  return comp_code == NE ? AARCH64_EQ : AARCH64_NE;
>>> +case CC_DGEmode:
>>> +  return comp_code == NE ? AARCH64_GE : AARCH64_LT;
>>> +case CC_DLTmode:
>>> +  return comp_code == NE ? AARCH64_LT : AARCH64_GE;
>>> +case CC_DGTmode:
>>> +  return comp_code == NE ? AARCH64_GT : AARCH64_LE;
>>> +case CC_DLEmode:
>>> +  return comp_code == NE ? AARCH64_LE : AARCH64_GT;
>>> +case CC_DGEUmode:
>>> +  return comp_code == NE ? AARCH64_CS : AARCH64_CC;
>>> +case CC_DLTUmode:
>>> +  return comp_code == NE ? AARCH64_CC : AARCH64_CS;
>>> +case CC_DGTUmode:
>>> +  return comp_code == NE ? AARCH64_HI : AARCH64_LS;
>>> +case CC_DLEUmode:
>>> +  return comp_code == NE ? AARCH64_LS : AARCH64_HI;
>>
>> I think these should return -1 if comp_code is not EQ.  Like the CC_Zmode
>> case below.
> 
> Since the code can not guarantee that the CC is used in cbranchcc insns when
> expand, it maybe in a tmp register. After some optimizations the CC is
> forwarded in cbranchcc insn. So the comp_code might be any legal COMPARE.

Um, no.  The point of returning -1 is to avoid combining with comparisons for
which we cannot produce the proper result.

E.g. the existing CC_Zmode, where only the Z bit is valid.  We want to reject
combination with LTU, which checks the C bit.

Are you honestly suggesting that using CC_DNEmode with GE can be made to make
sense in any way?


r~


[PATCH] PR ipa/63576: Process speculative edges in ICF

2014-10-27 Thread Ilya Palachev
Hi all,

The attached patch is an attempt to fix the bug PR ipa/63576.
As it is said in the comment to the bug,

Jan Hubicka wrote:
> THen you need to sum counts (instead of taking ones from BB) and
> turn them back to frequencies (because it is profile only counts
> should be non-0)

It seems that counts and frequencies are gathered in some special
manner, and this patch simply adds counts from speculative edges and
from basic blocks. Of course, I don't know whether this way is proper
one, so please correct me or redirect to right place where it is
documented :)

Anyway, the patch was bootstrapped and regtested on
x86_64-unknown-linux-gnu.

Ok for trunk? 

gcc/

2014-10-22  Ilya Palachev  

* ipa-utils.c (compute_edge_count_and_frequency): New function
(ipa_merge_profiles): handle speculative case
---
 gcc/ipa-utils.c | 52 ++--
 1 file changed, 42 insertions(+), 10 deletions(-)

diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c
index 552071e..335ab05 100644
--- a/gcc/ipa-utils.c
+++ b/gcc/ipa-utils.c
@@ -380,6 +380,46 @@ get_base_var (tree t)
   return t;
 }
 
+/* Computes count and frequency for edges.  */
+
+static void
+compute_edge_count_and_frequency(struct cgraph_edge *e,
+struct cgraph_node *dst)
+{
+  basic_block bb = gimple_bb (e->call_stmt);
+  if (!e->speculative)
+{
+  e->count = bb->count;
+  e->frequency = compute_call_stmt_bb_frequency (dst->decl, bb);
+}
+  else
+{
+  if (profile_status_for_fn (DECL_STRUCT_FUNCTION (dst->decl))
+ == PROFILE_ABSENT)
+{
+ e->count = bb->count;
+ e->frequency = CGRAPH_FREQ_BASE;
+   }
+  else
+{
+ gcc_assert (e->count >= 0);
+ e->count += bb->count;
+ gcc_assert (e->frequency >= 0);
+
+ int entry_freq = ENTRY_BLOCK_PTR_FOR_FN
+   (DECL_STRUCT_FUNCTION (dst->decl))->frequency;
+ int freq = e->frequency + bb->frequency;
+
+ if (!entry_freq)
+   entry_freq = 1, freq++;
+
+ freq = freq * CGRAPH_FREQ_BASE / entry_freq;
+ if (freq > CGRAPH_FREQ_MAX)
+   freq = CGRAPH_FREQ_MAX;
+ e->frequency = freq;
+   }
+}
+}
 
 /* SRC and DST are going to be merged.  Take SRC's profile and merge it into
DST so it is not going to be lost.  Destroy SRC's body on the way.  */
@@ -537,19 +577,11 @@ ipa_merge_profiles (struct cgraph_node *dst,
   pop_cfun ();
   for (e = dst->callees; e; e = e->next_callee)
{
- gcc_assert (!e->speculative);
- e->count = gimple_bb (e->call_stmt)->count;
- e->frequency = compute_call_stmt_bb_frequency
-(dst->decl,
- gimple_bb (e->call_stmt));
+ compute_edge_count_and_frequency(e, dst);
}
   for (e = dst->indirect_calls; e; e = e->next_callee)
{
- gcc_assert (!e->speculative);
- e->count = gimple_bb (e->call_stmt)->count;
- e->frequency = compute_call_stmt_bb_frequency
-(dst->decl,
- gimple_bb (e->call_stmt));
+ compute_edge_count_and_frequency(e, dst);
}
   src->release_body ();
   inline_update_overall_summary (dst);
-- 
2.1.1



Re: [PATCH] PR ipa/63576: Process speculative edges in ICF

2014-10-27 Thread Jiong Wang


On 27/10/14 15:30, Ilya Palachev wrote:

Hi all,

The attached patch is an attempt to fix the bug PR ipa/63576.
As it is said in the comment to the bug,

Jan Hubicka wrote:

THen you need to sum counts (instead of taking ones from BB) and
turn them back to frequencies (because it is profile only counts
should be non-0)

It seems that counts and frequencies are gathered in some special
manner, and this patch simply adds counts from speculative edges and
from basic blocks. Of course, I don't know whether this way is proper
one, so please correct me or redirect to right place where it is
documented :)

Anyway, the patch was bootstrapped and regtested on
x86_64-unknown-linux-gnu.

Ok for trunk?

gcc/

2014-10-22  Ilya Palachev  

* ipa-utils.c (compute_edge_count_and_frequency): New function
(ipa_merge_profiles): handle speculative case
---
  gcc/ipa-utils.c | 52 ++--
  1 file changed, 42 insertions(+), 10 deletions(-)

diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c
index 552071e..335ab05 100644
--- a/gcc/ipa-utils.c
+++ b/gcc/ipa-utils.c
@@ -380,6 +380,46 @@ get_base_var (tree t)
return t;
  }
  
+/* Computes count and frequency for edges.  */

+
+static void
+compute_edge_count_and_frequency(struct cgraph_edge *e,
+struct cgraph_node *dst)
+{
+  basic_block bb = gimple_bb (e->call_stmt);
+  if (!e->speculative)
+{
+  e->count = bb->count;
+  e->frequency = compute_call_stmt_bb_frequency (dst->decl, bb);
+}
+  else
+{
+  if (profile_status_for_fn (DECL_STRUCT_FUNCTION (dst->decl))
+ == PROFILE_ABSENT)
+{
+ e->count = bb->count;
+ e->frequency = CGRAPH_FREQ_BASE;
+   }
+  else
+{
+ gcc_assert (e->count >= 0);
+ e->count += bb->count;
+ gcc_assert (e->frequency >= 0);
+
+ int entry_freq = ENTRY_BLOCK_PTR_FOR_FN
+   (DECL_STRUCT_FUNCTION (dst->decl))->frequency;
+ int freq = e->frequency + bb->frequency;
+
+ if (!entry_freq)
+   entry_freq = 1, freq++;
+
+ freq = freq * CGRAPH_FREQ_BASE / entry_freq;
+ if (freq > CGRAPH_FREQ_MAX)
+   freq = CGRAPH_FREQ_MAX;
+ e->frequency = freq;
+   }
+}
+}


how about using early exit for above code, something like:

  if (!e->speculative
  || profile_status_for_fn (DECL_STRUCT_FUNCTION (dst->decl))
 == PROFILE_ABSEN))
{
  e->count = bb->count;
  e->frequency = (e->speculative ? CGRAPH_FREQ_BASE
  : compute_call_stmt_bb_frequency (dst->decl, bb));
  return;
}
 
  gcc_assert (e->count >= 0);

  ...
  ...


  
  /* SRC and DST are going to be merged.  Take SRC's profile and merge it into

 DST so it is not going to be lost.  Destroy SRC's body on the way.  */
@@ -537,19 +577,11 @@ ipa_merge_profiles (struct cgraph_node *dst,
pop_cfun ();
for (e = dst->callees; e; e = e->next_callee)
{
- gcc_assert (!e->speculative);
- e->count = gimple_bb (e->call_stmt)->count;
- e->frequency = compute_call_stmt_bb_frequency
-(dst->decl,
- gimple_bb (e->call_stmt));
+ compute_edge_count_and_frequency(e, dst);
}
for (e = dst->indirect_calls; e; e = e->next_callee)
{
- gcc_assert (!e->speculative);
- e->count = gimple_bb (e->call_stmt)->count;
- e->frequency = compute_call_stmt_bb_frequency
-(dst->decl,
- gimple_bb (e->call_stmt));
+ compute_edge_count_and_frequency(e, dst);
}
src->release_body ();
inline_update_overall_summary (dst);





Re: [Ping] [PATCH, 8/10] aarch64: ccmp insn patterns

2014-10-27 Thread Richard Henderson
On 10/27/2014 12:49 AM, Zhenqiang Chen wrote:
> +  {AARCH64_CC_Z, 0}, /* EQ, Z == 1.  */
> +  {0, AARCH64_CC_Z}, /* NE, Z == 0.  */
> +  {AARCH64_CC_C, 0}, /* CS, C == 1.  */
> +  {0, AARCH64_CC_C}, /* CC, C == 0.  */
> +  {0, 0}, /* MI, not supported*/
> +  {0, 0}, /* PL, not supported*/
> +  {0, 0}, /* VS, not supported*/
> +  {0, 0}, /* VC, not supported*/

Why not go ahead and fill out the table?  You know what needs to go in these
slots, after all.

> +  {AARCH64_CC_C, AARCH64_CC_Z}, /* HI, C ==1 && Z == 0.  */
> +  {AARCH64_CC_Z, AARCH64_CC_C}, /* LS, !(C == 1 && Z == 0).  */
> +  {AARCH64_CC_N | AARCH64_CC_V, AARCH64_CC_N}, /* GE, N == V.  */
> +  {AARCH64_CC_N, AARCH64_CC_N | AARCH64_CC_V}, /* LT, N != V.  */
> +  {AARCH64_CC_N | AARCH64_CC_V, AARCH64_CC_Z}, /* GT, Z == 0 && N == V.  */
> +  {AARCH64_CC_Z, AARCH64_CC_N | AARCH64_CC_V}, /* LE, !(Z == 0 && N == V).  
> */

Perhaps it's me, but does it make things clearer to reduce these?
That is, for the compound conditions, we need not make both sub-conditions be
false, only one of them.  E.g.

  {AARCH64_CC_C, 0} /* HI, C ==1 && Z == 0.  */
  {0, AARCH64_CC_C} /* LS, !(C ==1 && Z == 0) */
  {0, AARCH64_CC_V} /* GE, N == V */
  {AARCH64_CC_V, 0} /* LT, N != V */
  {0, AARCH64_CC_Z} /* GT, Z == 0 && N == V */
  {AARCH64_CC_Z, 0} /* LE, !(Z == 0 && N == V) */

At which point it becomes blindingly obvious that while we can't compress the
table with ~nczv, we can index it with reverse_comparison instead.

> +case 'k':
> +  {
> + int cond_code;
> + rtx op0 = XEXP (x, 0);
> + enum rtx_code mode_code;
> + /* Print a condition (eq, ne, etc) of ccmp.  */
> +
> + if (!COMPARISON_P (x) || !ccmp_cc_register (op0, GET_MODE (op0)))
> +   {
> + output_operand_lossage ("invalid operand for '%%%c'", code);
> + return;
> +   }
> +
> + mode_code = aarch64_ccmp_mode_to_code (GET_MODE (op0));
> + cond_code = aarch64_get_condition_code_1 (CCmode, mode_code);
> + gcc_assert (cond_code >= 0);
> + fputs (aarch64_condition_codes[cond_code], f);
> +  }

Is there a branch with all the patches applied?  I can't look back at the
modified aarch64_get_condition_code_1, but off-hand I can't think of why %m/%M
wouldn't work.  Surely

  aarch64_get_condition_code_1 (GET_MODE (op0), GET_CODE (x))

will yield the correct cond_code.  If it didn't, then surely branches wouldn't
work at all.

These are not some magic new kind of conditions; they're exactly the same.


r~


Re: [PATCHv5][Kasan] Allow to override Asan shadow offset from command line

2014-10-27 Thread Ian Lance Taylor
Yury Gribov  writes:

> --- a/include/libiberty.h
> +++ b/include/libiberty.h
> @@ -655,6 +655,33 @@ extern size_t strnlen (const char *, size_t);
>  extern int strverscmp (const char *, const char *);
>  #endif
>  
> +#if defined(HAVE_DECL_STRTOL) && !HAVE_DECL_STRTOL
> +extern long int strtol (const char *nptr,
> +char **endptr, int base);
> +#endif
> +
> +#if defined(HAVE_DECL_STRTOUL) && !HAVE_DECL_STRTOUL
> +extern unsigned long int strtoul (const char *nptr,
> +  char **endptr, int base);
> +#endif
> +
> +#if defined(HAVE_DECL_STRTOLL) && !HAVE_DECL_STRTOLL
> +__extension__
> +extern long long int strtoll (const char *nptr,
> +  char **endptr, int base);
> +#endif
> +
> +#if defined(HAVE_DECL_STRTOULL) && !HAVE_DECL_STRTOULL
> +__extension__
> +extern unsigned long long int strtoull (const char *nptr,
> +char **endptr, int base);
> +#endif


Your patch is otherwise careful to check that only use "long long" if
the compiler supports it.  Here you are not.  I think you need to wrap
the declarations of strtoll and strtoull in

#ifdef HAVE_LONG_LONG

With that change the libiberty/include patch is OK.

Thanks.

Ian


Re: [Ping] [PATCH, 10/10] aarch64: Handle ccmp in ifcvt to make it work with cmov

2014-10-27 Thread Richard Henderson
On 10/27/2014 12:50 AM, Zhenqiang Chen wrote:
> Good point. It is not ccmp special. It is cbranchcc4 related. If I
> understand correct, without cbranchcc4, we need put the result to  a tmp
> register and generate additional compares, which is not good for
> performance.

It won't be an additional compare.  It is regenerating the compare at a new
location.  The old comparison would be deleted via dead code elimination.

That said,

> +#if HAVE_cbranchcc4
> +  allow_cc_mode = true;
> +#endif

does seem to be the right solution.

If a target has this, we ought to be able to reasonably expect that it's got
all the other patterns that this implies.  If a target is missing them,
hopefully we can get that sorted fairly quickly after this patch is included.

> +#if HAVE_cbranchcc4
> +  if (!(GET_MODE_CLASS (GET_MODE (cmp_a)) == MODE_CC
> + || GET_MODE_CLASS (GET_MODE (cmp_b)) == MODE_CC))
> +#endif

This test looks weird, considering what we're looking for.
I think a better test is

  if (GET_MODE_CLASS (GET_MODE (cmp_a)) != MODE_CC
  || cmp_b != const0_rtx)

Accepting something like (compare (reg:CC a) (reg:CC b)) is definitely
non-canonical.  Even (compare (const_int 0) (reg:CC flags)) is odd.

The ifcvt.c change should go in by itself.
The expr.c change should also be standalone.
The ccmp.c change should probably be merged with the initial commit of ccmp.c.
The aaarch64.md change should probably be merged with the patch that adds
cbranchcc.


r~


Re: Patch RFA: Top-level configure patch: disable go on systems where it doesn't work

2014-10-27 Thread Jan-Benedict Glaw
On Mon, 2014-10-27 08:19:34 -0700, Ian Taylor  wrote:
> On Mon, Oct 27, 2014 at 8:06 AM, Jan-Benedict Glaw  wrote:
> > On Wed, 2014-10-22 20:36:53 -0700, Ian Taylor  wrote:
> > > This patch to the top level GCC configure script disables the go
> > > languages on some systems where it is known to not work.  Bootstrapped
> > > on x86_64-unknown-gnu-linux.
> >
> > I don't have a clue here, but in what way is Go broken for these
> > targets? Bacause this patch "breaks" a number of targets mentioned in
> > contrib/config-list.mk.  Maybe Go didn't work on these, but it at
> > least built.  Is it FUBAR there? Or just little fixes needed?
> 
> I'm not sure exactly what you mean by "breaks," here, as Go is never
> in the set of default languages.  It should only break builds that are
> using --enable-languages=go.  And for those targets, the Go support
> has never worked, so they were already broken.

With its initial commit in 2010, Joern had Go in the
--enable-languages list in contrib/config-list.mk .  This used to work
(read: build succeeded), even if Go wouldn't work (or wasn't built
silently, I didn't check.)

  With this slight change in behavior, we'd probably fix
config-list.mk to reflect these targets where Go would lead to a
configury failure early.

MfG, JBG

-- 
  Jan-Benedict Glaw  jbg...@lug-owl.de  +49-172-7608481
  Signature of:Lauf nicht vor Deinem Glück davon:
  the second  : Es könnte hinter Dir stehen!


signature.asc
Description: Digital signature


[PATCH] -fsanitize=vptr instrumentation (take 2)

2014-10-27 Thread Jakub Jelinek
On Wed, Sep 17, 2014 at 10:27:02AM -0400, Jason Merrill wrote:
> On 09/16/2014 10:56 AM, Jakub Jelinek wrote:
> >vptr-5.C is one Jason mailed me yesterday, clang++ doesn't instrument this
> >and g++ right now doesn't either, build_static_cast_1 certainly isn't called
> >in that case, and I must say I have no idea what should be checked there,
> >where etc.
> 
> What needs to be checked is conversion (in this case implicit) to a virtual
> base; if the vptr doesn't point to a vtable that has the appropriate vbase
> offset, we should complain.
> 
> virtual base conversions are implemented in build_base_path under if
> (virtual_access).

Implemented now.

> >vptr-6.C shows where the this optimization is performed and where it isn't
> >(clang++ has 10 instrumentations in T::h and 1 in S::l, g++ has fewer than
> >that, but not 0 in T::h (1 in S::l is right and needed I think)).
> 
> I agree that 0 is enough for T::h and 1 for S::l.

Based on the further discussions, I've dropped the this optimizations,
perhaps we can tweak the sanopt pass to optimize some unnecessary checks
later on.

> >I hope all of f[1-6] is invalid, I really don't see how we could instrument
> >member accesses otherwise (we'd need to limit to not taking address of it);
> >NULL pointer shouldn't point at a valid object.

Based on the discussions, I'm not instrumenting &p->a or &*&p->a for now,
am instrumenting just p->a or *&p->a.  Until the WG decides what to do with
DR597/DR1531.

> I don't see anything in the standard saying that these are undefined, only
> that trying to access the (non-)object pointed to is undefined.  It would be
> undefined if a conversion to virtual base were involved, i.e.
> 
> struct V: virtual R { };
> 
> // undefined if p doesn't point to a V because of the conversion to
> // virtual base R
> int* f7 (V* p) { return &p->r; }

Yeah, this is instrumented now (including complaining if p is NULL here).

> These conditions were loosened in C++11 by DRs 597 and 1531; before that it
> was reasonable to regard f[1-6] as undefined, and perhaps clang is using the
> earlier interpretation.
> 
> >+  TREE_SIDE_EFFECTS (cond) = 1;
> ...
> >+  TREE_SIDE_EFFECTS (hash) = 1;
> 
> Why do you need to set TREE_SIDE_EFFECTS on these?

Not needed, dropped now.

> >+  if (current_function_decl == NULL_TREE
> >+  || lookup_attribute ("no_sanitize_undefined",
> >+   DECL_ATTRIBUTES (current_function_decl)))
> >+return NULL_TREE;
> 
> When would this be called outside a function?  If for namespace-scope
> variable initializers, I'd think we do want instrumentation.

Changed.

> >+  /* T t; t.foo (); doesn't need instrumentation, if the type is known.  */
> >+  if (is_addr
> >+  && TREE_CODE (op) == ADDR_EXPR
> >+  && DECL_P (TREE_OPERAND (op, 0))
> >+  && same_type_p (type,
> >+  TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (op, 0)
> >+return NULL_TREE;
> 
> You might want to use resolves_to_fixed_type_p in the optimizations.

For now I'd prefer not to do further optimizations, until it is clear that
those optimizations wouldn't remove any checks that could trigger on invalid
programs.

Here is an updated patch, ok if bootstrap/testing passes (so far just
checked with
make -j16 -k check RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} asan.exp 
tsan.exp ubsan.exp'
)?

I haven't implemented the upcast checks Alex Samsonov implemented in clang 
recently,
those aren't -fsanitize=vptr but -fsanitize=alignment and/or
-fsanitize=object-size, so can be done in an incremental patch.

Furthermore, not 100% sure there if say given:
struct S { int a; };
struct T : S { int b[1024]; };
S *foo (T *p) { return (S *) p; }
it is really undefined behavior if p (if not NULL) doesn't point to object
that has at least sizeof (T) bytes in it.  Where does C++ say that e.g.:
S *bar () { S s; return foo ((T *) &s); }
is undefined behavior (assuming the alignment is right)?
struct U { S s; int b[1024]; };
S *foo2 (U *p) { return (S *) p; }
S *bar2 () { S s; return foo2 ((U *) &s); }
is not instrumented and not undefined behavior (again, assuming the
alignment is right)?  I have in mind the common technique where even in GCC
sources e.g. for tree_node union we sometimes allocate smaller sizes (just
to cover the size of some union field), instead of whole union, or
allocating space just for parts of a structure (e.g. if there is a trailing
foo[1] array, allocation size can be done for offsetof(type, foo[0]) etc.).

2014-10-27  Jakub Jelinek  

* flag-types.h (enum sanitize_code): Add SANITIZE_VPTR,
include SANITIZE_VPTR in SANITIZE_UNDEFINED.
* opts.c (common_handle_option): Add -fsanitize=vptr.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_DYNAMIC_TYPE_CACHE_MISS,
BUILT_IN_UBSAN_HANDLE_DYNAMIC_TYPE_CACHE_MISS_ABORT): New.
* ubsan.h (enum ubsan_null_ckind): Add UBSAN_DOWNCAST_POINTER,
UBSAN_DOWNCAST_REFERENCE, UBSAN_UPCAST and UBSAN_CAST_TO_VBASE.
cp/

Re: [GOOGLE] Fix LIPO resolved node reference fixup

2014-10-27 Thread Xinliang David Li
ok.

thanks,

David


On Mon, Oct 27, 2014 at 7:33 AM, Teresa Johnson  wrote:
> Here is the new patch that walks op looking for the reference to addr.
>
> Passes internal benchmarks and regression tests. Ok for google/4_9?
>
> Thanks,
> Teresa
>
> 2014-10-27  Teresa Johnson  
>
> Google ref b/18110567.
> * cgraphbuild.c (fixup_all_refs_1): New function.
> (fixup_all_refs): Ditto.
> (fixup_ref): Walk tree to find and replace ref.
>
> Index: cgraphbuild.c
> ===
> --- cgraphbuild.c   (revision 216735)
> +++ cgraphbuild.c   (working copy)
> @@ -665,6 +665,45 @@ record_references_in_initializer (tree decl, bool
>pointer_set_destroy (visited_nodes);
>  }
>
> +typedef struct _fixup_decl_info {
> +  tree orig_decl;
> +  tree new_decl;
> +} fixup_decl_info;
> +
> +/* Check the tree at TP to see if it contains the original decl stored in
> +   DATA and if so replace it with the new decl. If original decl is
> +   found set WALK_SUBTREES to 0 so the subtree under TP is not traversed.
> +   Returns the updated parent tree T or NULL if no update performed.  */
> +
> +static tree
> +fixup_all_refs_1 (tree *tp, int *walk_subtrees, void *data)
> +{
> +  tree t = *tp;
> +  fixup_decl_info *info = (fixup_decl_info *) data;
> +
> +  /* The original function decl is always the first tree operand.  */
> +  if (TREE_OPERAND (t,0) == info->orig_decl)
> +{
> +  TREE_OPERAND (t,0) = info->new_decl;
> +  *walk_subtrees = 0;
> +  return t;
> +}
> +  return NULL_TREE;
> +}
> +
> +/* Walk the whole tree rooted at TP and invoke fixup_all_refs_1 to
> +   replace any references to the original decl with the new decl
> +   stored in INFO.  */
> +
> +static inline void
> +fixup_all_refs (tree *tp, fixup_decl_info *info)
> +{
> +  tree t = walk_tree (tp, fixup_all_refs_1, info, NULL);
> +  /* This is invoked when we found the original decl, so we expect
> + to have replaced a reference.  */
> +  gcc_assert (t != NULL_TREE);
> +}
> +
>  /* Update any function decl references in base ADDR of operand OP to refer to
> the resolved node.  */
>
> @@ -674,13 +713,16 @@ fixup_ref (gimple, tree addr, tree op)
>addr = get_base_address (addr);
>if (addr && TREE_CODE (addr) == FUNCTION_DECL)
>  {
> -  gcc_assert (TREE_CODE (op) == ADDR_EXPR);
> -  gcc_assert (TREE_OPERAND (op,0) == addr);
>struct cgraph_node *real_callee;
>real_callee = cgraph_lipo_get_resolved_node (addr);
>if (addr == real_callee->decl)
>  return false;
> -  TREE_OPERAND (op,0) = real_callee->decl;
> +  /* We need to locate and update the tree operand within OP
> + that contains ADDR and update it to the real callee's decl.  */
> +  fixup_decl_info info;
> +  info.orig_decl = addr;
> +  info.new_decl = real_callee->decl;
> +  fixup_all_refs (&op, &info);
>  }
>return false;
>  }
>
>
> On Fri, Oct 24, 2014 at 11:46 AM, Teresa Johnson  wrote:
>> On Fri, Oct 24, 2014 at 10:55 AM, Xinliang David Li  
>> wrote:
>>> When orgin_addr == addr, is there a guarantee that this assert:
>>>
>>>  gcc_assert (TREE_OPERAND (op,0) == addr);
>>>
>>> is always true?
>>
>> It should be, that is the assumption of the code that we are trying to
>> enforce with the assert.
>>
>> Teresa
>>
>>>
>>> David
>>>
>>>
>>>
>>> On Fri, Oct 24, 2014 at 10:21 AM, Teresa Johnson  
>>> wrote:
 This patch makes a fix to the reference fixups performed after LIPO
 node resolution, to better handle the case where we are updating the
 base address of a reference.

 Fixes google benchmark and passes regression tests. Ok for google/4_9?

 Thanks,
 Teresa

 2014-10-24  Teresa Johnson  

 Google ref b/18110567.
 * cgraphbuild.c (get_base_address_expr): New function.
 (fixup_ref): Update the op expression for new base address.

 Index: cgraphbuild.c
 ===
 --- cgraphbuild.c   (revision 216667)
 +++ cgraphbuild.c   (working copy)
 @@ -665,13 +665,35 @@ record_references_in_initializer (tree decl, bool
pointer_set_destroy (visited_nodes);
  }

 +/* Similar to get_base_address but returns the ADDR_EXPR pointing
 +   to the base address corresponding to T.  */
 +
 +static tree
 +get_base_address_expr (tree t)
 +{
 +  while (handled_component_p (t))
 +t = TREE_OPERAND (t, 0);
 +
 +  if ((TREE_CODE (t) == MEM_REF
 +   || TREE_CODE (t) == TARGET_MEM_REF)
 +  && TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR)
 +return TREE_OPERAND (t, 0);
 +
 +  return NULL_TREE;
 +}
 +
  /* Update any function decl references in base ADDR of operand OP to 
 refer to
 the resolved node.  */

  static bool
  fixup_ref (gimple, tree addr,

Re: Patch RFA: Top-level configure patch: disable go on systems where it doesn't work

2014-10-27 Thread Ian Taylor
On Mon, Oct 27, 2014 at 9:02 AM, Jan-Benedict Glaw  wrote:
> On Mon, 2014-10-27 08:19:34 -0700, Ian Taylor  wrote:
>> On Mon, Oct 27, 2014 at 8:06 AM, Jan-Benedict Glaw  wrote:
>> > On Wed, 2014-10-22 20:36:53 -0700, Ian Taylor  wrote:
>> > > This patch to the top level GCC configure script disables the go
>> > > languages on some systems where it is known to not work.  Bootstrapped
>> > > on x86_64-unknown-gnu-linux.
>> >
>> > I don't have a clue here, but in what way is Go broken for these
>> > targets? Bacause this patch "breaks" a number of targets mentioned in
>> > contrib/config-list.mk.  Maybe Go didn't work on these, but it at
>> > least built.  Is it FUBAR there? Or just little fixes needed?
>>
>> I'm not sure exactly what you mean by "breaks," here, as Go is never
>> in the set of default languages.  It should only break builds that are
>> using --enable-languages=go.  And for those targets, the Go support
>> has never worked, so they were already broken.
>
> With its initial commit in 2010, Joern had Go in the
> --enable-languages list in contrib/config-list.mk .  This used to work
> (read: build succeeded), even if Go wouldn't work (or wasn't built
> silently, I didn't check.)
>
>   With this slight change in behavior, we'd probably fix
> config-list.mk to reflect these targets where Go would lead to a
> configury failure early.

I think changing config-list.mk is appropriate.

I added this patch to the top-level configure script because someone
observed that it was annoying to configure GCC for Darwin with
--enable-languages=go, have the whole build succeed, and only then
discover that attempts to build Go programs failed with obscure error
messages.  That does not serve our users.

Ian


libgo patch committed: Update to 1.3.3

2014-10-27 Thread Ian Taylor
This patch to libgo updates it to the Go 1.3.3 release.  This is just
a few bug fixes.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff -r 03219f2d0191 libgo/MERGE
--- a/libgo/MERGE   Thu Oct 23 21:57:37 2014 -0700
+++ b/libgo/MERGE   Mon Oct 27 09:34:59 2014 -0700
@@ -1,4 +1,4 @@
-9895f9e36435
+f44017549ff9
 
 The first line of this file holds the Mercurial revision number of the
 last merge done from the master library sources.
diff -r 03219f2d0191 libgo/go/compress/gzip/gzip.go
--- a/libgo/go/compress/gzip/gzip.goThu Oct 23 21:57:37 2014 -0700
+++ b/libgo/go/compress/gzip/gzip.goMon Oct 27 09:34:59 2014 -0700
@@ -245,7 +245,8 @@
return z.err
 }
 
-// Close closes the Writer. It does not close the underlying io.Writer.
+// Close closes the Writer, flushing any unwritten data to the underlying
+// io.Writer, but does not close the underlying io.Writer.
 func (z *Writer) Close() error {
if z.err != nil {
return z.err
diff -r 03219f2d0191 libgo/go/compress/zlib/writer.go
--- a/libgo/go/compress/zlib/writer.go  Thu Oct 23 21:57:37 2014 -0700
+++ b/libgo/go/compress/zlib/writer.go  Mon Oct 27 09:34:59 2014 -0700
@@ -174,7 +174,8 @@
return z.err
 }
 
-// Calling Close does not close the wrapped io.Writer originally passed to 
NewWriter.
+// Close closes the Writer, flushing any unwritten data to the underlying
+// io.Writer, but does not close the underlying io.Writer.
 func (z *Writer) Close() error {
if !z.wroteHeader {
z.err = z.writeHeader()
diff -r 03219f2d0191 libgo/go/crypto/rsa/pkcs1v15.go
--- a/libgo/go/crypto/rsa/pkcs1v15.go   Thu Oct 23 21:57:37 2014 -0700
+++ b/libgo/go/crypto/rsa/pkcs1v15.go   Mon Oct 27 09:34:59 2014 -0700
@@ -53,11 +53,14 @@
if err := checkPub(&priv.PublicKey); err != nil {
return nil, err
}
-   valid, out, err := decryptPKCS1v15(rand, priv, ciphertext)
-   if err == nil && valid == 0 {
-   err = ErrDecryption
+   valid, out, index, err := decryptPKCS1v15(rand, priv, ciphertext)
+   if err != nil {
+   return
}
-
+   if valid == 0 {
+   return nil, ErrDecryption
+   }
+   out = out[index:]
return
 }
 
@@ -80,21 +83,32 @@
}
k := (priv.N.BitLen() + 7) / 8
if k-(len(key)+3+8) < 0 {
-   err = ErrDecryption
-   return
+   return ErrDecryption
}
 
-   valid, msg, err := decryptPKCS1v15(rand, priv, ciphertext)
+   valid, em, index, err := decryptPKCS1v15(rand, priv, ciphertext)
if err != nil {
return
}
 
-   valid &= subtle.ConstantTimeEq(int32(len(msg)), int32(len(key)))
-   subtle.ConstantTimeCopy(valid, key, msg)
+   if len(em) != k {
+   // This should be impossible because decryptPKCS1v15 always
+   // returns the full slice.
+   return ErrDecryption
+   }
+
+   valid &= subtle.ConstantTimeEq(int32(len(em)-index), int32(len(key)))
+   subtle.ConstantTimeCopy(valid, key, em[len(em)-len(key):])
return
 }
 
-func decryptPKCS1v15(rand io.Reader, priv *PrivateKey, ciphertext []byte) 
(valid int, msg []byte, err error) {
+// decryptPKCS1v15 decrypts ciphertext using priv and blinds the operation if
+// rand is not nil. It returns one or zero in valid that indicates whether the
+// plaintext was correctly structured. In either case, the plaintext is
+// returned in em so that it may be read independently of whether it was valid
+// in order to maintain constant memory access patterns. If the plaintext was
+// valid then index contains the index of the original message in em.
+func decryptPKCS1v15(rand io.Reader, priv *PrivateKey, ciphertext []byte) 
(valid int, em []byte, index int, err error) {
k := (priv.N.BitLen() + 7) / 8
if k < 11 {
err = ErrDecryption
@@ -107,7 +121,7 @@
return
}
 
-   em := leftPad(m.Bytes(), k)
+   em = leftPad(m.Bytes(), k)
firstByteIsZero := subtle.ConstantTimeByteEq(em[0], 0)
secondByteIsTwo := subtle.ConstantTimeByteEq(em[1], 2)
 
@@ -115,8 +129,7 @@
// octets, followed by a 0, followed by the message.
//   lookingForIndex: 1 iff we are still looking for the zero.
//   index: the offset of the first zero byte.
-   var lookingForIndex, index int
-   lookingForIndex = 1
+   lookingForIndex := 1
 
for i := 2; i < len(em); i++ {
equals0 := subtle.ConstantTimeByteEq(em[i], 0)
@@ -129,8 +142,8 @@
validPS := subtle.ConstantTimeLessOrEq(2+8, index)
 
valid = firstByteIsZero & secondByteIsTwo & (^lookingForIndex & 1) & 
validPS
-   msg = em[index+1:]
-   return
+   index = subtle.ConstantTimeSelect(valid, index+1, 0)
+   return valid, em, index, nil
 }
 
 // nonZeroRandomBytes fills the giv

C++ PATCH to implement C++14 aggregate NSDMI (N3653)

2014-10-27 Thread Jason Merrill
This patch implements one of the remaining missing features in our C++14 
support.  To support references to the object being initialized, which 
has also been a hole in our support of C++11 constexpr constructors, I 
now pass down both the object being initialized and the initializer 
we're building through the constexpr machinery.  I also track the values 
of temporaries created within the constant-expression, which should 
extend easily to tracking local variables in full C++14 constexpr support.


I'm using PLACEHOLDER_EXPR for references to the object being 
initialized in NSDMI, since its semantics described in tree.def match 
very well what we need here.  Unfortunately, contains_placeholder_p and 
substitute_placeholder_in_expr don't work so well for me; in particular, 
I need to be able to start from the most complete object and build up 
subobject references as we work inward, while s_p_i_e expects to be 
passed a reference to an innermost subobject, so I needed to roll my own 
replacement.


Currently I'm not tracking whether or not a particular class uses 
placeholders, and the changes for tracking the initializer as we build 
it required me to drop the memory optimization I had previously where we 
wouldn't build a new CONSTRUCTOR unless one of the elements changed. 
Hopefully these won't have too much impact on time/space usage.


Tested x86_64-pc-linux-gnu, applying to trunk.

commit c7c58e6d9ee52a501cc002c67c8972798a98814e
Author: Jason Merrill 
Date:   Mon Apr 22 13:17:05 2013 -0400

	Implement N3653 (Member initializers and aggregates) and fix
	references to 'this' in constexpr constructors.
	* class.c (check_field_decls): In C++14 an NSDMI does not make the
	class non-aggregate.
	* constexpr.c (struct constexpr_ctx): New.
	(cxx_bind_parameters_in_call): Handle 'this'.
	(cxx_eval_call_expression): Create new constexpr_ctx.
	(cxx_eval_component_reference): Check CONSTRUCTOR_NO_IMPLICIT_ZERO.
	(initialized_type, init_subob_ctx, verify_ctor_sanity): New.
	(cxx_eval_bare_aggregate): Use them.  Build CONSTRUCTOR early.
	(cxx_eval_vec_init_1): Likewise.
	(cxx_eval_constant_expression) [PARM_DECL]: Allow 'this'.
	[TARGET_EXPR]: Build new constexpr_ctx.
	[PLACEHOLDER_EXPR]: New.
	(cxx_eval_outermost_constant_expr): Build new constexpr_ctx.  Add
	object parameter.
	(is_sub_constant_expr): Build new constexpr_ctx.
	(potential_constant_expression_1): Handle PLACEHOLDER_EXPR.
	Allow 'this'.
	* cp-gimplify.c (cp_gimplify_init_expr): Call replace_placeholders.
	* cp-tree.h (CONSTRUCTOR_NO_IMPLICIT_ZERO): New.
	* error.c (dump_expr): Handle PLACEHOLDER_EXPR.
	* init.c (get_nsdmi): Generate PLACEHOLDER_EXPR.
	* tree.c (lvalue_kind): Handle PLACEHOLDER_EXPR.
	(build_ctor_subob_ref, replace_placeholders): New.
	* typeck2.c (store_init_value): Use replace_placeholders.
	(process_init_constructor_record): Make zero-init before NSDMI
	explicit.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 99bfa95..5f50aff 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -3659,8 +3659,8 @@ check_field_decls (tree t, tree *access_decls,
 
   /* Now that we've removed bit-field widths from DECL_INITIAL,
 	 anything left in DECL_INITIAL is an NSDMI that makes the class
-	 non-aggregate.  */
-  if (DECL_INITIAL (x))
+	 non-aggregate in C++11.  */
+  if (DECL_INITIAL (x) && cxx_dialect < cxx14)
 	CLASSTYPE_NON_AGGREGATE (t) = true;
 
   /* If any field is const, the structure type is pseudo-const.  */
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 30a5e08..cd10766 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -846,14 +846,26 @@ struct constexpr_call_hasher : ggc_hasher
 {
   static hashval_t hash (constexpr_call *);
   static bool equal (constexpr_call *, constexpr_call *);
-		 };
+};
+
+/* The constexpr expansion context.  CALL is the current function
+   expansion, CTOR is the current aggregate initializer, OBJECT is the
+   object being initialized by CTOR, either a VAR_DECL or a _REF.  VALUES
+   is a map of values of variables initialized within the expression.  */
+
+struct constexpr_ctx {
+  constexpr_call *call;
+  hash_map *values;
+  tree ctor;
+  tree object;
+};
 
 /* A table of all constexpr calls that have been evaluated by the
compiler in this translation unit.  */
 
 static GTY (()) hash_table *constexpr_call_table;
 
-static tree cxx_eval_constant_expression (const constexpr_call *, tree,
+static tree cxx_eval_constant_expression (const constexpr_ctx *, tree,
 	  bool, bool, bool *, bool *);
 
 /* Compute a hash value for a constexpr call representation.  */
@@ -964,7 +976,7 @@ lookup_parameter_binding (const constexpr_call *call, tree t)
represented by _CST nodes.  */
 
 static tree
-cxx_eval_builtin_function_call (const constexpr_call *call, tree t,
+cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t,
 bool allow_non_co

[jit] Merger of trunk r216524 into jit branch

2014-10-27 Thread David Malcolm
I've merged svn trunk into the git dmalcolm/jit branch, specifically
from trunk r216746 aka fddbd0194b01f44c5b5f16379fd5405dcf6d71c0
(2014-10-27) bringing in all changes since r216524 aka
d14cac46135326115f0dc589b0b3d2d249d74cf7 (2014-10-21).

Some #include fixups were needed within gcc/jit to track the
header file flattening on trunk.

With this change, jit.sum's # of expected passes remains 4663

gcc/jit/ChangeLog.jit:
* dummy-frontend.c: Drop includes of tree-iterator.h,
tree-ssa-alias.h, gimple-expr.h, gimple.h, gimple-pretty-print.h.
* jit-playback.c: Drop includes of debug.h, langhooks.h,
langhooks-def.h, tree-iterator.h, gimple-expr.h, tree-ssa-alias.h,
gimple.h, gimple-pretty-print.h, diagnostic-core.h, dumpfile.h.




[gomp4] Fix combined directives.

2014-10-27 Thread James Norris

Hi!

This patch fixes an issue in handling combined directives. The
code now accepts clauses for both the loop directive and the
other directive, i.e., parallel or kernels.

OK for gomp4 branch?

Thanks!

Jim

ChangeLog

 2014-10-27  James Norris

 * c/c-parser.c (c_parser_oacc_loop, OACC_LOOP_CLAUSE_MASK): 
Relocate.

 (c_parser_oacc_kernels, c_parser_oacc_parallel): Fix combined
 directives.
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 0480932..f0d7138 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -11857,6 +11857,34 @@ c_parser_oacc_data (location_t loc, c_parser *parser)
 }
 
 /* OpenACC 2.0:
+   # pragma acc loop oacc-loop-clause[optseq] new-line
+ structured-block
+
+   LOC is the location of the #pragma token.
+*/
+
+#define OACC_LOOP_CLAUSE_MASK		\
+	( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_COLLAPSE)		\
+	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION) )
+
+static tree
+c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name)
+{
+  tree stmt, clauses, block;
+
+  strcat (p_name, " loop");
+
+  clauses = c_parser_oacc_all_clauses (parser, OACC_LOOP_CLAUSE_MASK, p_name);
+
+  block = c_begin_compound_stmt (true);
+  stmt = c_parser_omp_for_loop (loc, parser, OACC_LOOP, clauses, NULL);
+  block = c_end_compound_stmt (loc, block, true);
+  add_stmt (block);
+
+  return stmt;
+}
+
+/* OpenACC 2.0:
# pragma acc kernels oacc-kernels-clause[optseq] new-line
  structured-block
 
@@ -11881,60 +11909,32 @@ c_parser_oacc_data (location_t loc, c_parser *parser)
 static tree
 c_parser_oacc_kernels (location_t loc, c_parser *parser, char *p_name)
 {
-  tree stmt, clauses = NULL_TREE, block;
+  tree stmt, clauses, block;
+  omp_clause_mask mask;
+  bool is_combined = false;
 
   strcat (p_name, " kernels");
 
+  mask = OACC_KERNELS_CLAUSE_MASK;
   if (c_parser_next_token_is (parser, CPP_NAME))
 {
-  const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
-  if (strcmp (p, "loop") == 0)
+  stmt = c_parser_peek_token (parser)->value;
+  if (!strcmp ("loop", IDENTIFIER_POINTER (stmt)))
 	{
+	  mask |= OACC_LOOP_CLAUSE_MASK;
+	  strcat (p_name, " loop");
 	  c_parser_consume_token (parser);
-	  block = c_begin_omp_parallel ();
-	  c_parser_oacc_loop (loc, parser, p_name);
-	  stmt = c_finish_oacc_kernels (loc, clauses, block);
-	  OACC_KERNELS_COMBINED (stmt) = 1;
-	  return stmt;
+	  is_combined = true;
 	}
 }
 
-  clauses =  c_parser_oacc_all_clauses (parser, OACC_KERNELS_CLAUSE_MASK,
-	p_name);
+  clauses =  c_parser_oacc_all_clauses (parser, mask, p_name);
 
   block = c_begin_omp_parallel ();
   add_stmt (c_parser_omp_structured_block (parser));
-
   stmt = c_finish_oacc_kernels (loc, clauses, block);
-
-  return stmt;
-}
-
-/* OpenACC 2.0:
-   # pragma acc loop oacc-loop-clause[optseq] new-line
- structured-block
-
-   LOC is the location of the #pragma token.
-*/
-
-#define OACC_LOOP_CLAUSE_MASK		\
-	( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_COLLAPSE)		\
-	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION) )
-
-static tree
-c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name)
-{
-  tree stmt, clauses, block;
-
-  strcat (p_name, " loop");
-
-  clauses = c_parser_oacc_all_clauses (parser, OACC_LOOP_CLAUSE_MASK, p_name);
-
-  block = c_begin_compound_stmt (true);
-  stmt = c_parser_omp_for_loop (loc, parser, OACC_LOOP, clauses, NULL);
-  block = c_end_compound_stmt (loc, block, true);
-  add_stmt (block);
-
+  if (is_combined)
+OACC_KERNELS_COMBINED (stmt) = 1;
   return stmt;
 }
 
@@ -11967,32 +11967,32 @@ c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name)
 static tree
 c_parser_oacc_parallel (location_t loc, c_parser *parser, char *p_name)
 {
-  tree stmt, clauses = NULL_TREE, block;
+  tree stmt, clauses, block;
+  omp_clause_mask mask;
+  bool is_combined = false;
 
   strcat (p_name, " parallel");
 
+  mask = OACC_PARALLEL_CLAUSE_MASK;
   if (c_parser_next_token_is (parser, CPP_NAME))
 {
-  const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
-  if (strcmp (p, "loop") == 0)
+  stmt = c_parser_peek_token (parser)->value;
+  if (!strcmp ("loop", IDENTIFIER_POINTER (stmt)))
 	{
+	  mask |= OACC_LOOP_CLAUSE_MASK;
+	  strcat (p_name, " loops");
 	  c_parser_consume_token (parser);
-	  block = c_begin_omp_parallel ();
-	  c_parser_oacc_loop (loc, parser, p_name);
-	  stmt = c_finish_oacc_parallel (loc, clauses, block);
-	  OACC_PARALLEL_COMBINED (stmt) = 1;
-	  return stmt;
+	  is_combined = true;
 	}
 }
 
-  clauses =  c_parser_oacc_all_clauses (parser, OACC_PARALLEL_CLAUSE_MASK,
-	p_name);
+  clauses =  c_parser_oacc_all_clauses (parser, mask, p_name);
 
   block = c_begin_omp_parallel ();
   add_stmt (c_parser_omp_structured_block (parser));
-
   stmt = c_finish_oacc_parallel (loc, clauses, block);
-
+  if (is_combined)
+OACC_PARALLEL_COMBINED (stmt) = 1;
   return stmt;
 }
 


[google gcc-4_9] make ifunc support available for BIONIC

2014-10-27 Thread Rong Xu
ifunc support is hard-coded as false for BIONIC. This patch removes
this check and let
configure decide whether it should have ifunc support.

Thanks,

-Rong


ifunc_diff
Description: Binary data


Re: [google gcc-4_9] make ifunc support available for BIONIC

2014-10-27 Thread Xinliang David Li
ok.

David

On Mon, Oct 27, 2014 at 11:04 AM, Rong Xu  wrote:
> ifunc support is hard-coded as false for BIONIC. This patch removes
> this check and let
> configure decide whether it should have ifunc support.
>
> Thanks,
>
> -Rong


Re: [gomp4] Fix combined directives.

2014-10-27 Thread Jakub Jelinek
On Mon, Oct 27, 2014 at 01:00:41PM -0500, James Norris wrote:
>  2014-10-27  James Norris

Missing two spaces before <.

>  * c/c-parser.c (c_parser_oacc_loop, OACC_LOOP_CLAUSE_MASK):

Note, gcc/c/ directory has its own ChangeLog, so the c/ prefix doesn't
belong into ChangeLog entries.

> +#define OACC_LOOP_CLAUSE_MASK
> \
> + ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_COLLAPSE) \
> + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION) )
> +
> +static tree
> +c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name)
> +{
> +  tree stmt, clauses, block;
> +
> +  strcat (p_name, " loop");
> +
> +  clauses = c_parser_oacc_all_clauses (parser, OACC_LOOP_CLAUSE_MASK, 
> p_name);

I must say I'm quite surprised that you hardcode the mask here, can loop
never be combined with acc parallel?  Look what I'm doing for OpenMP
constructs?

> +  if (!strcmp ("loop", IDENTIFIER_POINTER (stmt)))
>   {
> +   mask |= OACC_LOOP_CLAUSE_MASK;
> +   strcat (p_name, " loop");
> c_parser_consume_token (parser);
> -   block = c_begin_omp_parallel ();
> -   c_parser_oacc_loop (loc, parser, p_name);
> -   stmt = c_finish_oacc_kernels (loc, clauses, block);
> -   OACC_KERNELS_COMBINED (stmt) = 1;
> -   return stmt;
> +   is_combined = true;
>   }
>  }
>  
> -  clauses =  c_parser_oacc_all_clauses (parser, OACC_KERNELS_CLAUSE_MASK,
> - p_name);
> +  clauses =  c_parser_oacc_all_clauses (parser, mask, p_name);

Doesn't this really mean that you don't parse the the loop as loop?

Also, please avoid the extra space in "=  c_...".

Jakub


Re: [PATCH][optabs] PR63442 libgcc_cmp_return_mode not always return word_mode

2014-10-27 Thread Jeff Law

On 10/27/14 08:24, Jiong Wang wrote:


On 24/10/14 19:41, Jeff Law wrote:

On 10/24/14 08:09, Jiong Wang wrote:

ping~

thanks.

Regards,
Jiong

On 17/10/14 13:04, Jiong Wang wrote:

the cause should be one minor bug in prepare_cmp_insn.

the last mode parameter "pmode" of "prepare_cmp_insn" should match the
mode of the first parameter "x", while during the recursive call of
"prepare_cmp_insn",
x is with mode of targetm.libgcc_cmp_return_mode () and pmode is
assign to word_mode.

generally this is OK, because default libgcc_cmp_return_mode hook
always return word_mode,
but AArch64 has a target private implementation which always return
SImode, so there is a
mismatch which cause a ICE later.

this minor issue is hidding because nearly all other targets use
default hook, and the
compare is rarely invoked.

Thanks

gcc/
 PR target/63442
 * optabs.c (prepare_cmp_insn): Use target hook
"libgcc_cmp_return_mode" instead of word_mode.

This is fine once you have run it through a bootstrap and regression
test.

Any reason not to use RET_MODE since that's already set up with the
result of the target hook?


Ah, it's better to reuse ret_mode, thanks for your carefulness.

patch updated, bootstrapping OK on x86-64 (--enable-languages=c,c++), no
regression. (on top of 216667 which is nearly up-to-date)

ok for trunk?

gcc/
   PR target/63442
   * optabs.c (prepare_cmp_insn): Use "ret_mode" instead of "word_mode".

OK for the trunk once the bootstrap and regression test are complete.

jeff



Re: [PATCH 11/14] Remove VEC_LSHIFT_EXPR and vec_shl_optab

2014-10-27 Thread Alan Lawrence
Ok, I've now pushed the previously-approved first half of this, and am now 
looking at replacing VEC_RSHIFT_EXPR with a VEC_PERM_EXPR. However: does it seem 
reasonable to push this patch 11 (removing VEC_LSHIFT_EXPR and vec_shl_optab) 
out-of-sequence? The patch applies almost-cleanly, there is just a one-line 
conflict with a change to a comment from the previous patch (which I'm skipping)...


Cheers, Alan

Richard Biener wrote:

On Thu, Sep 18, 2014 at 2:35 PM, Alan Lawrence  wrote:

The VEC_LSHIFT_EXPR tree code, and the corresponding vec_shl_optab, seem to
have been added for completeness, providing a counterpart to VEC_RSHIFT_EXPR
and vec_shr_optab. However, whereas VEC_RSHIFT_EXPRs are generated (only) by
the vectorizer, VEC_LSHIFT_EXPR expressions are not generated at all, so
there seems little point in maintaining it.

Bootstrapped on x86_64-unknown-linux-gnu.
aarch64.exp+vect.exp on aarch64-none-elf and aarch64_be-none-elf.


Ah, there it is ;)

Ok.

Thanks,
Richard.


gcc/ChangeLog:

* expr.c (expand_expr_real_2): Remove code handling VEC_LSHIFT_EXPR.
* fold-const.c (const_binop): Likewise.
* cfgexpand.c (expand_debug_expr): Likewise.
* tree-inline.c (estimate_operator_cost, dump_generic_node,
op_code_prio, op_symbol_code): Likewise.
* tree-vect-generic.c (expand_vector_operations_1): Likewise.
* optabs.c (optab_for_tree_code): Likewise.
(expand_vec_shift_expr): Likewise, update comment.
* tree.def: Delete VEC_LSHIFT_EXPR, remove comment.
* optabs.h (expand_vec_shift_expr): Remove comment re.
VEC_LSHIFT_EXPR.
* optabs.def: Remove vec_shl_optab.
* doc/md.texi: Remove references to vec_shr_m.







Re: [pr/63582] Don't even store __int128 types if not supported.

2014-10-27 Thread Joseph S. Myers
On Sat, 25 Oct 2014, DJ Delorie wrote:

> Fixed PR/63582.  Tested with no regressions on x86-64 and ix86.  Ok?
> 
>   * tree.c (build_common_tree_nodes): Don't even store the
>   __int128 types if they're not supported.

OK.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [pr/63582] Don't even store __int128 types if not supported.

2014-10-27 Thread DJ Delorie

> > Fixed PR/63582.  Tested with no regressions on x86-64 and ix86.  Ok?
> > 
> > * tree.c (build_common_tree_nodes): Don't even store the
> > __int128 types if they're not supported.
> 
> OK.

Thanks!  Committed.


Re: genmatch infinite loop during bootstrap on AIX

2014-10-27 Thread David Edelsohn
On Mon, Oct 27, 2014 at 2:37 AM, Richard Biener
 wrote:
> On October 27, 2014 1:49:54 AM CET, David Edelsohn  wrote:
>>Richi,
>>
>>Does genmatch rely on static constructors or implicitly rely on the
>>order of static constructors? Sometimes those cause problems on AIX.
>
> No, it doesn't.
>
>>Bootstrap on AIX succeeds prior to r216631, e.g., r216624.  It works
>>after your commit r216619 to correct Makefile.in, or prior to that by
>>manually editing Makefile.in to add LIBICONV and LIBINTL.
>
> OK, so this would mean that r216631 causes a miscompile for you. Though that 
> does not match up with you seeing this happening during stage1...
>
> Bah.
>
> The place where it is looping is using std::map .
>
> Does -static-libstdc++ work for you host compilers?
>
> Can you try emptying gcc/match.pd for a non-working rev.?

I am trying a bootstrap with an empty match.pd as a short-term
work-around to allow me to continue bootstrapping and testing GCC
trunk on AIX while we debug this.

- David


Re: [PATCH 5/5] add libcc1

2014-10-27 Thread Phil Muldoon

> On 10/10/14 22:58, Jeff Law wrote:
>> On 10/09/14 03:07, Phil Muldoon wrote:

> Given the length of time since the original post and now, can you please do 
> sanity bootstrap to make sure nothing's bitrotted before you commit?

>> I've built both pristine and patched branches with bootstrap enabled.
>> I ran both testsuites and used contrib/compare_tests to make sure
>> everything was as it should be.  compare_tests reports everything as
>> fine.  One minor change I found, was due to some ongoing work on
>> hash_tables.  It seems to parameterless constructor call for a new
>> hash table has been removed.  This was trivially fixed with the patch
>> attached.  Even though (to me) it is obvious, what do you think?

> Looks fine to me.
>
> jeff

> On 24/10/14 08:43, Jakub Jelinek wrote:

> So, if these are the only non-obvious changes you needed, please go
> ahead and commit.

>Jakub

Thanks.  This patch has now been committed.  Bootstrap and
testsuite pre and post are as expected.  Thanks for your help
in getting this patch-series committed.

Cheers

Phil



[gimple-classes] New branch (was Re: [RFC] Compile-time gimple-checking (again))

2014-10-27 Thread David Malcolm
On Thu, 2014-10-16 at 12:36 -0600, Jeff Law wrote:
> On 10/16/14 05:27, Richard Biener wrote:
> >>
> >> This required numerous essentially mechanical changes to the patches
> >> e.g. for the big reworking of cgraph functions to be methods.  I've been
> >> working on the assumption that these various changes aren't going to
> >> require a re-review.
> If they're fairly mechanical, then I think we're OK.
> 
> >>
> >> I also removed the unloved as_a/dyn_cast methods from the gimple base
> >> class in favor of as_a<>/dyn_cast<> functions from is-a.h
> OK.
> 
> >> Are people still happy with the proposed naming from:
> >>https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00346.html
> >> (incorporating the "pointerness" change of gimple to require "gimple
> >> *").
> >>
> >> How should I proceed?  The proposal is going to require one or more
> >> auto-generated "megapatches", and such a patch is going to bitrot
> >> immediately... and break everyone else's patches and branches that touch
> >> the middle-end if/when it goes in (the "gimple" to "gimple *" change is
> >> the issue here).
> >>
> >> I'm thinking that I could attempt to put all of the handwritten stuff
> >> onto a (git) branch, or possibly put the .patch files though a renaming
> >> script to partially automated things first e.g. by updating the patches
> >> to use explicit pointers for *subclasses* as the patchkit introduces
> >> uses of subclasses.
> >>
> >> Then the big "gimple" to "gimple *" conversion could be done mostly
> >> separately, once the rest of the branch was ready to go in.  That would
> >> allow trunk to be easily mergable *into* the branch for all except the
> >> final autogenerated change.  We'd avoid introducing lots of "const_"
> >> typedefs, the only weird thing would be (until the final patch goes in)
> >> having "gimple" implicitly be a ptr, whereas the subclasses would
> >> require explicit ptr syntax.
> >>
> >> A merging strategy could be:
> >>   - keep the branch hand-written, with ChangeLog.gimple-classes files
> >>   - develop on branch, fixing more accessors, posting to gcc-patches
> >>   - merge from trunk to the branch periodically
> >>   - when ready, merge from branch to trunk in one commit
> >>   - apply the final autogenerated change of "gimple" to "gimple *" in one
> >> commit to trunk.
> >>
> >> That way everything is diffable, and the awkward autogenerated megapatch
> >> is isolated as one change.
> >>
> >> Thoughts?
> >
> > Overall I'm fine with both conversions and any order they happen in
> > given both happen (I'm also fine to only do gimple -> gimple * for this
> > stage1).  I think timing-wise you should now have the burden to wait
> > for the end of stage1 (and thus all pending big merges).  I'm fine doing
> > this refactoring very early in stage3.  How you develop the patch is
> > left to you - I don't have strong opinions here.
> No strong opinions here other than I think this stuff should go forward 
> during this stage1/early stage3.  David delayed the work until after 
> 4.9.1 was released and is doing a massive renaming -- we shouldn't 
> penalize him for meeting our requests.  So as long as we're in agreement 
> this stuff is suitable now or early in stage3, then I'm comfortable with 
> either approach.

Thanks.

I've created a new branch within git: "dmalcolm/gimple-classes" to track
this work.

It can be seen at:
https://gcc.gnu.org/git/?p=gcc.git;a=shortlog;h=refs/heads/dmalcolm/gimple-classes
(branching from r216157 aka fc222f445c6108418196a1b48703d350f3c3d45a)

I've pushed 92 patches there so far, which I'm about to post to this
list, with the prefix "[gimple-classes]".

I'm accumulating the ChangeLogs into a gcc/ChangeLog.gimple-classes
file, as well as in the commit messages.

Dave



Re: genmatch infinite loop during bootstrap on AIX

2014-10-27 Thread Richard Biener
On October 27, 2014 8:13:09 PM CET, David Edelsohn  wrote:
>On Mon, Oct 27, 2014 at 2:37 AM, Richard Biener
> wrote:
>> On October 27, 2014 1:49:54 AM CET, David Edelsohn
> wrote:
>>>Richi,
>>>
>>>Does genmatch rely on static constructors or implicitly rely on the
>>>order of static constructors? Sometimes those cause problems on AIX.
>>
>> No, it doesn't.
>>
>>>Bootstrap on AIX succeeds prior to r216631, e.g., r216624.  It works
>>>after your commit r216619 to correct Makefile.in, or prior to that by
>>>manually editing Makefile.in to add LIBICONV and LIBINTL.
>>
>> OK, so this would mean that r216631 causes a miscompile for you.
>Though that does not match up with you seeing this happening during
>stage1...
>>
>> Bah.
>>
>> The place where it is looping is using std::map unsigned>.
>>
>> Does -static-libstdc++ work for you host compilers?
>>
>> Can you try emptying gcc/match.pd for a non-working rev.?
>
>I am trying a bootstrap with an empty match.pd as a short-term
>work-around to allow me to continue bootstrapping and testing GCC
>trunk on AIX while we debug this.

Not sure if you will be very successful with this :/  I've requested access to 
the compile-farm so I cab reproduce it. The ppc-linux bootstrap went fine for 
me.

The stage1 issue must be either host-compiler related or a build machinery 
issue. I suspect the stage2 issue to be a miscompile of the stage1 libstdc++ or 
of stage2 genmatch.

Richard.

>- David




Re: Ping: PR 63340: Avoid harmful union classes in ira-costs.c

2014-10-27 Thread Vladimir Makarov

On 2014-10-27 7:12 AM, Richard Sandiford wrote:

Two-patch IRA series to fix PR 63340:

https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02636.html


"This significantly reduces the number of redundant classes in the
cost_classes structure, so it's also a minor compile-time improvement.
The time for -O0 fold-const.ii on x86_64 improved by ~0.5%.
(record_reg_classes was previously the hottest function in the
compilation, after the patch it goes down to number 2, though
it's still costly.)

I did a diff of the assembly output before and after the patch
on x86_64-linux-gnu, powerpc64-linux-gnu, s390x-linux-gnu and
aarch64-linux-gnu.  There were some minor register allocation
changes in a handful files, but nothing major."


Thanks for checking the code and testing 4 platforms.  The area is very 
sensitive as some target-dependent hooks are not defined well for all 
classes.  That is a problem of targets and if something is broken by the 
patch it probably should be fixed in target-dependent code.


The patch is ok.  It would be ok to commit even if it did not solve the 
problems as it speeds up one of the most time consuming code in RA.



https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02637.html



The patch is also ok.


It also fixes PR 63403.



So you can commit the both of them.

Richard, thanks for working on this.  As usually, your patches and 
solutions are very high quality ones.




Re: [PATCH 11/14] Remove VEC_LSHIFT_EXPR and vec_shl_optab

2014-10-27 Thread Richard Biener
On October 27, 2014 7:43:05 PM CET, Alan Lawrence  wrote:
>Ok, I've now pushed the previously-approved first half of this, and am
>now 
>looking at replacing VEC_RSHIFT_EXPR with a VEC_PERM_EXPR. However:
>does it seem 
>reasonable to push this patch 11 (removing VEC_LSHIFT_EXPR and
>vec_shl_optab) 
>out-of-sequence? The patch applies almost-cleanly, there is just a
>one-line 
>conflict with a change to a comment from the previous patch (which I'm
>skipping)...

Sure - please go ahead!

Thanks,
Richard.

>Cheers, Alan
>
>Richard Biener wrote:
>> On Thu, Sep 18, 2014 at 2:35 PM, Alan Lawrence
> wrote:
>>> The VEC_LSHIFT_EXPR tree code, and the corresponding vec_shl_optab,
>seem to
>>> have been added for completeness, providing a counterpart to
>VEC_RSHIFT_EXPR
>>> and vec_shr_optab. However, whereas VEC_RSHIFT_EXPRs are generated
>(only) by
>>> the vectorizer, VEC_LSHIFT_EXPR expressions are not generated at
>all, so
>>> there seems little point in maintaining it.
>>>
>>> Bootstrapped on x86_64-unknown-linux-gnu.
>>> aarch64.exp+vect.exp on aarch64-none-elf and aarch64_be-none-elf.
>> 
>> Ah, there it is ;)
>> 
>> Ok.
>> 
>> Thanks,
>> Richard.
>> 
>>> gcc/ChangeLog:
>>>
>>> * expr.c (expand_expr_real_2): Remove code handling
>VEC_LSHIFT_EXPR.
>>> * fold-const.c (const_binop): Likewise.
>>> * cfgexpand.c (expand_debug_expr): Likewise.
>>> * tree-inline.c (estimate_operator_cost, dump_generic_node,
>>> op_code_prio, op_symbol_code): Likewise.
>>> * tree-vect-generic.c (expand_vector_operations_1):
>Likewise.
>>> * optabs.c (optab_for_tree_code): Likewise.
>>> (expand_vec_shift_expr): Likewise, update comment.
>>> * tree.def: Delete VEC_LSHIFT_EXPR, remove comment.
>>> * optabs.h (expand_vec_shift_expr): Remove comment re.
>>> VEC_LSHIFT_EXPR.
>>> * optabs.def: Remove vec_shl_optab.
>>> * doc/md.texi: Remove references to vec_shr_m.
>> 




[jit] Merger of trunk *r216746* into jit branch

2014-10-27 Thread David Malcolm
On Mon, 2014-10-27 at 13:50 -0400, David Malcolm wrote:
> I've merged svn trunk into the git dmalcolm/jit branch, specifically
> from trunk r216746 aka fddbd0194b01f44c5b5f16379fd5405dcf6d71c0
> (2014-10-27) bringing in all changes since r216524 aka
> d14cac46135326115f0dc589b0b3d2d249d74cf7 (2014-10-21).
> 
> Some #include fixups were needed within gcc/jit to track the
> header file flattening on trunk.
> 
> With this change, jit.sum's # of expected passes remains 4663
> 
> gcc/jit/ChangeLog.jit:
>   * dummy-frontend.c: Drop includes of tree-iterator.h,
>   tree-ssa-alias.h, gimple-expr.h, gimple.h, gimple-pretty-print.h.
>   * jit-playback.c: Drop includes of debug.h, langhooks.h,
>   langhooks-def.h, tree-iterator.h, gimple-expr.h, tree-ssa-alias.h,
>   gimple.h, gimple-pretty-print.h, diagnostic-core.h, dumpfile.h.

FWIW, subject of prior email should have referred to r216746, not
r216524; sorry.  The text body was correct.




[gimple-classes, committed 00/92] Initial slew of commits

2014-10-27 Thread David Malcolm
These patches move the type-checking of gimple statement accessors
from run-time to compile-time, for about half of the accessors.

I've pushed them to the git branch "dmalcolm/gimple-classes", which
can be seen at:
https://gcc.gnu.org/git/?p=gcc.git;a=shortlog;h=refs/heads/dmalcolm/gimple-classes

Patches 01-87:
  These correspond to patches 02-89 from the patch kit I posted in
  April, and approved by Jeff (with various caveats), rebased against trunk,
  and eliminating the as_a_gimple_foo and dyn_cast_gimple_foo *methods* in
  favor of direct use of as_a <>/dyn_cast <> from is-a.h
  I used a script [1] to add references to the initial patch kit and Jeff's
  reviews to the commit messages.

  They introduce various new gimple subclasses, along with typedefs for the
  const/non-const variants.  Richi didn't want these typedefs, so I
  immediately undo this part, renaming them in followups... (doing it this
  way was the least error-prone way):

Patch 88: "Preparatory work before subclass renaming":
  Various variables have names that confuse my subclass renaming
  script.  Rename them now to simplify the mass-renaming.

Patches 89 and 90 only make sense together; the former is handwritten, the
latter autogenerated:
  Patch 89: "Eliminate subclass typedefs from coretypes.h"
This patch eliminates the const/non-const typedefs for the gimple
subclasses.
  Patch 90: "Automated renaming of gimple subclasses"
This patch renames the gimple subclasses based on the pattern from
https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00346.html
e.g.
  "gimple_switch" becomes "gswitch *".
  "const_gimple_bind" becomes "const gbind *".
  i.e. pointers to all gimple *subclasses* now must be explicitly referred
  to with "*".   "gimple" is still implicitly a pointer, to minimize noise
  when diffing against trunk.
  The renaming script was:

https://github.com/davidmalcolm/gcc-refactoring-scripts/blob/master/rename_gimple_subclasses.py

Patch 91: "Remove out-of-date references to typedefs":
  Fix some now-bogus comments.

Patch 92: "Update gimple.texi class hierarchy diagram"

I've successfully bootstrapped and regrtested patches 01-90 on
x86_64-unknown-linux-gnu (Fedora 20) - same results relative to
an unpatched control bootstrap of the branchpoint (r216157).

For reference, here's what the class hierarchy diagram from
gimple.texi looks like after these patches, with the new subclass
names (e.g. "gassign" and "gphi"):

   gimple_statement_base
 |layout: GSS_BASE
 |used for 4 codes: GIMPLE_ERROR_MARK
 |  GIMPLE_NOP
 |  GIMPLE_OMP_SECTIONS_SWITCH
 |  GIMPLE_PREDICT
 |
 + gimple_statement_with_ops_base
 |   |(no GSS layout)
 |   |
 |   + gimple_statement_with_ops
 |   |   |layout: GSS_WITH_OPS
 |   |   |
 |   |   + gcond
 |   |   | code: GIMPLE_COND
 |   |   |
 |   |   + gdebug
 |   |   | code: GIMPLE_DEBUG
 |   |   |
 |   |   + ggoto
 |   |   | code: GIMPLE_GOTO
 |   |   |
 |   |   + glabel
 |   |   | code: GIMPLE_LABEL
 |   |   |
 |   |   + gswitch
 |   | code: GIMPLE_SWITCH
 |   |
 |   + gimple_statement_with_memory_ops_base
 |   |layout: GSS_WITH_MEM_OPS_BASE
 |   |
 |   + gimple_statement_with_memory_ops
 |   |   |layout: GSS_WITH_MEM_OPS
 |   |   |
 |   |   + gassign
 |   |   |code GIMPLE_ASSIGN
 |   |   |
 |   |   + greturn
 |   |code GIMPLE_RETURN
 |   |
 |   + gcall
 |   |layout: GSS_CALL, code: GIMPLE_CALL
 |   |
 |   + gasm
 |   |layout: GSS_ASM, code: GIMPLE_ASM
 |   |
 |   + gtransaction
 |layout: GSS_TRANSACTION, code: GIMPLE_TRANSACTION
 |
 + gimple_statement_omp
 |   |layout: GSS_OMP.  Used for code GIMPLE_OMP_SECTION
 |   |
 |   + gomp_critical
 |   |layout: GSS_OMP_CRITICAL, code: GIMPLE_OMP_CRITICAL
 |   |
 |   + gomp_for
 |   |layout: GSS_OMP_FOR, code: GIMPLE_OMP_FOR
 |   |
 |   + gomp_parallel_layout
 |   |   |layout: GSS_OMP_PARALLEL_LAYOUT
 |   |   |
 |   |   + gimple_statement_omp_taskreg
 |   |   |   |
 |   |   |   + gomp_parallel
 |   |   |   |code: GIMPLE_OMP_PARALLEL
 |   |   |   |
 |   |   |   + gomp_task
 |   |   |code: GIMPLE_OMP_TASK
 |   |   |
 |   |   + gimple_statement_omp_target
 |   |code: GIMPLE_OMP_TARGET
 |   |
 |   + gomp_sections
 |   |layout: GSS_OMP_SECTIONS, code: GIMPLE_OMP_SECTIONS
 |   |
 |   + gimple_statement_omp_single_layout
 |   |layout: GSS_OMP_SINGLE_LAYOUT
 |   |
 |   + gomp_single
 |   |code: GIMPLE_OMP_SINGLE
 |  

[gimple-classes, committed 09/92] Update ssa_prop_visit_phi_fn callbacks to take a gimple_phi

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 10/89] Update ssa_prop_visit_phi_fn callbacks to take a gimple_phi
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01216.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK when prerequisites have gone in.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00619.html

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/ChangeLog.gimple-classes | 16 
 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 +-
 7 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 33a4f87..bd635c6 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,21 @@
 2014-10-24  David Malcolm  
 
+   Update ssa_prop_visit_phi_fn callbacks to take a gimple_phi
+
+   * 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.
+
+2014-10-24  David Malcolm  
+
Introduce gimple_phi_iterator
 
* gimple-iterator.h (struct gimple_phi_iterator): New subclass of
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index 9eb77e8..25dcad8 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -399,7 +399,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 ce23019..19f2c32 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1018,7 +1018,7 @@ ccp_lattice_meet (ccp_prop_value_t *val1, 
ccp_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;
   ccp_prop_value_t *old_val, new_val;
diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c
index 367..f7e8566 100644
--- a/gcc/tree-ssa-copy.c
+++ b/gcc/tree-ssa-copy.c
@@ -331,7 +331,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 2e337e4..6ed41bd 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -324,7 +324,7 @@ simulate_stmt (gimple stmt)
 
   if (gimple_code (stmt) == GIMPLE_PHI)
 {
-  val = ssa_prop_visit_phi (stmt);
+  val = ssa_prop_visit_phi (as_a  (stmt));
   output_name = gimple_phi_result (stmt);
 }
   else
diff --git a/gcc/tree-ssa-propagate.h b/gcc/tree-ssa-propagate.h
index 2d8d876..1e1a3a1 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 2e19273..289f0ba 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -8467,7 +8467,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.8.5.3



[gimple-classes, committed 02/92] Introduce gimple_bind and use it for accessors.

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 03/89] Introduce gimple_bind and use it for accessors.
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01190.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> This is fine, with the same requested changes as #2; specifically
> using an explicit cast
> rather than hiding the conversion in a method. Once those changes are
> in place, it's good for 4.9.1.
in https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01485.html

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_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.
(lower_omp_for): 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.

Conflicts:
gcc/omp-low.c
gcc/tree-nested.c
---
 gcc/ChangeLog.gimple-classes  | 89 +++
 gcc/c-family/ChangeLog.gimple-classes | 12 +
 gcc/c-family/c-gimplify.c |  4 +-
 gcc/coretypes.h   |  4 ++
 gcc/gdb

[gimple-classes, committed 04/92] Introduce gimple_assign and use it in various places

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 05/89] Introduce gimple_assign and use it in various places
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01151.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> Similar to the gimple_cond patch. Update for the changes in the
> prerequisites and it's good to go. Please post final version for
> archival purposes.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00596.html

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.
(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, 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/ChangeLog.gimple-classes | 65 
 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 | 13 +
 gcc/gimple.h | 29 
 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 
 14 files changed, 151 insertions(+), 57 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index a7d756e..f737e3c 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,70 @@
 2014-10-24  David Malcolm  
 
+   Introduce gimple_assign and use it in various places
+
+   * 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.
+   (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-classes, committed 06/92] Introduce gimple_debug and use it in a few places

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 07/89] Introduce gimple_debug and use it in a few places
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01192.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> Same as prior patches.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00598.html

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.
(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/ChangeLog.gimple-classes | 37 +
 gcc/coretypes.h  |  4 
 gcc/gdbhooks.py  |  2 ++
 gcc/gimple-pretty-print.c|  4 ++--
 gcc/gimple.c | 20 +++-
 gcc/gimple.h | 26 --
 gcc/tree-inline.c| 16 +---
 gcc/tree-inline.h|  2 +-
 8 files changed, 90 insertions(+), 21 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 68eb669..ec16551 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,42 @@
 2014-10-24  David Malcolm  
 
+   Introduce gimple_debug and use it in a few places
+
+   * 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.
+   (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.
+
+2014-10-24  David Malcolm  
+
Introduce gimple_label and use it in a few places
 
* coretypes.h (gimple_label): New typedef.
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 24c6352..a338599 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -94,6 +94,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 7514e45..455fa5c 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -460,6 +460,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-classes, committed 05/92] Introduce gimple_label and use it in a few places

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 06/89] Introduce gimple_label and use it in a few places
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01152.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> Same as prior patches for gimple_cond and gimple_assign.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00597.html

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.
(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/ChangeLog.gimple-classes | 32 
 gcc/coretypes.h  |  4 
 gcc/gdbhooks.py  |  2 ++
 gcc/gimple-pretty-print.c|  4 ++--
 gcc/gimple.c |  5 +++--
 gcc/gimple.h | 24 +++-
 gcc/gimplify.c   |  6 +++---
 gcc/tree-cfg.c   |  4 ++--
 gcc/tree-switch-conversion.c |  2 +-
 9 files changed, 72 insertions(+), 11 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index f737e3c..68eb669 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,37 @@
 2014-10-24  David Malcolm  
 
+   Introduce gimple_label and use it in a few places
+
+   * 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.
+   (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.
+
+2014-10-24  David Malcolm  
+
Introduce gimple_assign and use it in various places
 
* coretypes.h (gimple_assign): New typedef.
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index f8aeb94..24c6352 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -94,6 +94,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 d5162de..7514e45 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -460,6 +460,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 482fb1f..9766d57 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -863,7 +863,7 @@ dump_gimple_cond (pretty_printer *buffer, gimple_cond gs, 
int spc, in

[gimple-classes, committed 14/92] tree-ssa-loop-manip.c: use gimple_phi in three places

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 15/89] tree-ssa-loop-manip.c: use gimple_phi in three places
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01217.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK when prerequisites have gone in.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00625.html

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/ChangeLog.gimple-classes | 8 
 gcc/tree-ssa-loop-manip.c| 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 533002f..1e636be 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,13 @@
 2014-10-24  David Malcolm  
 
+   tree-ssa-loop-manip.c: use gimple_phi in three places
+
+   * 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".
+
+2014-10-24  David Malcolm  
+
tree-ssa-loop-niter.c: use gimple_phi in a few places
 
* tree-ssa-loop-niter.c (chain_of_csts_start): Return a gimple_phi
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 3acf7fb..edc913d 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.8.5.3



[gimple-classes, committed 01/92] Introduce gimple_switch and use it in various places

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 02/89] Introduce gimple_switch and use it in various places
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01154.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> So it sounds like Richi really prefers the explicit casting rather
> than member functions. It seems like a minor issue to me, so let's go
> with explicit casting.
> OK for the trunk with that change. Per Richi's request, please
> hold off until 4.9.1 goes out the door (~2 months?)
in https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01475.html

gcc/
* gimple.h (gimple_statement_switch): New subclass of
gimple_statement_with_ops, adding the invariant that
stmt->code == GIMPLE_SWITCH.
(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.

Conflicts:
gcc/coretypes.h
gcc/tree-cfg.c
gcc/tree-ssa-dom.c
gcc/tree-ssa-uncprop.c
gcc/tree-vrp.c
---
 gcc/ChangeLog.gimple-classes | 100 +++

[gimple-classes, committed 03/92] Introduce gimple_cond and use it in various places

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 04/89] Introduce gimple_cond and use it in various places
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01153.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> This is generally fine. It needs minor tweaks due to the change in how
> we're handling const stuff, but otherwise it looks ready to go.
> So, once you've flushed the queue of dependencies and reworked
> this to fit into the new world order, it's OK for the trunk. Please
> post the final version for archival purposes.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00595.html

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.
(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-pre.c (eliminate_dom_walker::before_dom_children):
Likewise.
* tree-vrp.c (simplify_stmt_using_ranges): Likewise.

* cfgloopmanip.c (create_empty_loop_on_edge): Update local to be a
gimple_cond.
* 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-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/ChangeLog.gimple-classes | 66 
 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 | 31 +
 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-pre.c   |  4 +--
 gcc/tree-ssa-threadedge.c|  8 +++---
 gcc/tree-ssa-threadedge.h|  2 +-
 gcc/tree-vrp.c   |  6 ++--
 17 files changed, 149 insertions(+), 49 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index dc1edc86..a7d756e 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,71 @@
 2014-10-24  David Malcolm  
 
+   Introduce gimple_cond and use it in various places
+
+   * 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.
+   (is_a_helper ::test): New.
+   

[gimple-classes, committed 19/92] Introduce gimple_return

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 21/89] Introduce gimple_return
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01180.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK after fixing up the naming/const stuff as discussed for prior
> patches.
> That applies to 22-30. Make sure to take care of
> the pretty printers per Trevor's comments as well. He indicated those
> were missing in a couple of those patches.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00628.html

gcc/
* coretypes.h (gimple_return): New typedef.
(const_gimple_return): New typedef.

* gimple.h (gimple_statement_return): New subclass of
gimple_statement_with_memory_ops, adding the invariant that
stmt->code == GIMPLE_RETURN.
(is_a_helper ::test): New.
(gimple_build_return): Return a gimple_return rather
than a plain gimple.

* gimple.c (gimple_build_return): Return a gimple_return rather
than a plain gimple.

* cgraphunit.c (expand_thunk): Convert local from a gimple to
a gimple_return.

* gimple-low.c (struct return_statements_t): Convert field "stmt"
from a gimple to a gimple_return.
(lower_gimple_return): Convert local from a gimple to a
gimple_return.

* gimple-pretty-print.c (dump_gimple_return): Require a
gimple_return rather than a plain gimple.
(pp_gimple_stmt_1): Add a checked cast to gimple_return within
case GIMPLE_RETURN of switch statement.

* gimplify.c (gimplify_return_expr): Convert locals from
gimple to gimple_return.

* ipa-split.c (split_function): Likewise.

* tree-cfg.c (verify_gimple_assign): Require a gimple_return
rather than a plain gimple.
(verify_gimple_stmt): Add checked cast to gimple_return within
case GIMPLE_RETURN of switch statement.

* tree-tailcall.c (adjust_return_value): Convert local from
gimple to gimple_return.
---
 gcc/ChangeLog.gimple-classes | 43 +++
 gcc/cgraphunit.c |  2 +-
 gcc/coretypes.h  |  4 
 gcc/gimple-low.c |  4 ++--
 gcc/gimple-pretty-print.c|  4 ++--
 gcc/gimple.c |  6 --
 gcc/gimple.h | 24 +---
 gcc/gimplify.c   |  4 ++--
 gcc/ipa-split.c  |  2 +-
 gcc/omp-low.c|  3 ++-
 gcc/tree-cfg.c   |  4 ++--
 gcc/tree-tailcall.c  |  3 ++-
 12 files changed, 86 insertions(+), 17 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index ba0bde6..5508788 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,48 @@
 2014-10-24  David Malcolm  
 
+   Introduce gimple_return
+
+   * coretypes.h (gimple_return): New typedef.
+   (const_gimple_return): New typedef.
+
+   * gimple.h (gimple_statement_return): New subclass of
+   gimple_statement_with_memory_ops, adding the invariant that
+   stmt->code == GIMPLE_RETURN.
+   (is_a_helper ::test): New.
+   (gimple_build_return): Return a gimple_return rather
+   than a plain gimple.
+
+   * gimple.c (gimple_build_return): Return a gimple_return rather
+   than a plain gimple.
+
+   * cgraphunit.c (expand_thunk): Convert local from a gimple to
+   a gimple_return.
+
+   * gimple-low.c (struct return_statements_t): Convert field "stmt"
+   from a gimple to a gimple_return.
+   (lower_gimple_return): Convert local from a gimple to a
+   gimple_return.
+
+   * gimple-pretty-print.c (dump_gimple_return): Require a
+   gimple_return rather than a plain gimple.
+   (pp_gimple_stmt_1): Add a checked cast to gimple_return within
+   case GIMPLE_RETURN of switch statement.
+
+   * gimplify.c (gimplify_return_expr): Convert locals from
+   gimple to gimple_return.
+
+   * ipa-split.c (split_function): Likewise.
+
+   * tree-cfg.c (verify_gimple_assign): Require a gimple_return
+   rather than a plain gimple.
+   (verify_gimple_stmt): Add checked cast to gimple_return within
+   case GIMPLE_RETURN of switch statement.
+
+   * tree-tailcall.c (adjust_return_value): Convert local from
+   gimple to gimple_return.
+
+2014-10-24  David Malcolm  
+
Introduce gimple_call
 
* coretypes.h (gimple_call): New typedef.
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 723ec5e..98d34be 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1496,7 +1496,7 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool 
force_gimple_thunk)
   tree restmp = NULL;
 
   gimple_call call;
-  gimple ret;
+  gimple_return ret;
 
   if (in_lto_p)
get_body ();
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 4981e7c..f726053 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -114,6 +114,10 @@ struct gi

[gimple-classes, committed 25/92] Introduce gimple_eh_must_not_throw

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 27/89] Introduce gimple_eh_must_not_throw
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01218.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK after fixing up the naming/const stuff as discussed for prior
> patches.
> That applies to 22-30. Make sure to take care of
> the pretty printers per Trevor's comments as well. He indicated those
> were missing in a couple of those patches.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00628.html

gcc/
* coretypes.h (gimple_eh_must_not_throw): New typedef.
(const_gimple_eh_must_not_throw): New typedef.

* gimple-pretty-print.c (dump_gimple_eh_must_not_throw): Require
a gimple_eh_must_not_throw rather than a plain gimple.
(pp_gimple_stmt_1): Add a checked cast to gimple_eh_must_not_throw
within GIMPLE_EH_MUST_NOT_THROW case of switch statement.

* gimple-streamer-in.c (input_gimple_stmt): Likewise.

* gimple-streamer-out.c (output_gimple_stmt): Likewise.

* gimple.c (gimple_build_eh_must_not_throw): Return a
gimple_eh_must_not_throw rather than a plain gimple.

* gimple.h (gimple_build_eh_must_not_throw): Return a
gimple_eh_must_not_throw rather than a plain gimple.
(gimple_eh_must_not_throw_fndecl): Require a
gimple_eh_must_not_throw rather than a plain gimple.
(gimple_eh_must_not_throw_set_fndecl): Likewise.

* tree-eh.c (lower_eh_must_not_throw): Add checked cast.
---
 gcc/ChangeLog.gimple-classes | 27 +++
 gcc/coretypes.h  |  4 
 gcc/gimple-pretty-print.c|  8 +---
 gcc/gimple-streamer-in.c |  4 +++-
 gcc/gimple-streamer-out.c|  5 -
 gcc/gimple.c |  6 --
 gcc/gimple.h |  9 -
 gcc/tree-eh.c|  3 ++-
 8 files changed, 53 insertions(+), 13 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index e91317c..dd39ce6 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,32 @@
 2014-10-24  David Malcolm  
 
+   Introduce gimple_eh_must_not_throw
+
+   * coretypes.h (gimple_eh_must_not_throw): New typedef.
+   (const_gimple_eh_must_not_throw): New typedef.
+
+   * gimple-pretty-print.c (dump_gimple_eh_must_not_throw): Require
+   a gimple_eh_must_not_throw rather than a plain gimple.
+   (pp_gimple_stmt_1): Add a checked cast to gimple_eh_must_not_throw
+   within GIMPLE_EH_MUST_NOT_THROW case of switch statement.
+
+   * gimple-streamer-in.c (input_gimple_stmt): Likewise.
+
+   * gimple-streamer-out.c (output_gimple_stmt): Likewise.
+
+   * gimple.c (gimple_build_eh_must_not_throw): Return a
+   gimple_eh_must_not_throw rather than a plain gimple.
+
+   * gimple.h (gimple_build_eh_must_not_throw): Return a
+   gimple_eh_must_not_throw rather than a plain gimple.
+   (gimple_eh_must_not_throw_fndecl): Require a
+   gimple_eh_must_not_throw rather than a plain gimple.
+   (gimple_eh_must_not_throw_set_fndecl): Likewise.
+
+   * tree-eh.c (lower_eh_must_not_throw): Add checked cast.
+
+2014-10-24  David Malcolm  
+
Introduce gimple_eh_filter
 
* coretypes.h (gimple_eh_filter): New typedef.
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index d2d19ec..51b73f6 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -142,6 +142,10 @@ struct gimple_statement_eh_filter;
 typedef struct gimple_statement_eh_filter *gimple_eh_filter;
 typedef const struct gimple_statement_eh_filter *const_gimple_eh_filter;
 
+struct gimple_statement_eh_mnt;
+typedef struct gimple_statement_eh_mnt *gimple_eh_must_not_throw;
+typedef const struct gimple_statement_eh_mnt *const_gimple_eh_must_not_throw;
+
 struct gimple_statement_phi;
 typedef struct gimple_statement_phi *gimple_phi;
 typedef const struct gimple_statement_phi *const_gimple_phi;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 5876a0c..42f94a3 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1021,8 +1021,8 @@ dump_gimple_eh_filter (pretty_printer *buffer, 
gimple_eh_filter gs, int spc,
 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple.  */
 
 static void
-dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
-  int spc, int flags)
+dump_gimple_eh_must_not_throw (pretty_printer *buffer,
+  gimple_eh_must_not_throw gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
@@ -2203,7 +2203,9 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int 
spc, int flags)
   break;
 
 case GIMPLE_EH_MUST_NOT_THROW:
-  dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
+  dump_gimple_eh_must_not_throw (buffer,
+as_a  (gs),
+spc, flags);
  

[gimple-classes, committed 20/92] Introduce gimple_goto

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 22/89] Introduce gimple_goto
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01174.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK after fixing up the naming/const stuff as discussed for prior
> patches.
> That applies to 22-30. Make sure to take care of
> the pretty printers per Trevor's comments as well. He indicated those
> were missing in a couple of those patches.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00628.html

gcc/
* coretypes.h (gimple_goto): New typedef.
(const_gimple_goto): New typedef.

* gimple.h (gimple_statement_goto): New subclass of
gimple_statement_with_ops, adding the invariant that
stmt->code == GIMPLE_GOTO.
(is_a_helper ::test): New.
(gimple_build_goto): Return a gimple_goto rather than a
plain gimple.

* gimple-pretty-print.c (dump_gimple_goto): Require a gimple_goto
rather than a plain gimple.
(pp_gimple_stmt_1): Add a checked cast to gimple_goto within
GIMPLE_GOTO case of switch statement.

* gimple.c (gimple_build_goto): Return a gimple_goto rather than a
plain gimple.

* tree-cfg.c (verify_gimple_goto): Require a gimple_goto rather
than a plain gimple.
(verify_gimple_stmt): Add a checked cast to gimple_goto within
GIMPLE_GOTO case of switch statement.
---
 gcc/ChangeLog.gimple-classes | 27 +++
 gcc/coretypes.h  |  4 
 gcc/gimple-pretty-print.c|  4 ++--
 gcc/gimple.c |  5 +++--
 gcc/gimple.h | 24 +++-
 gcc/tree-cfg.c   |  4 ++--
 6 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 5508788..bba6c7d 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,32 @@
 2014-10-24  David Malcolm  
 
+   Introduce gimple_goto
+
+   * coretypes.h (gimple_goto): New typedef.
+   (const_gimple_goto): New typedef.
+
+   * gimple.h (gimple_statement_goto): New subclass of
+   gimple_statement_with_ops, adding the invariant that
+   stmt->code == GIMPLE_GOTO.
+   (is_a_helper ::test): New.
+   (gimple_build_goto): Return a gimple_goto rather than a
+   plain gimple.
+
+   * gimple-pretty-print.c (dump_gimple_goto): Require a gimple_goto
+   rather than a plain gimple.
+   (pp_gimple_stmt_1): Add a checked cast to gimple_goto within
+   GIMPLE_GOTO case of switch statement.
+
+   * gimple.c (gimple_build_goto): Return a gimple_goto rather than a
+   plain gimple.
+
+   * tree-cfg.c (verify_gimple_goto): Require a gimple_goto rather
+   than a plain gimple.
+   (verify_gimple_stmt): Add a checked cast to gimple_goto within
+   GIMPLE_GOTO case of switch statement.
+
+2014-10-24  David Malcolm  
+
Introduce gimple_return
 
* coretypes.h (gimple_return): New typedef.
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index f726053..653343a 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -98,6 +98,10 @@ struct gimple_statement_debug;
 typedef struct gimple_statement_debug *gimple_debug;
 typedef const struct gimple_statement_debug *const_gimple_debug;
 
+struct gimple_statement_goto;
+typedef struct gimple_statement_goto *gimple_goto;
+typedef const struct gimple_statement_goto *const_gimple_goto;
+
 struct gimple_statement_label;
 typedef struct gimple_statement_label *gimple_label;
 typedef const struct gimple_statement_label *const_gimple_label;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index cfc111c..47772d6 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -884,7 +884,7 @@ dump_gimple_label (pretty_printer *buffer, gimple_label gs, 
int spc, int flags)
TDF_* in dumpfile.h).  */
 
 static void
-dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_goto (pretty_printer *buffer, gimple_goto gs, int spc, int flags)
 {
   tree label = gimple_goto_dest (gs);
   if (flags & TDF_RAW)
@@ -2109,7 +2109,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int 
spc, int flags)
   break;
 
 case GIMPLE_GOTO:
-  dump_gimple_goto (buffer, gs, spc, flags);
+  dump_gimple_goto (buffer, as_a  (gs), spc, flags);
   break;
 
 case GIMPLE_NOP:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index e8c0a62..0e5e473 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -499,10 +499,11 @@ gimple_build_label (tree label)
 
 /* Build a GIMPLE_GOTO statement to label DEST.  */
 
-gimple
+gimple_goto
 gimple_build_goto (tree dest)
 {
-  gimple p = gimple_build_with_ops (GIMPLE_GOTO, ERROR_MARK, 1);
+  gimple_goto p =
+as_a  (gimple_build_with_ops (GIMPLE_GOTO, ERROR_MARK, 1));
   gimple_goto_set_dest (p, dest);
   return p;
 }
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 559d281..128baf5 100644
--- a/

[gimple-classes, committed 22/92] Introduce gimple_transaction

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 24/89] Introduce gimple_transaction
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01207.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK after fixing up the naming/const stuff as discussed for prior
> patches.
> That applies to 22-30. Make sure to take care of
> the pretty printers per Trevor's comments as well. He indicated those
> were missing in a couple of those patches.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00628.html

gcc/
* coretypes.h (gimple_transaction): New typedef.
(const_gimple_transaction): New typedef.

* gimple.h (gimple_build_transaction): Return a gimple_transaction
rather than a plain gimple.
(gimple_transaction_body_ptr): Require a gimple_transaction rather
than a plain gimple.
(gimple_transaction_body): Likewise.
(gimple_transaction_label_ptr): Likewise.
(gimple_transaction_set_body): Likewise.
(gimple_transaction_set_label): Likewise.
(gimple_transaction_set_subcode): Likewise.
(gimple_transaction_label): Require a const_gimple_transaction
rather than a plain const_gimple.
(gimple_transaction_subcode): Likewise.

* gimple-low.c (lower_stmt): Add checked cast to
gimple_transaction within GIMPLE_TRANSACTION case of switch
statement.

* gimple-pretty-print.c (dump_gimple_transaction): Require a
gimple_transaction rather than a plain gimple.
(pp_gimple_stmt_1): Add checked cast to gimple_transaction within
GIMPLE_TRANSACTION case of switch statement.
* gimple-streamer-in.c (input_gimple_stmt): Likewise.
* gimple-streamer-out.c (output_gimple_stmt): Likewise.
* gimple-walk.c (walk_gimple_op): Likewise.
(walk_gimple_stmt): Likewise.

* gimple.c (gimple_build_transaction): Return a gimple_transaction
rather than a plain gimple.
(gimple_copy): Add checked casts to gimple_transaction within
GIMPLE_TRANSACTION case of switch statement.

* gimplify.c (gimplify_transaction): Split local "g" into
"body_stmt" and "trans_stmt", strengthening the type of the latter
from gimple to gimple_transaction.

* omp-low.c (lower_omp_1): Add checked cast to gimple_transaction
within GIMPLE_TRANSACTION case of switch statement.

* trans-mem.c (diagnose_tm_1): Add checked cast within
GIMPLE_TRANSACTION case of switch statement, introducing a new
local "trans_stmt".  Use it in place of "stmt".
(examine_call_tm): Convert local from gimple to gimple_transaction.
(tm_region::get_transaction_stmt): New method.
(tm_region::transaction_stmt): Add clarification of type to the
comment.
(tm_region_init_0): Require a gimple_transaction rather than a
plain gimple.
(tm_region_init): Convert a check against GIMPLE_TRANSACTION to a
dyn_cast and new local.
(transaction_subcode_ior): Add a new local, using the new
get_transaction_stmt method to perform a checked cast.
(propagate_tm_flags_out): Likewise.
(expand_transaction): Add a checked cast using the new
get_transaction_stmt method.
(generate_tm_state): Likewise.
(execute_tm_mark): Likewise.
(ipa_tm_diagnose_transaction): Likewise.

* tree-cfg.c (verify_gimple_transaction): Require a
gimple_transaction rather than a plain gimple.
(make_edges): Add checked cast within GIMPLE_TRANSACTION case of
switch statement
(cleanup_dead_labels): Likewise.
(verify_gimple_stmt): Likewise.
(verify_gimple_in_seq_2): Likewise.
(verify_gimple_in_seq_2): Likewise.
(gimple_redirect_edge_and_branch): Add checked cast.

* tree-inline.c (remap_gimple_stmt): Add checked cast within
GIMPLE_TRANSACTION case of switch statement, introducing a new
local "old_trans_stmt".  Use it in place of "stmt".  Add new
local "new_trans_stmt", using it to initialize "copy", and for
type-safe operations as a transaction.
(estimate_num_insns): Add checked cast within GIMPLE_TRANSACTION
case of switch statement.
---
 gcc/ChangeLog.gimple-classes | 83 
 gcc/coretypes.h  |  4 +++
 gcc/gimple-low.c |  4 ++-
 gcc/gimple-pretty-print.c|  6 ++--
 gcc/gimple-streamer-in.c |  3 +-
 gcc/gimple-streamer-out.c|  7 ++--
 gcc/gimple-walk.c|  8 +++--
 gcc/gimple.c | 11 +++---
 gcc/gimple.h | 46 ++--
 gcc/gimplify.c   | 13 +++
 gcc/omp-low.c|  4 ++-
 gcc/trans-mem.c  | 66 ---
 gcc/tree-cfg.c   | 19 +-
 gcc/tree-inline.c| 19 +++---
 14 files changed, 214 insertions(+),

[gimple-classes, committed 27/92] Introduce gimple_resx

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 29/89] Introduce gimple_resx
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01161.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK after fixing up the naming/const stuff as discussed for prior
> patches.
> That applies to 22-30. Make sure to take care of
> the pretty printers per Trevor's comments as well. He indicated those
> were missing in a couple of those patches.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00628.html

gcc/
* coretypes.h (gimple_resx): New typedef.
(const_gimple_resx): New typedef.

* gimple.h (gimple_build_resx): Return a gimple_resx rather than a
plain gimple.
(gimple_resx_region): Require a const_gimple_resx rather than a
plain const_gimple.
(gimple_resx_set_region): Require a gimple_resx rather than a
plain gimple.

* gimple-pretty-print.c (dump_gimple_resx): Require a gimple_resx
rather than a plain gimple.
(pp_gimple_stmt_1): Add a checked cast to gimple_resx within
GIMPLE_RESX case of switch statement.

* gimple-streamer-in.c (input_gimple_stmt): Likewise.

* gimple-streamer-out.c (output_gimple_stmt): Likewise.

* gimple.c (gimple_build_resx): Return a gimple_resx rather than
a plain gimple.

* tree-cfg.c (move_stmt_r): Add a checked cast to gimple_resx
within GIMPLE_RESX case of switch statement, adding a new local.

* tree-eh.c (emit_resx): Convert local "x" from gimple to
gimple_resx.
(lower_resx): Require a gimple_resx rather than a plain gimple.
(pass_lower_resx::execute): Add a checked cast to gimple_resx.
(mark_reachable_handlers): Likewise.

* tree-inline.c (remap_gimple_stmt): Add a checked cast to
gimple_resx within GIMPLE_RESX case of switch statement, adding
a new local.
---
 gcc/ChangeLog.gimple-classes | 39 +++
 gcc/coretypes.h  |  4 
 gcc/gimple-pretty-print.c|  4 ++--
 gcc/gimple-streamer-in.c |  3 ++-
 gcc/gimple-streamer-out.c|  2 +-
 gcc/gimple.c |  7 +++
 gcc/gimple.h | 13 +
 gcc/tree-cfg.c   |  5 +++--
 gcc/tree-eh.c| 11 +++
 gcc/tree-inline.c|  5 +++--
 10 files changed, 69 insertions(+), 24 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index fe3008a..6e2d2f5 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,44 @@
 2014-10-24  David Malcolm  
 
+   Introduce gimple_resx
+
+   * coretypes.h (gimple_resx): New typedef.
+   (const_gimple_resx): New typedef.
+
+   * gimple.h (gimple_build_resx): Return a gimple_resx rather than a
+   plain gimple.
+   (gimple_resx_region): Require a const_gimple_resx rather than a
+   plain const_gimple.
+   (gimple_resx_set_region): Require a gimple_resx rather than a
+   plain gimple.
+
+   * gimple-pretty-print.c (dump_gimple_resx): Require a gimple_resx
+   rather than a plain gimple.
+   (pp_gimple_stmt_1): Add a checked cast to gimple_resx within
+   GIMPLE_RESX case of switch statement.
+
+   * gimple-streamer-in.c (input_gimple_stmt): Likewise.
+
+   * gimple-streamer-out.c (output_gimple_stmt): Likewise.
+
+   * gimple.c (gimple_build_resx): Return a gimple_resx rather than
+   a plain gimple.
+
+   * tree-cfg.c (move_stmt_r): Add a checked cast to gimple_resx
+   within GIMPLE_RESX case of switch statement, adding a new local.
+
+   * tree-eh.c (emit_resx): Convert local "x" from gimple to
+   gimple_resx.
+   (lower_resx): Require a gimple_resx rather than a plain gimple.
+   (pass_lower_resx::execute): Add a checked cast to gimple_resx.
+   (mark_reachable_handlers): Likewise.
+
+   * tree-inline.c (remap_gimple_stmt): Add a checked cast to
+   gimple_resx within GIMPLE_RESX case of switch statement, adding
+   a new local.
+
+2014-10-24  David Malcolm  
+
Introduce gimple_eh_else
 
* coretypes.h (gimple_eh_else): New typedef.
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index ba076ec..fc2dbf3 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -150,6 +150,10 @@ struct gimple_statement_eh_else;
 typedef struct gimple_statement_eh_else *gimple_eh_else;
 typedef const struct gimple_statement_eh_else *const_gimple_eh_else;
 
+struct gimple_statement_resx;
+typedef struct gimple_statement_resx *gimple_resx;
+typedef const struct gimple_statement_resx *const_gimple_resx;
+
 struct gimple_statement_phi;
 typedef struct gimple_statement_phi *gimple_phi;
 typedef const struct gimple_statement_phi *const_gimple_phi;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index a82049f..81f1a35 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1057,7 +1057

[gimple-classes, committed 33/92] Introduce gimple_omp_atomic_store

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 35/89] Introduce gimple_omp_atomic_store
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01227.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK with expected changes due to renaming/updates to const handling.
> Please repost the final patch for archival purposes.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00804.html

gcc/
* coretypes.h (gimple_omp_atomic_store): New typedef.
(const_gimple_omp_atomic_store): New typedef.

* gimple-pretty-print.c (dump_gimple_omp_atomic_store): Require
a gimple_omp_atomic_store rather than a plain gimple.
(pp_gimple_stmt_1): Add checked cast to gimple_omp_atomic_store
within GIMPLE_OMP_ATOMIC_STORE case of switch statement.
* gimple-walk.c (walk_gimple_op): Likewise.

* gimple.c (gimple_build_omp_atomic_store): Return a
gimple_omp_atomic_store rather than a plain gimple.

* gimple.h (gimple_build_omp_atomic_store): Return a
gimple_omp_atomic_store rather than a plain gimple.
(gimple_omp_atomic_store_set_val): Require a gimple_omp_atomic_store
rather than a plain gimple.
(gimple_omp_atomic_store_val_ptr): Likewise.
(gimple_omp_atomic_store_val): Require a
const_gimple_omp_atomic_store rather than a plain const_gimple.

* gimplify.c (gimplify_omp_atomic): Strengthen locals "loadstmt" and
"storestmt" from gimple to gimple_omp_atomic_load loadstmt and
gimple_omp_atomic_store storestmt respectively.

* omp-low.c (expand_omp_atomic): Strengthen local "store" from
gimple to gimple_omp_atomic_store.
---
 gcc/ChangeLog.gimple-classes | 31 +++
 gcc/coretypes.h  |  5 +
 gcc/gimple-pretty-print.c|  8 +---
 gcc/gimple-walk.c|  5 +++--
 gcc/gimple.c |  5 +++--
 gcc/gimple.h | 20 +++-
 gcc/gimplify.c   |  3 ++-
 gcc/omp-low.c|  3 ++-
 8 files changed, 58 insertions(+), 22 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 3026787..0073b05 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,36 @@
 2014-10-24  David Malcolm  
 
+   Introduce gimple_omp_atomic_store
+
+   * coretypes.h (gimple_omp_atomic_store): New typedef.
+   (const_gimple_omp_atomic_store): New typedef.
+
+   * gimple-pretty-print.c (dump_gimple_omp_atomic_store): Require
+   a gimple_omp_atomic_store rather than a plain gimple.
+   (pp_gimple_stmt_1): Add checked cast to gimple_omp_atomic_store
+   within GIMPLE_OMP_ATOMIC_STORE case of switch statement.
+   * gimple-walk.c (walk_gimple_op): Likewise.
+
+   * gimple.c (gimple_build_omp_atomic_store): Return a
+   gimple_omp_atomic_store rather than a plain gimple.
+
+   * gimple.h (gimple_build_omp_atomic_store): Return a
+   gimple_omp_atomic_store rather than a plain gimple.
+   (gimple_omp_atomic_store_set_val): Require a gimple_omp_atomic_store
+   rather than a plain gimple.
+   (gimple_omp_atomic_store_val_ptr): Likewise.
+   (gimple_omp_atomic_store_val): Require a
+   const_gimple_omp_atomic_store rather than a plain const_gimple.
+
+   * gimplify.c (gimplify_omp_atomic): Strengthen locals "loadstmt" and
+   "storestmt" from gimple to gimple_omp_atomic_load loadstmt and
+   gimple_omp_atomic_store storestmt respectively.
+
+   * omp-low.c (expand_omp_atomic): Strengthen local "store" from
+   gimple to gimple_omp_atomic_store.
+
+2014-10-24  David Malcolm  
+
Introduce gimple_omp_atomic_load
 
* coretypes.h (gimple_omp_atomic_load): New typedef.
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 06b3be8..78647b2 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -171,6 +171,11 @@ typedef struct gimple_statement_omp_atomic_load 
*gimple_omp_atomic_load;
 typedef const struct gimple_statement_omp_atomic_load *
   const_gimple_omp_atomic_load;
 
+struct gimple_statement_omp_atomic_store;
+typedef struct gimple_statement_omp_atomic_store *gimple_omp_atomic_store;
+typedef const struct gimple_statement_omp_atomic_store *
+  const_gimple_omp_atomic_store;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index eafb6cd..62e4bf8 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -2000,8 +2000,8 @@ dump_gimple_omp_atomic_load (pretty_printer *buffer, 
gimple_omp_atomic_load gs,
in dumpfile.h).  */
 
 static void
-dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
- int flags)
+dump_gimple_omp_atomic_store (pretty_printer *buffer,
+ gimple_omp_atomic_store gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
 {
@@ -2149,7 +214

[gimple-classes, committed 38/92] tree-cfg.c: Make verify_gimple_call require a gimple_call

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 40/89] tree-cfg.c: Make verify_gimple_call require a gimple_call
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01232.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK when prerequisites have gone in.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00805.html

gcc/
* tree-cfg.c (verify_gimple_call): Require a gimple_call rather
than a plain gimple.
(verify_gimple_stmt): Add checked cast to gimple_call within
GIMPLE_CALL case of switch statement.
---
 gcc/ChangeLog.gimple-classes | 9 +
 gcc/tree-cfg.c   | 4 ++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index b0ddcd3..b030d20 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,14 @@
 2014-10-24  David Malcolm  
 
+   tree-cfg.c: Make verify_gimple_call require a gimple_call
+
+   * tree-cfg.c (verify_gimple_call): Require a gimple_call rather
+   than a plain gimple.
+   (verify_gimple_stmt): Add checked cast to gimple_call within
+   GIMPLE_CALL case of switch statement.
+
+2014-10-24  David Malcolm  
+
Introduce gimple_omp_parallel
 
* coretypes.h (gimple_omp_parallel): New typedef.
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index feeefea..9db1ffd 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -3208,7 +3208,7 @@ valid_fixed_convert_types_p (tree type1, tree type2)
is a problem, otherwise false.  */
 
 static bool
-verify_gimple_call (gimple stmt)
+verify_gimple_call (gimple_call stmt)
 {
   tree fn = gimple_call_fn (stmt);
   tree fntype, fndecl;
@@ -4486,7 +4486,7 @@ verify_gimple_stmt (gimple stmt)
   return verify_gimple_label (as_a  (stmt));
 
 case GIMPLE_CALL:
-  return verify_gimple_call (stmt);
+  return verify_gimple_call (as_a  (stmt));
 
 case GIMPLE_COND:
   if (TREE_CODE_CLASS (gimple_cond_code (stmt)) != tcc_comparison)
-- 
1.8.5.3



[gimple-classes, committed 39/92] Introduce gimple_omp_task

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 41/89] Introduce gimple_omp_task
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01160.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK with expected changes due to renaming/updates to const handling.
> Please repost the final patch for archival purposes.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00806.html

gcc/
* coretypes.h (gimple_omp_task): New typedef.
(const_gimple_omp_task): New typedef.

* gimple.h (gimple_build_omp_task): Return a gimple_omp_task
rather than a plain gimple.

* gimple-pretty-print.c (dump_gimple_omp_task): Require a
gimple_omp_task rather than a plain gimple.
(pp_gimple_stmt_1): Add checked cast to gimple_omp_task within
GIMPLE_OMP_TASK case of switch statement.

* gimple.c (gimple_build_omp_task): Return a gimple_omp_task
rather than a plain gimple.

* omp-low.c (finalize_task_copyfn): Require a gimple_omp_task
rather than a plain gimple.
(delete_omp_context): Add checked cast to gimple_omp_task.
(scan_omp_task): Strengthen local "stmt" from gimple to
gimple_omp_task.
(expand_task_call): Require a gimple_omp_task rather than a plain
gimple.
(expand_omp_taskreg): Add checked cast to gimple_omp_task.
(create_task_copyfn): Require a gimple_omp_task rather than a
plain gimple.
(lower_omp_taskreg): Add checked cast to gimple_omp_task.
---
 gcc/ChangeLog.gimple-classes | 30 ++
 gcc/coretypes.h  |  4 
 gcc/gimple-pretty-print.c|  4 ++--
 gcc/gimple.c |  5 +++--
 gcc/gimple.h |  3 ++-
 gcc/omp-low.c| 14 +++---
 6 files changed, 48 insertions(+), 12 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index b030d20..5dfdc22 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,35 @@
 2014-10-24  David Malcolm  
 
+   Introduce gimple_omp_task
+
+   * coretypes.h (gimple_omp_task): New typedef.
+   (const_gimple_omp_task): New typedef.
+
+   * gimple.h (gimple_build_omp_task): Return a gimple_omp_task
+   rather than a plain gimple.
+
+   * gimple-pretty-print.c (dump_gimple_omp_task): Require a
+   gimple_omp_task rather than a plain gimple.
+   (pp_gimple_stmt_1): Add checked cast to gimple_omp_task within
+   GIMPLE_OMP_TASK case of switch statement.
+
+   * gimple.c (gimple_build_omp_task): Return a gimple_omp_task
+   rather than a plain gimple.
+
+   * omp-low.c (finalize_task_copyfn): Require a gimple_omp_task
+   rather than a plain gimple.
+   (delete_omp_context): Add checked cast to gimple_omp_task.
+   (scan_omp_task): Strengthen local "stmt" from gimple to
+   gimple_omp_task.
+   (expand_task_call): Require a gimple_omp_task rather than a plain
+   gimple.
+   (expand_omp_taskreg): Add checked cast to gimple_omp_task.
+   (create_task_copyfn): Require a gimple_omp_task rather than a
+   plain gimple.
+   (lower_omp_taskreg): Add checked cast to gimple_omp_task.
+
+2014-10-24  David Malcolm  
+
tree-cfg.c: Make verify_gimple_call require a gimple_call
 
* tree-cfg.c (verify_gimple_call): Require a gimple_call rather
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 641658f..323e23c 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -192,6 +192,10 @@ struct gimple_statement_omp_parallel;
 typedef struct gimple_statement_omp_parallel *gimple_omp_parallel;
 typedef const struct gimple_statement_omp_parallel *const_gimple_omp_parallel;
 
+struct gimple_statement_omp_task;
+typedef struct gimple_statement_omp_task *gimple_omp_task;
+typedef const struct gimple_statement_omp_task *const_gimple_omp_task;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index ea788c2..2cb6fc8 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1911,7 +1911,7 @@ dump_gimple_omp_parallel (pretty_printer *buffer, 
gimple_omp_parallel gs,
dumpfile.h).  */
 
 static void
-dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
+dump_gimple_omp_task (pretty_printer *buffer, gimple_omp_task gs, int spc,
  int flags)
 {
   if (flags & TDF_RAW)
@@ -2142,7 +2142,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int 
spc, int flags)
   break;
 
 case GIMPLE_OMP_TASK:
-  dump_gimple_omp_task (buffer, gs, spc, flags);
+  dump_gimple_omp_task (buffer, as_a  (gs), spc, flags);
   break;
 
 case GIMPLE_OMP_ATOMIC_LOAD:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 26bd509..9510014 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -890,12 +890,13 @@ gimple_build_omp_parallel (gimple_seq body, tree clauses, 
tree child_fn,
COPY_FN

[gimple-classes, committed 31/92] Use more concrete types for various gimple statements

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 33/89] Use more concrete types for various gimple statements
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01226.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK after prerequisites have gone in.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00801.html

gcc/
* cgraphunit.c (thunk_adjust): Strengthen local "stmt" from gimple
to gimple_assign.

* gimple-ssa-isolate-paths.c
(insert_trap_and_remove_trailing_statements): Strengthen local
"new_stmt" from gimple to gimple_call.

* gimple-ssa-strength-reduction.c (replace_mult_candidate):
Strengthen local "copy_stmt" from gimple to gimple_assign.
(create_add_on_incoming_edge): Likewise, for "new_stmt".
(insert_initializers): Likewise, for "init_stmt".
(introduce_cast_before_cand): Likewise, for "cast_stmt".
(replace_one_candidate): Likewise, for "copy_stmt" and
"cast_stmt".

* gimplify.c (build_stack_save_restore): Require gimple_calls
rather than plain gimples.
(gimplify_bind_expr): Strengthen locals "stack_save" and
"stack_restore" from gimple to gimple_call.  Strengthen "gs"
to gimple_try.
(gimplify_switch_expr): Strengthen local "gimple_switch" from
gimple to gimple_switch, and "new_default" to gimple_label.
(gimplify_cond_expr): Strengthen local "gimple_cond" from gimple
to gimple_cond.
(gimplify_init_constructor): Strengthen local "init" from gimple
to gimple_assign.
(gimplify_cleanup_point_expr): Strengthen local "gtry" from gimple
to gimple_try.
(gimple_push_cleanup): Strengthen locals "ffalse" and "ftrue" from
gimple to gimple_assign.

* tree-eh.c (do_goto_redirection): Strengthen local to gimple_goto.
(emit_post_landing_pad): Strengthen local to gimple_label.

* tree-outof-ssa.c (insert_backedge_copies): Strengthen local
"stmt" from gimple to gimple_assign.

* tree-parloops.c (take_address_of): Likewise.

* tree-predcom.c (replace_ref_with): Likewise, for "new_stmt".
(initialize_root_vars_lm): Likewise, for "init_stmt".
(reassociate_to_the_same_stmt): Likewise, for "new_stmt" and "tmp_stmt".

* tree-profile.c (gimple_gen_edge_profiler): Likewise, for "stmt1",
"stmt2", "stmt3".
(gimple_gen_ic_profiler): Likewise.
(gimple_gen_ic_func_profiler): Strengthen local "stmt1" from
gimple to gimple_call, and "stmt2" to gimple_assign.

* tree-scalar-evolution.c (scev_const_prop): Strengthen local
"ass" from gimple to gimple_assign.

* tree-sra.c (build_ref_for_offset): Likewise for "stmt".
(generate_subtree_copies): Likewise; also strengthen "ds" to
gimple_debug.
(init_subtree_with_zero): Likewise.
(sra_modify_expr): Likewise.
(load_assign_lhs_subreplacements): Likewise.
(sra_modify_assign): Strengthen "ds" to gimple_debug.
(sra_ipa_reset_debug_stmts): Likewise for "def_temp".

* tree-ssa-ccp.c (insert_clobber_before_stack_restore):
Strengthen local "clobber_stmt" from gimple to gimple_assign.

* tree-ssa-dce.c (remove_dead_stmt): Strengthen "note" to
gimple_debug.

* tree-ssa-dom.c (record_equivalences_from_stmt): Strengthen
local "new_stmt" from gimple to gimple_assign.
(optimize_stmt): Likewise.

* tree-ssa-forwprop.c (simplify_bitwise_binary): Likewise for
4 declarations of "newop".
(simplify_rotate): Likewise for "g".

* tree-ssa-loop-im.c (rewrite_reciprocal): Likewise for 3 locals.
(rewrite_bittest): Likewise for "stmt" and "stmt2".
(move_computations_dom_walker::before_dom_children): Likewise for
"new_stmt".
(execute_sm): Likewise for "load" and "store".

* tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts):
Strengthen local "stmt" from gimple to gimple_call.
(unloop_loops): Likewise.

* tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Strengthen
local "ass" from gimple to gimple_assign.
(remove_unused_ivs): Strengthen "def_temp" to gimple_debug.

* tree-ssa-loop-manip.c (rewrite_phi_with_iv): Strengthen local "stmt"
from gimple to gimple_assign.

* tree-ssa-loop-prefetch.c (issue_prefetch_ref): Strengthen local
"prefetch" from gimple to gimple_call.

* tree-ssa-math-opts.c (insert_reciprocals): Strengthen local
"new_stmt" from gimple to gimple_assign.
(powi_as_mults_1): Likewise for "mult_stmt".
(powi_as_mults): Likewise for "div_stmt".
(build_and_insert_binop): Likewise for "stmt".
(build_and_insert_cast): Likewise.
(pass_cse_sincos::execute): Likewise for "stmt" and various decls
of "new_stmt".
(convert_mult_to_fma)

[gimple-classes, committed 45/92] omp-low.c: Use more concrete types of gimple statement for various locals

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 47/89] omp-low.c: Use more concrete types of gimple statement for 
various locals
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01203.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK once prerequisites have gone in.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00810.html

gcc/
* omp-low.c (finalize_task_copyfn): Strengthen local "bind" from
plain gimple to gimple_bind.
(lower_rec_input_clauses): Strengthen local "g" from
plain gimple to gimple_assign.
(lower_lastprivate_clauses): Likewise for "stmt" to gimple_cond
and "g" to gimple_call.
(expand_omp_for_init_vars): Likewise, for two decls of "stmt" to
gimple_assign.
(expand_omp_atomic_pipeline): Likewise for one decl of "stmt".
(expand_omp_atomic_mutex): Likewise.
(lower_omp_master): Likewise for "x" to gimple_call.
(lower_omp_ordered): Likewise.
---
 gcc/ChangeLog.gimple-classes | 17 +
 gcc/omp-low.c| 22 --
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index b8d2f38..b0391f3 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,22 @@
 2014-10-24  David Malcolm  
 
+   omp-low.c: Use more concrete types of gimple statement for various 
locals
+
+   * omp-low.c (finalize_task_copyfn): Strengthen local "bind" from
+   plain gimple to gimple_bind.
+   (lower_rec_input_clauses): Strengthen local "g" from
+   plain gimple to gimple_assign.
+   (lower_lastprivate_clauses): Likewise for "stmt" to gimple_cond
+   and "g" to gimple_call.
+   (expand_omp_for_init_vars): Likewise, for two decls of "stmt" to
+   gimple_assign.
+   (expand_omp_atomic_pipeline): Likewise for one decl of "stmt".
+   (expand_omp_atomic_mutex): Likewise.
+   (lower_omp_master): Likewise for "x" to gimple_call.
+   (lower_omp_ordered): Likewise.
+
+2014-10-24  David Malcolm  
+
tree-parloops.c: Use gimple_phi in various places
 
* tree-parloops.c (reduction_info::keep_res): Strengthen field
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 1edc943..9946f3f 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1377,7 +1377,7 @@ finalize_task_copyfn (gimple_omp_task task_stmt)
   struct function *child_cfun;
   tree child_fn;
   gimple_seq seq = NULL, new_seq;
-  gimple bind;
+  gimple_bind bind;
 
   child_fn = gimple_omp_task_copy_fn (task_stmt);
   if (child_fn == NULL_TREE)
@@ -3603,7 +3603,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, 
gimple_seq *dlist,
  gimplify_and_add (x, ilist);
  gimple_stmt_iterator gsi
= gsi_start_1 (gimple_omp_body_ptr (ctx->stmt));
- gimple g
+ gimple_assign g
= gimple_build_assign (unshare_expr (lvar), iv);
  gsi_insert_before_without_update (&gsi, g,
GSI_SAME_STMT);
@@ -3940,7 +3940,7 @@ lower_lastprivate_clauses (tree clauses, tree predicate, 
gimple_seq *stmt_list,
 
   if (predicate)
 {
-  gimple stmt;
+  gimple_cond stmt;
   tree label_true, arm1, arm2;
 
   label = create_artificial_label (UNKNOWN_LOCATION);
@@ -3987,7 +3987,7 @@ lower_lastprivate_clauses (tree clauses, tree predicate, 
gimple_seq *stmt_list,
  if (lastlane == NULL)
{
  lastlane = create_tmp_var (unsigned_type_node, NULL);
- gimple g
+ gimple_call g
= gimple_build_call_internal (IFN_GOMP_SIMD_LAST_LANE,
  2, simduid,
  TREE_OPERAND (val, 1));
@@ -5360,7 +5360,7 @@ expand_omp_for_init_vars (struct omp_for_data *fd, 
gimple_stmt_iterator *gsi,
  tree t = fold_convert (TREE_TYPE (tem), counts[i]);
  t = force_gimple_operand_gsi (gsi, t, false, NULL_TREE,
false, GSI_CONTINUE_LINKING);
- gimple stmt = gimple_build_assign (tem, t);
+ gimple_assign stmt = gimple_build_assign (tem, t);
  gsi_insert_after (gsi, stmt, GSI_CONTINUE_LINKING);
}
}
@@ -5369,7 +5369,7 @@ expand_omp_for_init_vars (struct omp_for_data *fd, 
gimple_stmt_iterator *gsi,
 
   tree type = TREE_TYPE (fd->loop.v);
   tree tem = create_tmp_reg (type, ".tem");
-  gimple stmt = gimple_build_assign (tem, startvar);
+  gimple_assign stmt = gimple_build_assign (tem, startvar);
   gsi_insert_after (gsi, stmt, GSI_CONTINUE_LINKING);
 
   for (i = fd->collapse - 1; i >= 0; i--)
@@ -8044,7 +8044,7 @@ expand_omp_atomic_pipeline (basic_block

[gimple-classes, committed 43/92] Introduce gimple_omp_sections

2014-10-27 Thread David Malcolm
This corresponds to:
  [PATCH 45/89] Introduce gimple_omp_sections
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01188.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK with expected changes due to renaming/updates to const handling.
> Please repost the final patch for archival purposes.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00821.html

gcc/
* coretypes.h (gimple_omp_sections): New typedef.
(const_gimple_omp_sections): New typedef.

* gimple-pretty-print.c (dump_gimple_omp_sections): Require a
gimple_omp_sections rather than a plain gimple.
(pp_gimple_stmt_1): Add checked cast to gimple_omp_sections within
GIMPLE_OMP_SECTIONS case of switch statement.

* gimple.c (gimple_build_omp_sections): Return a
gimple_omp_sections rather than a plain gimple.

* gimple.h (gimple_build_omp_sections): Return a
gimple_omp_sections rather than a plain gimple.

* omp-low.c (scan_omp_sections): Require a gimple_omp_sections
rather than a plain gimple.
(scan_omp_1_stmt): Add checked cast to gimple_omp_sections within
GIMPLE_OMP_SECTIONS case of switch statement.
(expand_omp_sections): Strengthen local "sections_stmt" from gimple
to gimple_omp_sections.
(lower_omp_sections): Likewise for "stmt".
---
 gcc/ChangeLog.gimple-classes | 26 ++
 gcc/coretypes.h  |  4 
 gcc/gimple-pretty-print.c|  7 ---
 gcc/gimple.c |  5 +++--
 gcc/gimple.h |  2 +-
 gcc/omp-low.c| 14 --
 6 files changed, 46 insertions(+), 12 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 65c7986..b0a8465 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,31 @@
 2014-10-24  David Malcolm  
 
+   Introduce gimple_omp_sections
+
+   * coretypes.h (gimple_omp_sections): New typedef.
+   (const_gimple_omp_sections): New typedef.
+
+   * gimple-pretty-print.c (dump_gimple_omp_sections): Require a
+   gimple_omp_sections rather than a plain gimple.
+   (pp_gimple_stmt_1): Add checked cast to gimple_omp_sections within
+   GIMPLE_OMP_SECTIONS case of switch statement.
+
+   * gimple.c (gimple_build_omp_sections): Return a
+   gimple_omp_sections rather than a plain gimple.
+
+   * gimple.h (gimple_build_omp_sections): Return a
+   gimple_omp_sections rather than a plain gimple.
+
+   * omp-low.c (scan_omp_sections): Require a gimple_omp_sections
+   rather than a plain gimple.
+   (scan_omp_1_stmt): Add checked cast to gimple_omp_sections within
+   GIMPLE_OMP_SECTIONS case of switch statement.
+   (expand_omp_sections): Strengthen local "sections_stmt" from gimple
+   to gimple_omp_sections.
+   (lower_omp_sections): Likewise for "stmt".
+
+2014-10-24  David Malcolm  
+
Introduce gimple_omp_teams
 
* coretypes.h (gimple_omp_teams): New typedef.
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 2cd33e5..b8417bc 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -196,6 +196,10 @@ struct gimple_statement_omp_task;
 typedef struct gimple_statement_omp_task *gimple_omp_task;
 typedef const struct gimple_statement_omp_task *const_gimple_omp_task;
 
+struct gimple_statement_omp_sections;
+typedef struct gimple_statement_omp_sections *gimple_omp_sections;
+typedef const struct gimple_statement_omp_sections *const_gimple_omp_sections;
+
 struct gimple_statement_omp_single;
 typedef struct gimple_statement_omp_single *gimple_omp_single;
 typedef const struct gimple_statement_omp_single *const_gimple_omp_single;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index d5e3639..a90d2ef 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1388,8 +1388,8 @@ dump_gimple_omp_teams (pretty_printer *buffer, 
gimple_omp_teams gs, int spc,
 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
- int flags)
+dump_gimple_omp_sections (pretty_printer *buffer, gimple_omp_sections gs,
+ int spc, int flags)
 {
   if (flags & TDF_RAW)
 {
@@ -2188,7 +2188,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int 
spc, int flags)
   break;
 
 case GIMPLE_OMP_SECTIONS:
-  dump_gimple_omp_sections (buffer, gs, spc, flags);
+  dump_gimple_omp_sections (buffer, as_a  (gs),
+   spc, flags);
   break;
 
 case GIMPLE_OMP_SECTIONS_SWITCH:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index b4b76f3..c2b4588 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1007,10 +1007,11 @@ gimple_build_omp_return (bool wait_p)
CLAUSES are any of the OMP sections contsruct's clauses: private,
firstprivate, lastprivate, red

  1   2   >