Re: Add .def file for public target instructions

2015-06-26 Thread Markus Trippelsdorf
On 2015.06.23 at 19:41 +0100, Richard Sandiford wrote:
> 
> gcc/
>   * Makefile.in (TARGET_DEF): Add target-insns.def.
>   (.PRECIOUS, simple_rtl_generated_h): Add insn-target-def.h.
>   (build/gentarget-def.o): New rule.
>   (genprogrtl): Add target-def.
>   * target-insns.def, gentarget-def.c: New files.
>   * target.def: Add targetm.have_* and targetm.gen_* hooks,
>   based on the contents of target-insns.def.
>   * defaults.h (HAVE_simple_return, gen_simple_return): Delete.
>   (HAVE_return, gen_return): Delete.
>   * target-def.h: Include insn-target-def.h.
>   * cfgrtl.c (force_nonfallthru_and_redirect): Use targetm interface
>   instead of direct calls.  Rely on them to do the appropriate assertions.
>   * function.c (gen_return_pattern): Likewise.  Return an rtx_insn *.
>   (convert_jumps_to_returns): Use targetm interface instead of
>   direct calls.
>   (thread_prologue_and_epilogue_insns): Likewise.
>   * reorg.c (find_end_label, dbr_schedule): Likewise.
>   * shrink-wrap.h (SHRINK_WRAPPING_ENABLED): Likewise.
>   * shrink-wrap.c (convert_to_simple_return): Likewise.
>   (try_shrink_wrapping): Use SHRINK_WRAPPING_ENABLED.

The patch breaks bootstrap on ppc64le. During libgcc configuration:

conftest.c: In function 'main':
conftest.c:16:1: internal compiler error: in as_a, at is-a.h:192
 }
 ^
0x1010411b as_a
../../gcc/gcc/is-a.h:192
0x1040ccd3 as_a
../../gcc/gcc/emit-rtl.c:4750
0x1040ccd3 emit_jump_insn_after(rtx_def*, rtx_def*)
../../gcc/gcc/emit-rtl.c:4749
0x104c378f emit_return_into_block(bool, basic_block_def*)
../../gcc/gcc/function.c:5633
0x104c3ee7 emit_return_for_exit(edge_def*, bool)
../../gcc/gcc/function.c:5779
0x104c9ee3 thread_prologue_and_epilogue_insns()
../../gcc/gcc/function.c:5961
0x104ca39f rest_of_handle_thread_prologue_and_epilogue
../../gcc/gcc/function.c:6443
0x104ca39f execute
../../gcc/gcc/function.c:6481
Please submit a full bug report,
with preprocessed source if appropriate.



-- 
Markus


Re: [PATCH] i386: Do not modify existing RTL (PR66412)

2015-06-26 Thread Uros Bizjak
Hello!

> > > [ I see i386 also does PUT_CODE in a few more splitters, hrm. ]
> >
> > I think the splitters need to be fixed but I also think that
> > shallow_copy_rtx should
> > be enough, no?  combine will not actually end up generating more references
> > to the original RTX so we won't end up with invalid RTX sharing (the same 
> > logic
> > is why the splitters didn't care).
>
> That probably is enough; I haven't thought about it too much, all other
> splitters doing a copy do a deep copy.  I don't think it is worth being
> too tricky here, those splitters do not match often at all.
>
> > It would be cleaner to write the splitters in a way that doesnt copy the RTX
> > but creates a new RTX with proper code/mode and operands (but that's more
> > work on your side - maybe Uros wants to help here).
>
> I think people use "copy_rtx; PUT_*" because it is less typing work ;-)
> If that is the only thing you change about the rtx, it even is easier
> to understand than creating a new one.

Attached patch implements both suggestions. It uses shallow_copy_rtx
before all PUT_* calls in the splitters, to avoid nasty surprises like
this one in the future. shallow_ropy_rtx copies just one level of RTX,
and this is all what we need. Also, the patch changes existing uses of
copy_rtx to shallow_copy_rtx.

2015-06-26  Uros Bizjak  
Segher Boessenkool  

* config/i386/i386.md (various splitters): Use shallow_copy_rtx
before doing PUT_MODE or PUT_CODE on operands to avoid
in-place RTX modification.

testsuite/ChangeLog:

2015-06-26  Uros Bizjak  

* gcc.target/i386/pr66412.c: New test.

Patch was bootstrapped and regresison tested on x85_64-linux-gnu
{,-m32}. Patch was committed to mainline SVN and will be backported to
all release branches (once they open).

Uros.
Index: config/i386/i386.md
===
--- config/i386/i386.md (revision 224993)
+++ config/i386/i386.md (working copy)
@@ -10796,6 +10796,7 @@
   [(set (match_dup 2) (match_dup 1))
(set (match_dup 0) (zero_extend:DI (match_dup 2)))]
 {
+  operands[1] = shallow_copy_rtx (operands[1]);
   PUT_MODE (operands[1], QImode);
   operands[2] = gen_lowpart (QImode, operands[0]);
 })
@@ -10813,6 +10814,7 @@
(parallel [(set (match_dup 0) (zero_extend:SI (match_dup 2)))
  (clobber (reg:CC FLAGS_REG))])]
 {
+  operands[1] = shallow_copy_rtx (operands[1]);
   PUT_MODE (operands[1], QImode);
   operands[2] = gen_lowpart (QImode, operands[0]);
 })
@@ -10828,6 +10830,7 @@
   [(set (match_dup 2) (match_dup 1))
(set (match_dup 0) (zero_extend:SI (match_dup 2)))]
 {
+  operands[1] = shallow_copy_rtx (operands[1]);
   PUT_MODE (operands[1], QImode);
   operands[2] = gen_lowpart (QImode, operands[0]);
 })
@@ -10865,7 +10868,10 @@
(const_int 0)))]
   ""
   [(set (match_dup 0) (match_dup 1))]
-  "PUT_MODE (operands[1], QImode);")
+{
+  operands[1] = shallow_copy_rtx (operands[1]);
+  PUT_MODE (operands[1], QImode);
+})
 
 (define_split
   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand"))
@@ -10874,7 +10880,10 @@
(const_int 0)))]
   ""
   [(set (match_dup 0) (match_dup 1))]
-  "PUT_MODE (operands[1], QImode);")
+{
+  operands[1] = shallow_copy_rtx (operands[1]);
+  PUT_MODE (operands[1], QImode);
+})
 
 (define_split
   [(set (match_operand:QI 0 "nonimmediate_operand")
@@ -10884,15 +10893,15 @@
   ""
   [(set (match_dup 0) (match_dup 1))]
 {
-  rtx new_op1 = copy_rtx (operands[1]);
-  operands[1] = new_op1;
-  PUT_MODE (new_op1, QImode);
-  PUT_CODE (new_op1, ix86_reverse_condition (GET_CODE (new_op1),
-GET_MODE (XEXP (new_op1, 0;
+  operands[1] = shallow_copy_rtx (operands[1]);
+  PUT_MODE (operands[1], QImode);
+  PUT_CODE (operands[1],
+   ix86_reverse_condition (GET_CODE (operands[1]),
+   GET_MODE (XEXP (operands[1], 0;
 
   /* Make sure that (a) the CCmode we have for the flags is strong
  enough for the reversed compare or (b) we have a valid FP compare.  */
-  if (! ix86_comparison_operator (new_op1, VOIDmode))
+  if (! ix86_comparison_operator (operands[1], VOIDmode))
 FAIL;
 })
 
@@ -10904,15 +10913,15 @@
   ""
   [(set (match_dup 0) (match_dup 1))]
 {
-  rtx new_op1 = copy_rtx (operands[1]);
-  operands[1] = new_op1;
-  PUT_MODE (new_op1, QImode);
-  PUT_CODE (new_op1, ix86_reverse_condition (GET_CODE (new_op1),
-GET_MODE (XEXP (new_op1, 0;
+  operands[1] = shallow_copy_rtx (operands[1]);
+  PUT_MODE (operands[1], QImode);
+  PUT_CODE (operands[1],
+   ix86_reverse_condition (GET_CODE (operands[1]),
+   GET_MODE (XEXP (operands[1], 0;
 
   /* Make sure that (a) the CCmode we have for the flags is strong
  enough for the reversed compare or (b) we have a valid FP compare.  */
-  if (! ix86_comparison_operator (new_op1, VOIDmode))
+  if (! 

Re: [PATCH] Use leon3 target for native LEON on Linux

2015-06-26 Thread Eric Botcazou
> 2015-06-23  Daniel Cederman  
> 
>   * config/sparc/driver-sparc.c: map /proc/cpuinfo with CPU LEON
> to leon3

OK for mainline and 5 branch (and 4.9 branch once it reopens), but the 
ChangeLog entry should be:

* config/sparc/driver-sparc.c (cpu_names): Map LEON to leon3.


-- 
Eric Botcazou


Re: [PATCH 2/2] Add leon3r0 and leon3r0v7 CPU targets

2015-06-26 Thread Eric Botcazou
> Early variants of LEON3, revision 0, do not support the CASA instruction.
> This patch adds two new targets, leon3r0 and leon3r0v7, that are equivalent
> to leon3 and leon3v7, except that they do not support CASA.

Why not use leon instead of leon3 for them?

-- 
Eric Botcazou


Re: [PATCH[2/n] Remove GENERIC stmt combining from SCCVN

2015-06-26 Thread Richard Biener
On Thu, 25 Jun 2015, Richard Biener wrote:

> 
> This shows up in gcc.dg/tree-ssa/reassoc-13.c where the 'reassoc:'
> case in fold_binary happily handles floats if flag_associative_math.
> Thus here, too.
> 
> Bootstrap & regtest ongoing on x86_64-unknown-linux-gnu.

Applied with the additional

* gfortran.dg/reassoc_3.f90: Adjust.

Index: gcc/testsuite/gfortran.dg/reassoc_3.f90
===
--- gcc/testsuite/gfortran.dg/reassoc_3.f90 (revision 224938)
+++ gcc/testsuite/gfortran.dg/reassoc_3.f90 (working copy)
@@ -14,5 +14,4 @@ function test(a)
 end
 
 ! { dg-final { scan-tree-dump "b = 5" "original" } }
-! { dg-final { scan-tree-dump "c_. = .a" "optimized" } }
-! { dg-final { scan-tree-dump "return c_.;" "optimized" } }
+! { dg-final { scan-tree-dump-times " = " 1 "optimized" } }


> Richard.
> 
> 2015-06-25  Richard Biener  
> 
>   * match.pd: Allow associating FLOAT_TYPE_P when flag_associative_math.
> 
> Index: gcc/match.pd
> ===
> --- gcc/match.pd  (revision 224893)
> +++ gcc/match.pd  (working copy)
> @@ -561,9 +578,10 @@ (define_operator_list swapped_tcc_compar
> && !TYPE_OVERFLOW_SANITIZED (type))
> (convert @1)))
>  
> - /* We can't reassociate floating-point or fixed-point plus or minus
> -because of saturation to +-Inf.  */
> - (if (!FLOAT_TYPE_P (type) && !FIXED_POINT_TYPE_P (type))
> + /* We can't reassociate floating-point unless -fassociative-math
> +or fixed-point plus or minus because of saturation to +-Inf.  */
> + (if ((!FLOAT_TYPE_P (type) || flag_associative_math)
> +  && !FIXED_POINT_TYPE_P (type))
>  
>/* Match patterns that allow contracting a plus-minus pair
>   irrespective of overflow issues.  */
> 
> 

-- 
Richard Biener 
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham 
Norton, HRB 21284 (AG Nuernberg)


C PATCH to use INDIRECT_REF_P

2015-06-26 Thread Marek Polacek
We have INDIRECT_REF_P macro, so let's use it to make the code a bit
more clear.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2015-06-25  Marek Polacek  

* array-notation-common.c (find_rank): Use INDIRECT_REF_P.
* c-common.c (c_fully_fold_internal): Likewise.
(c_alignof_expr): Likewise.
* c-pretty-print.c (c_pretty_printer::postfix_expression): Likewise.
* c-ubsan.c (ubsan_instrument_bounds): Likewise.
* cilk.c (create_parm_list): Likewise. 

* c-array-notation.c (fix_builtin_array_notation_fn): Use
INDIRECT_REF_P.
* c-typeck.c (array_to_pointer_conversion): Likewise.
(build_unary_op): Likewise.
(c_finish_return): Likewise.

diff --git gcc/c-family/array-notation-common.c 
gcc/c-family/array-notation-common.c
index f517424..f75936a 100644
--- gcc/c-family/array-notation-common.c
+++ gcc/c-family/array-notation-common.c
@@ -228,7 +228,7 @@ find_rank (location_t loc, tree orig_expr, tree expr, bool 
ignore_builtin_fn,
  ii_tree = ARRAY_NOTATION_ARRAY (ii_tree);
}
  else if (handled_component_p (ii_tree)
-  || TREE_CODE (ii_tree) == INDIRECT_REF)
+  || INDIRECT_REF_P (ii_tree))
ii_tree = TREE_OPERAND (ii_tree, 0);
  else if (TREE_CODE (ii_tree) == PARM_DECL
   || VAR_P (ii_tree))
diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index 73d0c7f..33888c5 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -1436,7 +1436,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool 
*maybe_const_operands,
   if (op0 != orig_op0
  && code == ADDR_EXPR
  && (op1 = get_base_address (op0)) != NULL_TREE
- && TREE_CODE (op1) == INDIRECT_REF
+ && INDIRECT_REF_P (op1)
  && TREE_CONSTANT (TREE_OPERAND (op1, 0)))
ret = fold_convert_loc (loc, TREE_TYPE (expr), fold_offsetof_1 (op0));
   else if (op0 != orig_op0 || in_init)
@@ -1447,7 +1447,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool 
*maybe_const_operands,
ret = fold (expr);
   if (code == INDIRECT_REF
  && ret != expr
- && TREE_CODE (ret) == INDIRECT_REF)
+ && INDIRECT_REF_P (ret))
{
  TREE_READONLY (ret) = TREE_READONLY (expr);
  TREE_SIDE_EFFECTS (ret) = TREE_SIDE_EFFECTS (expr);
@@ -5377,7 +5377,7 @@ c_alignof_expr (location_t loc, tree expr)
   && TREE_CODE (TREE_OPERAND (expr, 1)) == FIELD_DECL)
 t = size_int (DECL_ALIGN_UNIT (TREE_OPERAND (expr, 1)));
 
-  else if (TREE_CODE (expr) == INDIRECT_REF)
+  else if (INDIRECT_REF_P (expr))
 {
   tree t = TREE_OPERAND (expr, 0);
   tree best = t;
diff --git gcc/c-family/c-pretty-print.c gcc/c-family/c-pretty-print.c
index a65ff33..4be1d4f 100644
--- gcc/c-family/c-pretty-print.c
+++ gcc/c-family/c-pretty-print.c
@@ -1607,7 +1607,7 @@ c_pretty_printer::postfix_expression (tree e)
 case COMPONENT_REF:
   {
tree object = TREE_OPERAND (e, 0);
-   if (TREE_CODE (object) == INDIRECT_REF)
+   if (INDIRECT_REF_P (object))
  {
postfix_expression (TREE_OPERAND (object, 0));
pp_c_arrow (this);
diff --git gcc/c-family/c-ubsan.c gcc/c-family/c-ubsan.c
index 10524d2..5a95236 100644
--- gcc/c-family/c-ubsan.c
+++ gcc/c-family/c-ubsan.c
@@ -290,8 +290,7 @@ ubsan_instrument_bounds (location_t loc, tree array, tree 
*index,
   tree base = get_base_address (array);
   if ((flag_sanitize & SANITIZE_BOUNDS_STRICT) == 0
   && TREE_CODE (array) == COMPONENT_REF
-  && base && (TREE_CODE (base) == INDIRECT_REF
- || TREE_CODE (base) == MEM_REF))
+  && base && (INDIRECT_REF_P (base) || TREE_CODE (base) == MEM_REF))
 {
   tree next = NULL_TREE;
   tree cref = array;
diff --git gcc/c-family/cilk.c gcc/c-family/cilk.c
index c6ca288..4f8026f 100644
--- gcc/c-family/cilk.c
+++ gcc/c-family/cilk.c
@@ -392,7 +392,7 @@ create_parm_list (struct wrapper_data *wd, tree *val0, tree 
arg)
 
   val = TREE_OPERAND (val, 0);
   *val0 = val;
-  gcc_assert (TREE_CODE (val) == INDIRECT_REF);
+  gcc_assert (INDIRECT_REF_P (val));
   parm = TREE_OPERAND (val, 0);
   STRIP_NOPS (parm);
 }
diff --git gcc/c/c-array-notation.c gcc/c/c-array-notation.c
index 0292468..e6a1539 100644
--- gcc/c/c-array-notation.c
+++ gcc/c/c-array-notation.c
@@ -324,7 +324,7 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree 
*new_var)
 array_ind_value = build_decl (location, VAR_DECL, NULL_TREE, 
  TREE_TYPE (func_parm));
   array_op0 = (*array_operand)[0];
-  if (TREE_CODE (array_op0) == INDIRECT_REF)
+  if (INDIRECT_REF_P (array_op0))
 array_op0 = TREE_OPERAND (array_op0, 0);
   switch (an_type)
 {
diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index 9caf028..60d6ed8 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -1826,7 +1826,7 @@ array_to_pointer_con

C PATCH to use VECTOR_TYPE_P

2015-06-26 Thread Marek Polacek
This patch makes the C FE use the VECTOR_TYPE_P macro where appropriate.
The existing code in the last build_binary_op hunk was really weird...

Now the question is: do we want e.g. ARRAY_TYPE_P, etc.?

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2015-06-26  Marek Polacek  

* c-common.c (check_main_parameter_types): Use VECTOR_TYPE_P
throughout.
* c-gimplify.c: Likewise.

* c-typeck.c: Use VECTOR_TYPE_P throughout.

diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index 73d0c7f..5ca7f6c 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -2412,7 +2412,7 @@ check_main_parameter_types (tree decl)
 bool
 vector_targets_convertible_p (const_tree t1, const_tree t2)
 {
-  if (TREE_CODE (t1) == VECTOR_TYPE && TREE_CODE (t2) == VECTOR_TYPE
+  if (VECTOR_TYPE_P (t1) && VECTOR_TYPE_P (t2)
   && (TYPE_VECTOR_OPAQUE (t1) || TYPE_VECTOR_OPAQUE (t2))
   && tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2)))
 return true;
@@ -2500,7 +2500,7 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, 
tree mask,
   || mask == error_mark_node)
 return error_mark_node;
 
-  if (TREE_CODE (TREE_TYPE (mask)) != VECTOR_TYPE
+  if (!VECTOR_TYPE_P (TREE_TYPE (mask))
   || TREE_CODE (TREE_TYPE (TREE_TYPE (mask))) != INTEGER_TYPE)
 {
   if (complain)
@@ -2509,8 +2509,8 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, 
tree mask,
   return error_mark_node;
 }
 
-  if (TREE_CODE (TREE_TYPE (v0)) != VECTOR_TYPE
-  || TREE_CODE (TREE_TYPE (v1)) != VECTOR_TYPE)
+  if (!VECTOR_TYPE_P (TREE_TYPE (v0))
+  || !VECTOR_TYPE_P (TREE_TYPE (v1)))
 {
   if (complain)
error_at (loc, "__builtin_shuffle arguments must be vectors");
@@ -12483,7 +12483,7 @@ convert_vector_to_pointer_for_subscript (location_t loc,
 tree *vecp, tree index)
 {
   bool ret = false;
-  if (TREE_CODE (TREE_TYPE (*vecp)) == VECTOR_TYPE)
+  if (VECTOR_TYPE_P (TREE_TYPE (*vecp)))
 {
   tree type = TREE_TYPE (*vecp);
   tree type1;
@@ -12549,8 +12549,7 @@ scalar_to_vector (location_t loc, enum tree_code code, 
tree op0, tree op1,
   bool integer_only_op = false;
   enum stv_conv ret = stv_firstarg;
 
-  gcc_assert (TREE_CODE (type0) == VECTOR_TYPE
- || TREE_CODE (type1) == VECTOR_TYPE);
+  gcc_assert (VECTOR_TYPE_P (type0) || VECTOR_TYPE_P (type1));
   switch (code)
 {
   /* Most GENERIC binary expressions require homogeneous arguments.
@@ -12600,7 +12599,7 @@ scalar_to_vector (location_t loc, enum tree_code code, 
tree op0, tree op1,
   case LT_EXPR:
   case GT_EXPR:
   /* What about UNLT_EXPR?  */
-   if (TREE_CODE (type0) == VECTOR_TYPE)
+   if (VECTOR_TYPE_P (type0))
  {
ret = stv_secondarg;
std::swap (type0, type1);
diff --git gcc/c-family/c-gimplify.c gcc/c-family/c-gimplify.c
index 317891f..98a6d53 100644
--- gcc/c-family/c-gimplify.c
+++ gcc/c-family/c-gimplify.c
@@ -248,7 +248,7 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p 
ATTRIBUTE_UNUSED,
   We should get rid of this conversion when we have a proper
   type demotion/promotion pass.  */
tree *op1_p = &TREE_OPERAND (*expr_p, 1);
-   if (TREE_CODE (TREE_TYPE (*op1_p)) != VECTOR_TYPE
+   if (!VECTOR_TYPE_P (TREE_TYPE (*op1_p))
&& !types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (*op1_p)),
unsigned_type_node)
&& !types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (*op1_p)),
diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index 9caf028..66af203 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -2457,7 +2457,7 @@ build_array_ref (location_t loc, tree array, tree index)
   if (TREE_CODE (TREE_TYPE (array)) != ARRAY_TYPE
   && TREE_CODE (TREE_TYPE (array)) != POINTER_TYPE
   /* Allow vector[index] but not index[vector].  */
-  && TREE_CODE (TREE_TYPE (array)) != VECTOR_TYPE)
+  && !VECTOR_TYPE_P (TREE_TYPE (array)))
 {
   if (TREE_CODE (TREE_TYPE (index)) != ARRAY_TYPE
  && TREE_CODE (TREE_TYPE (index)) != POINTER_TYPE)
@@ -6730,7 +6730,7 @@ digest_init (location_t init_loc, tree type, tree init, 
tree origtype,
  vector constructor is not constant (e.g. {1,2,3,foo()}) then punt
  below and handle as a constructor.  */
   if (code == VECTOR_TYPE
-  && TREE_CODE (TREE_TYPE (inside_init)) == VECTOR_TYPE
+  && VECTOR_TYPE_P (TREE_TYPE (inside_init))
   && vector_types_convertible_p (TREE_TYPE (inside_init), type, true)
   && TREE_CONSTANT (inside_init))
 {
@@ -7181,7 +7181,7 @@ really_start_incremental_init (tree type)
   if (type == 0)
 type = TREE_TYPE (constructor_decl);
 
-  if (TREE_CODE (type) == VECTOR_TYPE
+  if (VECTOR_TYPE_P (type)
   && TYPE_VECTOR_OPAQUE (type))
 error ("opaque vector types cannot be initialized");
 
@@ -7267,7 +7267,7 @@ really_start_incremental_init (tree type)
 

Re: [PATCH] Make muser-mode the default for LEON3

2015-06-26 Thread Eric Botcazou
> The muser-mode flag causes the CASA instruction for LEON3 to use the
> user mode ASI. This is the correct behavior for almost all LEON3 targets.

Do they lack the CASA instruction with supervisor-mode ASI?  What happens when 
the CASA instruction with user-mode ASI is executed in supervisor mode?

-- 
Eric Botcazou


match.pd: Optimize (x | y) & ~(x & y) and (x | y) & (~x ^ y)

2015-06-26 Thread Marek Polacek
The following patch adds optimizing of
(x | y) & ~(x & y)
and
(x | y) & (~x ^ y)
to a single operation.

No +/-/* in those, so I think we don't have to worry about saturating types
this time around.

For some reason I had to use more :c's in the latter pattern than usual.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2015-06-26  Marek Polacek  

* match.pd ((x | y) & ~(x & y) -> x ^ y,
(x | y) & (~x ^ y) -> x & y): New patterns.

* gcc.dg/fold-and-1.c: New test.
* gcc.dg/fold-and-2.c: New test.

diff --git gcc/match.pd gcc/match.pd
index 292ce6d..f242c99 100644
--- gcc/match.pd
+++ gcc/match.pd
@@ -367,6 +367,16 @@ along with GCC; see the file COPYING3.  If not see
  (minus (bit_ior @0 @1) (bit_and @0 @1))
  (bit_xor @0 @1))
 
+/* (x | y) & ~(x & y) -> x ^ y */
+(simplify
+ (bit_and:c (bit_ior @0 @1) (bit_not (bit_and @0 @1)))
+ (bit_xor @0 @1))
+
+/* (x | y) & (~x ^ y) -> x & y */
+(simplify
+ (bit_and:c (bit_ior:c @0 @1) (bit_xor:c @1 (bit_not @0)))
+ (bit_and @0 @1))
+
 (simplify
  (abs (negate @0))
  (abs @0))
diff --git gcc/testsuite/gcc.dg/fold-and-1.c gcc/testsuite/gcc.dg/fold-and-1.c
index e69de29..d555bb4 100644
--- gcc/testsuite/gcc.dg/fold-and-1.c
+++ gcc/testsuite/gcc.dg/fold-and-1.c
@@ -0,0 +1,70 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-cddce1" } */
+
+int
+fn1 (int x, int y)
+{
+  int tem1 = x | y;
+  int tem2 = ~(x & y);
+  return tem1 & tem2;
+}
+
+int
+fn2 (int x, int y)
+{
+  int tem1 = y | x;
+  int tem2 = ~(x & y);
+  return tem1 & tem2;
+}
+
+int
+fn3 (int x, int y)
+{
+  int tem1 = x | y;
+  int tem2 = ~(y & x);
+  return tem1 & tem2;
+}
+
+int
+fn4 (int x, int y)
+{
+  int tem1 = y | x;
+  int tem2 = ~(y & x);
+  return tem1 & tem2;
+}
+
+int
+fn5 (int x, int y)
+{
+  int tem1 = ~(x & y);
+  int tem2 = x | y;
+  return tem1 & tem2;
+}
+
+int
+fn6 (int x, int y)
+{
+  int tem1 = ~(x & y);
+  int tem2 = y | x;
+  return tem1 & tem2;
+}
+
+int
+fn7 (int x, int y)
+{
+  int tem1 = ~(y & x);
+  int tem2 = x | y;
+  return tem1 & tem2;
+}
+
+int
+fn8 (int x, int y)
+{
+  int tem1 = ~(y & x);
+  int tem2 = y | x;
+  return tem1 & tem2;
+}
+
+/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */
+/* { dg-final { scan-tree-dump-not " \\& " "cddce1" } } */
+/* { dg-final { scan-tree-dump-not "~" "cddce1" } } */
diff --git gcc/testsuite/gcc.dg/fold-and-2.c gcc/testsuite/gcc.dg/fold-and-2.c
index e69de29..3df2a0b 100644
--- gcc/testsuite/gcc.dg/fold-and-2.c
+++ gcc/testsuite/gcc.dg/fold-and-2.c
@@ -0,0 +1,70 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-cddce1" } */
+
+int
+fn1 (int x, int y)
+{
+  int tem1 = x | y;
+  int tem2 = ~x ^ y;
+  return tem1 & tem2;
+}
+
+int
+fn2 (int x, int y)
+{
+  int tem1 = y | x;
+  int tem2 = ~x ^ y;
+  return tem1 & tem2;
+}
+
+int
+fn3 (int x, int y)
+{
+  int tem1 = x | y;
+  int tem2 = y ^ ~x;
+  return tem1 & tem2;
+}
+
+int
+fn4 (int x, int y)
+{
+  int tem1 = y | x;
+  int tem2 = y ^ ~x;
+  return tem1 & tem2;
+}
+
+int
+fn5 (int x, int y)
+{
+  int tem1 = ~x ^ y;
+  int tem2 = x | y;
+  return tem1 & tem2;
+}
+
+int
+fn6 (int x, int y)
+{
+  int tem1 = ~x ^ y;
+  int tem2 = y | x;
+  return tem1 & tem2;
+}
+
+int
+fn7 (int x, int y)
+{
+  int tem1 = y ^ ~x;
+  int tem2 = x | y;
+  return tem1 & tem2;
+}
+
+int
+fn8 (int x, int y)
+{
+  int tem1 = y ^ ~x;
+  int tem2 = y | x;
+  return tem1 & tem2;
+}
+
+/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */
+/* { dg-final { scan-tree-dump-not " \\^ " "cddce1" } } */
+/* { dg-final { scan-tree-dump-not "~" "cddce1" } } */

Marek


[committed] Use VAR_OR_FUNCTION_DECL_P

2015-06-26 Thread Marek Polacek
As Uros pointed out.

Bootstrapped/regtested on x86_64-linux, applying to trunk.

2015-06-26  Marek Polacek  

* c-common.c (handle_unused_attribute): Use VAR_OR_FUNCTION_DECL_P.

diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index 73d0c7f..b11a756 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -7376,8 +7376,7 @@ handle_unused_attribute (tree *node, tree name, tree 
ARG_UNUSED (args),
   tree decl = *node;
 
   if (TREE_CODE (decl) == PARM_DECL
- || VAR_P (decl)
- || TREE_CODE (decl) == FUNCTION_DECL
+ || VAR_OR_FUNCTION_DECL_P (decl)
  || TREE_CODE (decl) == LABEL_DECL
  || TREE_CODE (decl) == TYPE_DECL)
{

Marek


Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-06-26 Thread Marek Polacek
I'm pinging the C++ parts.

On Fri, Jun 19, 2015 at 12:44:36PM +0200, Marek Polacek wrote:
> Ping.
> 
> On Fri, Jun 12, 2015 at 11:07:29AM +0200, Marek Polacek wrote:
> > Ping.
> > 
> > On Fri, Jun 05, 2015 at 10:55:08AM +0200, Marek Polacek wrote:
> > > On Thu, Jun 04, 2015 at 09:04:19PM +, Joseph Myers wrote:
> > > > The C changes are OK.
> > > 
> > > Jason, do you want to approve the C++ parts?

Marek


Re: Add .def file for public target instructions

2015-06-26 Thread Richard Sandiford
Markus Trippelsdorf  writes:
> On 2015.06.23 at 19:41 +0100, Richard Sandiford wrote:
>> 
>> gcc/
>>  * Makefile.in (TARGET_DEF): Add target-insns.def.
>>  (.PRECIOUS, simple_rtl_generated_h): Add insn-target-def.h.
>>  (build/gentarget-def.o): New rule.
>>  (genprogrtl): Add target-def.
>>  * target-insns.def, gentarget-def.c: New files.
>>  * target.def: Add targetm.have_* and targetm.gen_* hooks,
>>  based on the contents of target-insns.def.
>>  * defaults.h (HAVE_simple_return, gen_simple_return): Delete.
>>  (HAVE_return, gen_return): Delete.
>>  * target-def.h: Include insn-target-def.h.
>>  * cfgrtl.c (force_nonfallthru_and_redirect): Use targetm interface
>>  instead of direct calls.  Rely on them to do the appropriate assertions.
>>  * function.c (gen_return_pattern): Likewise.  Return an rtx_insn *.
>>  (convert_jumps_to_returns): Use targetm interface instead of
>>  direct calls.
>>  (thread_prologue_and_epilogue_insns): Likewise.
>>  * reorg.c (find_end_label, dbr_schedule): Likewise.
>>  * shrink-wrap.h (SHRINK_WRAPPING_ENABLED): Likewise.
>>  * shrink-wrap.c (convert_to_simple_return): Likewise.
>>  (try_shrink_wrapping): Use SHRINK_WRAPPING_ENABLED.
>
> The patch breaks bootstrap on ppc64le. During libgcc configuration:

Yeah, sorry about that.  The problem is due to confusion about whether
the generator should emit a barrier or not.  After the final instruction
in a sequence, it should always be up to the caller to insert any
necessary barriers, just like it is for define_insns, and for define_expands
implemented in C++ with DONE.

I'm testing the following patch.

Thanks,
Richard


gcc/
* rtl.h (emit): Add an optional boolean parameter to control
whether barriers are emitted.
* emit-rtl.c (emit): Likewise.
* gensupport.c (get_emit_function): Return null rather than "emit".
* genemit.c (gen_emit_seq): Handle the null return value.
Don't emit barriers after the final instruction in the sequence.
* gentarget-def.c (main): Don't emit barriers after the instruction.

Index: gcc/rtl.h
===
--- gcc/rtl.h   2015-06-26 09:09:10.128602409 +0100
+++ gcc/rtl.h   2015-06-26 09:09:10.316600233 +0100
@@ -3494,7 +3494,7 @@ extern void add_insn (rtx_insn *);
 extern void add_insn_before (rtx, rtx, basic_block);
 extern void add_insn_after (rtx, rtx, basic_block);
 extern void remove_insn (rtx);
-extern rtx_insn *emit (rtx);
+extern rtx_insn *emit (rtx, bool = true);
 extern void emit_insn_at_entry (rtx);
 extern rtx gen_lowpart_SUBREG (machine_mode, rtx);
 extern rtx gen_const_mem (machine_mode, rtx);
Index: gcc/emit-rtl.c
===
--- gcc/emit-rtl.c  2015-06-26 09:09:10.124602455 +0100
+++ gcc/emit-rtl.c  2015-06-26 09:09:10.316600233 +0100
@@ -5303,11 +5303,14 @@ set_dst_reg_note (rtx insn, enum reg_not
   return NULL_RTX;
 }
 
-/* Emit the rtl pattern X as an appropriate kind of insn.
+/* Emit the rtl pattern X as an appropriate kind of insn.  Also emit a
+   following barrier if the instruction needs one and if ALLOW_BARRIER_P
+   is true.
+
If X is a label, it is simply added into the insn chain.  */
 
 rtx_insn *
-emit (rtx x)
+emit (rtx x, bool allow_barrier_p)
 {
   enum rtx_code code = classify_insn (x);
 
@@ -5320,7 +5323,8 @@ emit (rtx x)
 case  JUMP_INSN:
   {
rtx_insn *insn = emit_jump_insn (x);
-   if (any_uncondjump_p (insn) || GET_CODE (x) == RETURN)
+   if (allow_barrier_p
+   && (any_uncondjump_p (insn) || GET_CODE (x) == RETURN))
  return emit_barrier ();
return insn;
   }
Index: gcc/gensupport.c
===
--- gcc/gensupport.c2015-06-26 09:09:10.124602455 +0100
+++ gcc/gensupport.c2015-06-26 09:09:10.316600233 +0100
@@ -2983,7 +2983,9 @@ get_pattern_stats (struct pattern_stats
   stats->max_scratch_opno)) + 1;
 }
 
-/* Return the emit_* function that should be used for pattern X.  */
+/* Return the emit_* function that should be used for pattern X, or NULL
+   if we can't pick a particular type at compile time and should instead
+   fall back to "emit".  */
 
 const char *
 get_emit_function (rtx x)
@@ -3000,7 +3002,7 @@ get_emit_function (rtx x)
   return "emit_jump_insn";
 
 case UNKNOWN:
-  return "emit";
+  return NULL;
 
 default:
   gcc_unreachable ();
Index: gcc/genemit.c
===
--- gcc/genemit.c   2015-06-26 09:09:10.124602455 +0100
+++ gcc/genemit.c   2015-06-26 09:09:10.316600233 +0100
@@ -277,12 +277,22 @@ gen_emit_seq (rtvec vec, char *used)
 {
   for (int i = 0, len = GET_NUM_ELEM (vec); i < len; ++i)
 {
+  bool last_p = (i == len - 1);
   rtx next = RTV

[PATCH, ARM] Restrict pr65647 testcase to ARMv6-M effective target

2015-06-26 Thread Thomas Preud'homme
Hi,

Testcase for PR65647 assumes that the compiler can compile for ARMv6-M
which might not be the case if passing some extra options via
RUNTESTFLAGS (eg. -marm/-mcpu=cortex-a9). This patch restricts the
testcase to ARMv6-M effective targets.


Testsuite ChangeLog entry is as follows:

2015-06-25  Thomas Preud'homme  

* gcc.target/arm/pr65647.c: Restrict to ARMv6-M effective targets.


diff --git a/gcc/testsuite/gcc.target/arm/pr65647.c 
b/gcc/testsuite/gcc.target/arm/pr65647.c
index d3b44b2..d828d23 100644
--- a/gcc/testsuite/gcc.target/arm/pr65647.c
+++ b/gcc/testsuite/gcc.target/arm/pr65647.c
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target arm_arch_v6m_ok } */
 /* { dg-options "-march=armv6-m -mthumb -O3 -w -mfloat-abi=soft" } */
 
 a, b, c, e, g = &e, h, i = 7, l = 1, m, n, o, q = &m, r, s = &r, u, w = 9, x,


Patch was tested by running the testcase once with -mcpu=cortex-a9
(skipped as expected) and once with -mcpu=cortex-m0 (passes).

Is this ok for trunk?

Best regards,

Thomas




[PATCH AArch64]Handle wrong cost for addition of minus immediate in aarch64_rtx_costs.

2015-06-26 Thread Bin Cheng
Hi,
The canonical form of subtract of immediate is (add op0 minus_imm), which is
supported with addsi3_aarch64 pattern on aarch64.  Unfortunately wrong cost
(8 rather than 4) is computed by aarch64_rtx_cost because it doesn't honor
the fact that it actually is a sub instruction.  This patch fixes it, is
this OK?

Thanks,
bin

2015-06-25  Bin Cheng  

* config/aarch64/aarch64.c (aarch64_rtx_costs): Handle addition of
minus immediate.
Index: gcc/config/aarch64/aarch64.c
===
--- gcc/config/aarch64/aarch64.c(revision 224930)
+++ gcc/config/aarch64/aarch64.c(working copy)
@@ -6049,6 +6049,14 @@ cost_plus:
  *cost += extra_cost->alu.arith;
return true;
  }
+   else if (GET_MODE_CLASS (mode) == MODE_INT
+&& CONST_INT_P (op1)
+&& aarch64_uimm12_shift (- (INTVAL (op1
+ {
+   /* ADD -(immediate).  */
+   op1 = gen_int_mode (- (INTVAL (op1)), mode);
+   goto cost_minus;
+ }
 
*cost += rtx_cost (op1, PLUS, 1, speed);
 


[PATCH GCC][obvious]Don't reset ssa_name infor in struct iv.

2015-06-26 Thread Bin Cheng
Hi,
I applied a patch before to keep ssa_name information in struct iv.  Seems
this function somehow slipped away.
Will apply it to trunk.

Thanks,
bin

2015-06-26  Bin Cheng  

* tree-ssa-loop-ivopts.c (record_sub_use): Don't reset ssa_name
field in struct iv.
Index: gcc/tree-ssa-loop-ivopts.c
===
--- gcc/tree-ssa-loop-ivopts.c  (revision 224930)
+++ gcc/tree-ssa-loop-ivopts.c  (working copy)
@@ -1390,10 +1396,6 @@ record_sub_use (struct ivopts_data *data, tree *us
   pre->next = use;
 }
 
-  /* To avoid showing ssa name in the dumps, if it was not reset by the
- caller.  */
-  iv->ssa_name = NULL_TREE;
-
   return use;
 }
 


Re: Add .def file for public target instructions

2015-06-26 Thread Richard Sandiford
"H.J. Lu"  writes:
> On Thu, Jun 25, 2015 at 4:37 PM, H.J. Lu  wrote:
>> On Thu, Jun 25, 2015 at 4:00 PM, Andrew Pinski  wrote:
>>> On Thu, Jun 25, 2015 at 3:57 PM, H.J. Lu  wrote:
 On Thu, Jun 25, 2015 at 1:09 PM, H.J. Lu  wrote:
> On Tue, Jun 23, 2015 at 11:41 AM, Richard Sandiford
>  wrote:
>> [A fair bit later than promised, sorry...]
>>
>> Mikhail posted a patch to make genflags generate the default HAVE_foo
>> and gen_foo definitions that have recently been added to defaults.h:
>>
>>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00723.html
>>
>> I agree it'd be a good idea to generate this kind of thing automatically,
>> but I think we should take the opportunity to move the interface to the
>> target structure.  I.e.:
>>
>>   HAVE_foo -> targetm.have_foo ()
>>   gen_foo -> targetm.gen_foo ()
>>
>> This should move us closer to the pipedream goal of supporting multiple
>> targets at once.  It should also mean that only the target code depends
>> on insn-flags.h.
>>
>> The patch just moves return and simple_return as an example.  I have more
>> locally (in order to test other code paths), but they're just an obvious
>> extension of this one.
>>
>> The patch relies on the hashing changes in:
>>
>>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01066.html
>>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01564.html
>>
>> and on this trivial patch:
>>
>>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01604.html
>>
>> It seems a bit heavyweight when you just look at these two instructions,
>> but I think it'll be a saving in the end.
>>
>> Bootstrapped & regression-tested on x86_64-linux-gnu.  Also tested
>> via config-list.mk.  OK to install?
>>
>> Thanks,
>> Richard
>>
>>
>> gcc/
>> * Makefile.in (TARGET_DEF): Add target-insns.def.
>> (.PRECIOUS, simple_rtl_generated_h): Add insn-target-def.h.
>> (build/gentarget-def.o): New rule.
>> (genprogrtl): Add target-def.
>> * target-insns.def, gentarget-def.c: New files.
>> * target.def: Add targetm.have_* and targetm.gen_* hooks,
>> based on the contents of target-insns.def.
>> * defaults.h (HAVE_simple_return, gen_simple_return): Delete.
>> (HAVE_return, gen_return): Delete.
>> * target-def.h: Include insn-target-def.h.
>> * cfgrtl.c (force_nonfallthru_and_redirect): Use targetm 
>> interface
>> instead of direct calls.  Rely on them to do the appropriate 
>> assertions.
>> * function.c (gen_return_pattern): Likewise.  Return an rtx_insn 
>> *.
>> (convert_jumps_to_returns): Use targetm interface instead of
>> direct calls.
>> (thread_prologue_and_epilogue_insns): Likewise.
>> * reorg.c (find_end_label, dbr_schedule): Likewise.
>> * shrink-wrap.h (SHRINK_WRAPPING_ENABLED): Likewise.
>> * shrink-wrap.c (convert_to_simple_return): Likewise.
>> (try_shrink_wrapping): Use SHRINK_WRAPPING_ENABLED.
>>
>
> This breaks bootstrap on Linux/ia32:
>
> https://gcc.gnu.org/ml/gcc-regression/2015-06/msg00649.html
>
> ../../src-trunk/gcc/gentarget-def.c: In function âvoid
> def_target_insn(const char*, const char*)â:
> ../../src-trunk/gcc/gentarget-def.c:88:34: error: comparison between
> signed and unsigned integer expressions [-Werror=sign-compare]
>   if (strtol (p + 1, &endptr, 10) != opno
>

 There are

   unsigned int opno = 0;
   for (const char *p = prototype; *p; ++p)
 if (*p == 'x' && ISDIGIT (p[1]))
   {
 /* This should be a parameter name of the form "x".
That doesn't contribute to the suffix, so skip ahead and
process the following character.  */
 char *endptr;
 if (strtol (p + 1, &endptr, 10) != opno
 || (*endptr != ',' && *endptr != ')'))

 strtol returns long int.  Somehow, there is no warning on x86-64.
>>>
>>> Because on x86_64 (and all LP64 targets), the comparison gets promoted
>>> to long (which is 64bit) so the conversion from unsigned int to long
>>> does not lose precision.
>>>
>>
>> I am testing this.
>>
>>
>> --
>> H.J.
>> ---
>> diff --git a/gcc/gentarget-def.c b/gcc/gentarget-def.c
>> index d4839e8..3ca9cfd 100644
>> --- a/gcc/gentarget-def.c
>> +++ b/gcc/gentarget-def.c
>> @@ -77,7 +77,7 @@ def_target_insn (const char *name, const char *prototype)
>>   together to get a suffix.  */
>>char *suffix = XALLOCAVEC (char, strlen (prototype) + 1);
>>i = 0;
>> -  unsigned int opno = 0;
>> +  long opno = 0;
>>for (const char *p = prototype; *p; ++p)
>>  if (*p == 'x' && ISDIGIT (p[1]))
>>{
>
> It doesn't work.  I checked in th

Re: [PATCH, ARM] Restrict pr65647 testcase to ARMv6-M effective target

2015-06-26 Thread Richard Earnshaw
On 26/06/15 09:45, Thomas Preud'homme wrote:
> Hi,
> 
> Testcase for PR65647 assumes that the compiler can compile for ARMv6-M
> which might not be the case if passing some extra options via
> RUNTESTFLAGS (eg. -marm/-mcpu=cortex-a9). This patch restricts the
> testcase to ARMv6-M effective targets.
> 
> 
> Testsuite ChangeLog entry is as follows:
> 
> 2015-06-25  Thomas Preud'homme  
> 
> * gcc.target/arm/pr65647.c: Restrict to ARMv6-M effective targets.
> 
> 
> diff --git a/gcc/testsuite/gcc.target/arm/pr65647.c 
> b/gcc/testsuite/gcc.target/arm/pr65647.c
> index d3b44b2..d828d23 100644
> --- a/gcc/testsuite/gcc.target/arm/pr65647.c
> +++ b/gcc/testsuite/gcc.target/arm/pr65647.c
> @@ -1,4 +1,5 @@
>  /* { dg-do compile } */
> +/* { dg-require-effective-target arm_arch_v6m_ok } */
>  /* { dg-options "-march=armv6-m -mthumb -O3 -w -mfloat-abi=soft" } */
>  
>  a, b, c, e, g = &e, h, i = 7, l = 1, m, n, o, q = &m, r, s = &r, u, w = 9, x,
> 
> 
> Patch was tested by running the testcase once with -mcpu=cortex-a9
> (skipped as expected) and once with -mcpu=cortex-m0 (passes).
> 
> Is this ok for trunk?
> 

OK.

R.

> Best regards,
> 
> Thomas
> 
> 



Re: [PATCH] i386: Do not modify existing RTL (PR66412)

2015-06-26 Thread Segher Boessenkool
On Fri, Jun 26, 2015 at 09:42:06AM +0200, Uros Bizjak wrote:
> Hello!
> 
> > > > [ I see i386 also does PUT_CODE in a few more splitters, hrm. ]
> > >
> > > I think the splitters need to be fixed but I also think that
> > > shallow_copy_rtx should
> > > be enough, no?  combine will not actually end up generating more 
> > > references
> > > to the original RTX so we won't end up with invalid RTX sharing (the same 
> > > logic
> > > is why the splitters didn't care).
> >
> > That probably is enough; I haven't thought about it too much, all other
> > splitters doing a copy do a deep copy.  I don't think it is worth being
> > too tricky here, those splitters do not match often at all.
> >
> > > It would be cleaner to write the splitters in a way that doesnt copy the 
> > > RTX
> > > but creates a new RTX with proper code/mode and operands (but that's more
> > > work on your side - maybe Uros wants to help here).
> >
> > I think people use "copy_rtx; PUT_*" because it is less typing work ;-)
> > If that is the only thing you change about the rtx, it even is easier
> > to understand than creating a new one.
> 
> Attached patch implements both suggestions. It uses shallow_copy_rtx
> before all PUT_* calls in the splitters, to avoid nasty surprises like
> this one in the future. shallow_ropy_rtx copies just one level of RTX,
> and this is all what we need. Also, the patch changes existing uses of
> copy_rtx to shallow_copy_rtx.

Thanks for doing the legwork Uros!  Much appreciated.

Andreas, s390 does a bit of this too (in vector.md).  I cannot really
test for that at all, can you take care of it?


Segher


[PATCH GCC][refacor]Manage allocation of struct iv in obstack.

2015-06-26 Thread Bin Cheng
Hi,
GCC avoids multi-pointers/dangling-pointers of struct iv by allocating
multiple copies of the structure.  This patch is an obvious fix to the issue
by managing iv structures in obstack.

Bootstrap on x86_64, will apply to trunk if no objection.

Thanks,
bin

2015-06-26  Bin Cheng  

* tree-ssa-loop-ivopts.c (struct ivopts_data): New field iv_obstack.
(tree_ssa_iv_optimize_init): Initialize iv_obstack.
(alloc_iv): New parameter.  Allocate struct iv using obstack_alloc.
(set_iv, find_interesting_uses_address, add_candidate_1): New
argument.
(find_interesting_uses_op): Don't duplicate struct iv.
(free_loop_data): Don't free iv structure explicitly.
(tree_ssa_iv_optimize_finalize): Free iv_obstack.
Index: gcc/tree-ssa-loop-ivopts.c
===
--- gcc/tree-ssa-loop-ivopts.c  (revision 224930)
+++ gcc/tree-ssa-loop-ivopts.c  (working copy)
@@ -352,6 +352,9 @@ struct ivopts_data
   /* The maximum invariant id.  */
   unsigned max_inv_id;
 
+  /* Obstack for iv structure.  */
+  struct obstack iv_obstack;
+
   /* Whether to consider just related and important candidates when replacing a
  use.  */
   bool consider_all_candidates;
@@ -912,6 +915,7 @@ tree_ssa_iv_optimize_init (struct ivopts_data *dat
   data->inv_expr_id = 0;
   data->name_expansion_cache = NULL;
   decl_rtl_to_reset.create (20);
+  gcc_obstack_init (&data->iv_obstack);
 }
 
 /* Returns a memory object to that EXPR points.  In case we are able to
@@ -995,10 +999,12 @@ contain_complex_addr_expr (tree expr)
for loop LOOP.  NO_OVERFLOW implies the iv doesn't overflow.  */
 
 static struct iv *
-alloc_iv (tree base, tree step, bool no_overflow = false)
+alloc_iv (struct ivopts_data *data, tree base, tree step,
+ bool no_overflow = false)
 {
   tree expr = base;
-  struct iv *iv = XCNEW (struct iv);
+  struct iv *iv = (struct iv*) obstack_alloc (&data->iv_obstack,
+ sizeof (struct iv));
   gcc_assert (step != NULL_TREE);
 
   /* Lower address expression in base except ones with DECL_P as operand.
@@ -1039,7 +1045,7 @@ set_iv (struct ivopts_data *data, tree iv, tree ba
   gcc_assert (!info->iv);
 
   bitmap_set_bit (data->relevant, SSA_NAME_VERSION (iv));
-  info->iv = alloc_iv (base, step, no_overflow);
+  info->iv = alloc_iv (data, base, step, no_overflow);
   info->iv->ssa_name = iv;
 }
 
@@ -1430,7 +1432,6 @@ static struct iv_use *
 find_interesting_uses_op (struct ivopts_data *data, tree op)
 {
   struct iv *iv;
-  struct iv *civ;
   gimple stmt;
   struct iv_use *use;
 
@@ -1456,14 +1457,11 @@ find_interesting_uses_op (struct ivopts_data *data
 }
   iv->have_use_for = true;
 
-  civ = XNEW (struct iv);
-  *civ = *iv;
-
   stmt = SSA_NAME_DEF_STMT (op);
   gcc_assert (gimple_code (stmt) == GIMPLE_PHI
  || is_gimple_assign (stmt));
 
-  use = record_use (data, NULL, civ, stmt, USE_NONLINEAR_EXPR);
+  use = record_use (data, NULL, iv, stmt, USE_NONLINEAR_EXPR);
   iv->use_id = use->id;
 
   return use;
@@ -2038,7 +2036,7 @@ find_interesting_uses_address (struct ivopts_data
}
 }
 
-  civ = alloc_iv (base, step);
+  civ = alloc_iv (data, base, step);
   record_group_use (data, op_p, civ, stmt, USE_ADDRESS);
   return;
 
@@ -2681,7 +2679,7 @@ add_candidate_1 (struct ivopts_data *data,
   if (!base && !step)
cand->iv = NULL;
   else
-   cand->iv = alloc_iv (base, step);
+   cand->iv = alloc_iv (data, base, step);
 
   cand->pos = pos;
   if (pos != IP_ORIGINAL && cand->iv)
@@ -7188,7 +7186,6 @@ free_loop_data (struct ivopts_data *data)
   struct version_info *info;
 
   info = ver_info (data, i);
-  free (info->iv);
   info->iv = NULL;
   info->has_nonlin_use = false;
   info->preserve_biv = false;
@@ -7207,13 +7204,11 @@ free_loop_data (struct ivopts_data *data)
  gcc_assert (sub->related_cands == NULL);
  gcc_assert (sub->n_map_members == 0 && sub->cost_map == NULL);
 
- free (sub->iv);
  pre = sub;
  sub = sub->next;
  free (pre);
}
 
-  free (use->iv);
   BITMAP_FREE (use->related_cands);
   for (j = 0; j < use->n_map_members; j++)
if (use->cost_map[j].depends_on)
@@ -7227,7 +7222,6 @@ free_loop_data (struct ivopts_data *data)
 {
   struct iv_cand *cand = iv_cand (data, i);
 
-  free (cand->iv);
   if (cand->depends_on)
BITMAP_FREE (cand->depends_on);
   free (cand);
@@ -7269,6 +7263,7 @@ tree_ssa_iv_optimize_finalize (struct ivopts_data
   delete data->inv_expr_tab;
   data->inv_expr_tab = NULL;
   free_affine_expand_cache (&data->name_expansion_cache);
+  obstack_free (&data->iv_obstack, NULL);
 }
 
 /* Returns true if the loop body BODY includes any function calls.  */


[Patch ARM] Fix thinko in use of TARGET_UNIFIED_ASM

2015-06-26 Thread Ramana Radhakrishnan
While paving the way to turn on unified syntax in ARM state I came 
across this use of TARGET_UNIFIED_ASM that really doesn't make sense.


The idea that pop has different encoding sizes is a property of the 
Thumb instruction set rather than a property of which form of unified 
syntax was used. I still have quite a large patch set for the unified 
asm switch but it seems useful to get this one out of the way to catch 
any other issues.


Tested with an appropriate set of multilibs on arm-none-eabi / applied. 
Bootstrapped on armhf.


Applied to trunk.

regards
Ramana


2015-06-26  Ramana Radhakrishnan  

* config/arm/arm.c (arm_output_multireg_pop): Fix use of
TARGET_UNIFIED_ASM.
commit c085a69d4c1b9f9e43ef9655d1e88e7286ca3c2f
Author: Ramana Radhakrishnan 
Date:   Thu Jun 25 09:43:11 2015 +0100

Use TARGET_THUMB2 instead of TARGET_UNIFIED_ASM.

handle Thumb

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 09191e5..84e9e2f 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -17591,7 +17591,7 @@ arm_output_multireg_pop (rtx *operands, bool return_pc, 
rtx cond, bool reverse,
 }
 
   conditional = reverse ? "%?%D0" : "%?%d0";
-  if ((regno_base == SP_REGNUM) && TARGET_UNIFIED_ASM)
+  if ((regno_base == SP_REGNUM) && TARGET_THUMB)
 {
   /* Output pop (not stmfd) because it has a shorter encoding.  */
   gcc_assert (update);


[Patch wwwdocs] Document caveat with guard initializations for C++ on architectures without barrier instructions.

2015-06-26 Thread Ramana Radhakrishnan
As part of the work on PR66192 I promised a doc update at some point - 
here's that - hopefully better late than never.


I also wonder if this is worth putting into the documentation in 
addition to our release notes though I couldn't convince myself that 
standards.texi was the right place for it- any other suggestions are 
welcome.


OK ?


regards
Ramana

Index: htdocs/gcc-6/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-6/changes.html,v
retrieving revision 1.10
diff -a -u -r1.10 changes.html
--- htdocs/gcc-6/changes.html   26 May 2015 10:12:08 -  1.10
+++ htdocs/gcc-6/changes.html   4 Jun 2015 09:21:21 -
@@ -14,6 +14,20 @@
 
 Caveats
 
+
+On bare-metal targets for architectures like ARM
+ that have a relaxed memory model, the compiler will generate
+ code that calls __sync_synchronize for thread-safety
+ of guard accesses for statics in C++ code. In these cases,
+ it is expected that the user will provide either a stub function to
+ implement __sync_synchronize to provide a memory
+ barrier instruction or would compile their application with
+ -fno-threadsafe-statics as may be appropriate.
+ This can be demonstrated with the example in
+ https://gcc.gnu.org/PR66192";>PR66192
+ for the arm-none-eabi target, with the option
+ -mcpu=arm7tdmi on the command line.  
+
 
 
 General Optimizer Improvements


Re: [PATCH][4/n] Remove GENERIC stmt combining from SCCVN

2015-06-26 Thread Richard Biener
On Thu, 25 Jun 2015, Richard Biener wrote:

> 
> This moves fold_sign_changed_comparison.  Shows up in gcc.dg/pr55833.c
> 
> I'll eventually massage it according to Jakubs suggestion to do a
> 
> #ifndef HAVE_canonicalize_funcptr_for_compare
> #define HAVE_canonicalize_funcptr_for_compare 0
> #endif
> 
> somewhere (defaults.h should work I guess).
> 
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.

This runs into

Running target unix//-m32
FAIL: g++.dg/tree-ssa/calloc.C  -std=gnu++11  scan-tree-dump-not optimized 
"malloc"

where we now optimize

   n_5 = (size_t) n_4(D);
...
   :
   -  if (n_5 != 0)
   +  if (n_4(D) != 0)

but both VRP and DOM fail to record equivalences for n_5 from
the updated condition (I have a patch to fix VRP but not DOM).

When we restrict the transform to trigger on single-use n_5
only the patch doesn't fix the SCCVN regression that shows up
in gcc.dg/pr55833.c (SCCVN currently uses GENERIC folding which
doesn't care about single-uses and thus if switched to GIMPLE
folding it suddenly regresses).

Putting this one on hold for the moment.

I think we're simply missing a pass that can "properly" deal
with this kind of stuff.  For example DOM could re-visit
stmts which have uses of SSA names we added temporary
equivalences for (ones that dominate the current block,
others we'll (re-)visit anyway).  That would fix this testcase
but to catch secondary effects you'd need to re-visit uses of
the defs of the revisited stmts as well (if anything interesting
was produced, of course).

Richard.

> Richard.
> 
> gcc.dg/pr55833.c
> 
> 2015-06-25  Richard Biener  
> 
>   * fold-const.c (fold_sign_changed_comparison): Remove.
>   * match.pd: Instead add same functionality here.
> 
> Index: gcc/fold-const.c
> ===
> --- gcc/fold-const.c  (revision 224893)
> +++ gcc/fold-const.c  (working copy)
> @@ -7044,57 +7044,6 @@ fold_widened_comparison (location_t loc,
>return NULL_TREE;
>  }
>  
> -/* Fold comparison ARG0 CODE ARG1 (with result in TYPE), where for
> -   ARG0 just the signedness is changed.  */
> -
> -static tree
> -fold_sign_changed_comparison (location_t loc, enum tree_code code, tree type,
> -   tree arg0, tree arg1)
> -{
> -  tree arg0_inner;
> -  tree inner_type, outer_type;
> -
> -  if (!CONVERT_EXPR_P (arg0))
> -return NULL_TREE;
> -
> -  outer_type = TREE_TYPE (arg0);
> -  arg0_inner = TREE_OPERAND (arg0, 0);
> -  inner_type = TREE_TYPE (arg0_inner);
> -
> -#ifdef HAVE_canonicalize_funcptr_for_compare
> -  /* Disable this optimization if we're casting a function pointer
> - type on targets that require function pointer canonicalization.  */
> -  if (HAVE_canonicalize_funcptr_for_compare
> -  && TREE_CODE (inner_type) == POINTER_TYPE
> -  && TREE_CODE (TREE_TYPE (inner_type)) == FUNCTION_TYPE)
> -return NULL_TREE;
> -#endif
> -
> -  if (TYPE_PRECISION (inner_type) != TYPE_PRECISION (outer_type))
> -return NULL_TREE;
> -
> -  if (TREE_CODE (arg1) != INTEGER_CST
> -  && !(CONVERT_EXPR_P (arg1)
> -&& TREE_TYPE (TREE_OPERAND (arg1, 0)) == inner_type))
> -return NULL_TREE;
> -
> -  if (TYPE_UNSIGNED (inner_type) != TYPE_UNSIGNED (outer_type)
> -  && code != NE_EXPR
> -  && code != EQ_EXPR)
> -return NULL_TREE;
> -
> -  if (POINTER_TYPE_P (inner_type) != POINTER_TYPE_P (outer_type))
> -return NULL_TREE;
> -
> -  if (TREE_CODE (arg1) == INTEGER_CST)
> -arg1 = force_fit_type (inner_type, wi::to_widest (arg1), 0,
> -TREE_OVERFLOW (arg1));
> -  else
> -arg1 = fold_convert_loc (loc, inner_type, arg1);
> -
> -  return fold_build2_loc (loc, code, type, arg0_inner, arg1);
> -}
> -
>  
>  /* Fold A < X && A + 1 > Y to A < X && A >= Y.  Normally A + 1 > Y
> means A >= Y && A != MAX, but in this case we know that
> @@ -9252,11 +9201,6 @@ fold_comparison (location_t loc, enum tr
>tem = fold_widened_comparison (loc, code, type, arg0, arg1);
>if (tem)
>   return tem;
> -
> -  /* Or if we are changing signedness.  */
> -  tem = fold_sign_changed_comparison (loc, code, type, arg0, arg1);
> -  if (tem)
> - return tem;
>  }
>  
>/* If this is comparing a constant with a MIN_EXPR or a MAX_EXPR of a
> Index: gcc/match.pd
> ===
> --- gcc/match.pd  (revision 224893)
> +++ gcc/match.pd  (working copy)
> @@ -1086,6 +1196,30 @@ (define_operator_list swapped_tcc_compar
>  (if (tem && !TREE_OVERFLOW (tem))
>   (scmp @0 { tem; }))
>  
> +/* From fold_sign_changed_comparison.  */
> +(for cmp (tcc_comparison)
> + (simplify
> +  (cmp (convert@0 @00) (convert?@1 @10))
> +  (if (TREE_CODE (TREE_TYPE (@0)) == INTEGER_TYPE)
> +   /* Disable this optimization if we're casting a function pointer
> +  type on targets that require function pointer canonicalization.  */
> +#ifdef HAVE_canonicalize_f

Re: match.pd: Optimize (x | y) & ~(x & y) and (x | y) & (~x ^ y)

2015-06-26 Thread Richard Biener
On Fri, 26 Jun 2015, Marek Polacek wrote:

> The following patch adds optimizing of
> (x | y) & ~(x & y)
> and
> (x | y) & (~x ^ y)
> to a single operation.
> 
> No +/-/* in those, so I think we don't have to worry about saturating types
> this time around.
> 
> For some reason I had to use more :c's in the latter pattern than usual.

Yeah, I double-checked and indeed you can't remove any there.

> Bootstrapped/regtested on x86_64-linux, ok for trunk?

Ok.  (I suppose you always check whether the patterns are in fold-const.c
and remove them there if you spot them)

Thanks,
Richard.

> 2015-06-26  Marek Polacek  
> 
>   * match.pd ((x | y) & ~(x & y) -> x ^ y,
>   (x | y) & (~x ^ y) -> x & y): New patterns.
> 
>   * gcc.dg/fold-and-1.c: New test.
>   * gcc.dg/fold-and-2.c: New test.
> 
> diff --git gcc/match.pd gcc/match.pd
> index 292ce6d..f242c99 100644
> --- gcc/match.pd
> +++ gcc/match.pd
> @@ -367,6 +367,16 @@ along with GCC; see the file COPYING3.  If not see
>   (minus (bit_ior @0 @1) (bit_and @0 @1))
>   (bit_xor @0 @1))
>  
> +/* (x | y) & ~(x & y) -> x ^ y */
> +(simplify
> + (bit_and:c (bit_ior @0 @1) (bit_not (bit_and @0 @1)))
> + (bit_xor @0 @1))
> +
> +/* (x | y) & (~x ^ y) -> x & y */
> +(simplify
> + (bit_and:c (bit_ior:c @0 @1) (bit_xor:c @1 (bit_not @0)))
> + (bit_and @0 @1))
> +
>  (simplify
>   (abs (negate @0))
>   (abs @0))
> diff --git gcc/testsuite/gcc.dg/fold-and-1.c gcc/testsuite/gcc.dg/fold-and-1.c
> index e69de29..d555bb4 100644
> --- gcc/testsuite/gcc.dg/fold-and-1.c
> +++ gcc/testsuite/gcc.dg/fold-and-1.c
> @@ -0,0 +1,70 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O -fdump-tree-cddce1" } */
> +
> +int
> +fn1 (int x, int y)
> +{
> +  int tem1 = x | y;
> +  int tem2 = ~(x & y);
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn2 (int x, int y)
> +{
> +  int tem1 = y | x;
> +  int tem2 = ~(x & y);
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn3 (int x, int y)
> +{
> +  int tem1 = x | y;
> +  int tem2 = ~(y & x);
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn4 (int x, int y)
> +{
> +  int tem1 = y | x;
> +  int tem2 = ~(y & x);
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn5 (int x, int y)
> +{
> +  int tem1 = ~(x & y);
> +  int tem2 = x | y;
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn6 (int x, int y)
> +{
> +  int tem1 = ~(x & y);
> +  int tem2 = y | x;
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn7 (int x, int y)
> +{
> +  int tem1 = ~(y & x);
> +  int tem2 = x | y;
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn8 (int x, int y)
> +{
> +  int tem1 = ~(y & x);
> +  int tem2 = y | x;
> +  return tem1 & tem2;
> +}
> +
> +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */
> +/* { dg-final { scan-tree-dump-not " \\& " "cddce1" } } */
> +/* { dg-final { scan-tree-dump-not "~" "cddce1" } } */
> diff --git gcc/testsuite/gcc.dg/fold-and-2.c gcc/testsuite/gcc.dg/fold-and-2.c
> index e69de29..3df2a0b 100644
> --- gcc/testsuite/gcc.dg/fold-and-2.c
> +++ gcc/testsuite/gcc.dg/fold-and-2.c
> @@ -0,0 +1,70 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O -fdump-tree-cddce1" } */
> +
> +int
> +fn1 (int x, int y)
> +{
> +  int tem1 = x | y;
> +  int tem2 = ~x ^ y;
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn2 (int x, int y)
> +{
> +  int tem1 = y | x;
> +  int tem2 = ~x ^ y;
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn3 (int x, int y)
> +{
> +  int tem1 = x | y;
> +  int tem2 = y ^ ~x;
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn4 (int x, int y)
> +{
> +  int tem1 = y | x;
> +  int tem2 = y ^ ~x;
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn5 (int x, int y)
> +{
> +  int tem1 = ~x ^ y;
> +  int tem2 = x | y;
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn6 (int x, int y)
> +{
> +  int tem1 = ~x ^ y;
> +  int tem2 = y | x;
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn7 (int x, int y)
> +{
> +  int tem1 = y ^ ~x;
> +  int tem2 = x | y;
> +  return tem1 & tem2;
> +}
> +
> +int
> +fn8 (int x, int y)
> +{
> +  int tem1 = y ^ ~x;
> +  int tem2 = y | x;
> +  return tem1 & tem2;
> +}
> +
> +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */
> +/* { dg-final { scan-tree-dump-not " \\^ " "cddce1" } } */
> +/* { dg-final { scan-tree-dump-not "~" "cddce1" } } */
> 
>   Marek
> 
> 

-- 
Richard Biener 
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham 
Norton, HRB 21284 (AG Nuernberg)


[AArch64][1/2] Rename SYMBOL_SMALL_GOT to SYMBOL_SMALL_GOT_4G

2015-06-26 Thread Jiong Wang

Marcus Shawcroft writes:

> On 23 June 2015 at 14:02, Jiong Wang  wrote:
>>
>> Marcus Shawcroft writes:
>>
>>> On 20 May 2015 at 11:21, Jiong Wang  wrote:
>>>
 gcc/
   * config/aarch64/aarch64.md: (ldr_got_small_): Support new GOT 
 relocation
   modifiers.
   (ldr_got_small_sidi): Ditto.
   * config/aarch64/iterators.md (got_modifier): New mode iterator.
   * config/aarch64/aarch64-otps.h (aarch64_code_model): New model.
   * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Support 
 -fpic.
   (aarch64_rtx_costs): Add costs for new instruction sequences.
   (initialize_aarch64_code_model): Initialize new model.
   (aarch64_classify_symbol): Recognize new model.
   (aarch64_asm_preferred_eh_data_format): Support new model.
   (aarch64_load_symref_appropriately): Generate new instruction sequences 
 for -fpic.
   (TARGET_USE_PSEUDO_PIC_REG): New definition.
   (aarch64_use_pseudo_pic_reg): New function.

 gcc/testsuite/
   * gcc.target/aarch64/pic-small.c: New testcase.
>>>
>>>
>>> Rather than thread tests against aarch64_cmodel throughout the
>>> existing code can we instead extend classify_symbol with a new symbol
>>> classification?
>>
>> Yes, we can. As -fPIC/-fpic allow 4G/32K GOT table size, we may name
>> corresponding symbol classification as "SYMBOL_GOT_4G",
>> "SYMBOL_GOT_32K".
>>
>> But can we let this patch go in and create a another patch to improve
>> this? there are several other TLS patches may needs rebase if we change
>> this immedaitely.
>
> We can wait for a proper solution that fits with the code already in place.

OK. Reworked this patch. Removed those redundant memory model check by
adding new symbol classification. Patch splitted into two:

  * [1/2] Rename SYMBOL_SMALL_GOT to SYMBOL_SMALL_GOT_4G
  * [2/2] Implement -fpic for -mcmodel=small

This is the first patch which only renmae SYMBOL_SMALL_GOT into
SYMBOL_SMALL_GOT_4G. Please review, Thanks.

2015-06-26  Jiong Wang  

gcc/
  * config/aarch64/aarch64-protos.h (aarch64_symbol_type): Rename
  SYMBOL_SMALL_GOT to SYMBOL_SMALL_GOT_4G.
  * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Ditto.
  (aarch64_expand_mov_immediate): Ditto.
  (aarch64_print_operand): Ditto.
  (aarch64_classify_symbol): Ditto.

---
 gcc/config/aarch64/aarch64-protos.h |  7 ---
 gcc/config/aarch64/aarch64.c| 10 +-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 965a11b..36bd051 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -49,12 +49,13 @@ enum aarch64_symbol_context
 
This corresponds to the small code model of the compiler.
 
-   SYMBOL_SMALL_GOT: Similar to the one above but this
+   SYMBOL_SMALL_GOT_4G: Similar to the one above but this
gives us the GOT entry of the symbol being referred to :
Thus calculating the GOT entry for foo is done using the
following sequence of instructions.  The ADRP instruction
gets us to the page containing the GOT entry of the symbol
-   and the got_lo12 gets us the actual offset in it.
+   and the got_lo12 gets us the actual offset in it, together
+   the base and offset, we can address 4G size GOT table.
 
adrp  x0, :got:foo
ldr   x0, [x0, :gotoff_lo12:foo]
@@ -94,7 +95,7 @@ enum aarch64_symbol_context
 enum aarch64_symbol_type
 {
   SYMBOL_SMALL_ABSOLUTE,
-  SYMBOL_SMALL_GOT,
+  SYMBOL_SMALL_GOT_4G,
   SYMBOL_SMALL_TLSGD,
   SYMBOL_SMALL_TLSDESC,
   SYMBOL_SMALL_GOTTPREL,
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 17bae08..776600f 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -814,7 +814,7 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm,
   emit_insn (gen_rtx_SET (dest, imm));
   return;
 
-case SYMBOL_SMALL_GOT:
+case SYMBOL_SMALL_GOT_4G:
   {
 	/* In ILP32, the mode of dest can be either SImode or DImode,
 	   while the got entry is always of SImode size.  The mode of
@@ -1466,7 +1466,7 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm)
 case SYMBOL_SMALL_TLSGD:
 case SYMBOL_SMALL_TLSDESC:
 case SYMBOL_SMALL_GOTTPREL:
-	case SYMBOL_SMALL_GOT:
+	case SYMBOL_SMALL_GOT_4G:
 	case SYMBOL_TINY_GOT:
 	  if (offset != const0_rtx)
 	{
@@ -4333,7 +4333,7 @@ aarch64_print_operand (FILE *f, rtx x, char code)
 
   switch (aarch64_classify_symbolic_expression (x, SYMBOL_CONTEXT_ADR))
 	{
-	case SYMBOL_SMALL_GOT:
+	case SYMBOL_SMALL_GOT_4G:
 	  asm_fprintf (asm_out_file, ":got:");
 	  break;
 
@@ -4366,7 +4366,7 @@ aarch64_print_operand (FILE *f, rtx x, char code)
 case 'L':
   switch (aarch64_classify_symbolic_expression (x, SYMBOL_CONTEXT_ADR))
 	{
-	case SYMBOL_SMALL_GOT:
+	case SYMBOL_SMALL_GOT_4G:
 	  asm_fprintf (asm_out_file, ":lo12:");
 	  break;
 
@@ -7377,7 +7377,7 @@ aarch64_classify_symbol (r

[AArch64][2/2] Implement -fpic for -mcmodel=small

2015-06-26 Thread Jiong Wang

This patch respin https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01804.html.

A new symbol classification "SYMBOL_SMALL_GOT_28K" added to represent symbol
which needs go through GOT table and it's under -fpic/-mcmodel-small. the "_28K"
suffix can reflect the symbol's attribute better, and by introducing this new
symbol type, we could avoid checking aarch64_cmodel at some extent
though still needs the check somewhere.

All other code logic not changed.

OK for trunk?

Thanks.

2015-06-26  Jiong. Wang  

gcc/
  * config/aarch64/aarch64-protos.h (aarch64_symbol_type): New type
  SYMBOL_SMALL_GOT_28K.
  * config/aarch64/aarch64.md: (ldr_got_small_): Support new GOT
  relocation modifiers.
  (unspec): New enum "UNSPEC_GOTMALLPIC28K.
  (ldr_got_small_28k_): New.
  (ldr_got_small_28k_sidi): New.
  * config/aarch64/iterators.md (got_modifier): New mode iterator.
  * config/aarch64/aarch64-otps.h (aarch64_code_model): New model.
  * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Support
  SYMBOL_SMALL_GOT_28K.
  (aarch64_rtx_costs): Add costs for new instruction sequences.
  (initialize_aarch64_code_model): Initialize new model.
  (aarch64_classify_symbol): Recognize new model and new symbol classification.
  (aarch64_asm_preferred_eh_data_format): Support new model.
  (aarch64_load_symref_appropriately): Generate new instruction
  sequences for -fpic.
  (TARGET_USE_PSEUDO_PIC_REG): New definition.
  (aarch64_use_pseudo_pic_reg): New function.

gcc/testsuite/
  * gcc.target/aarch64/pic-small.c: New testcase.

Regards,
Jiong

diff --git a/gcc/config/aarch64/aarch64-opts.h b/gcc/config/aarch64/aarch64-opts.h
index ea64cf4..24bfd9f 100644
--- a/gcc/config/aarch64/aarch64-opts.h
+++ b/gcc/config/aarch64/aarch64-opts.h
@@ -56,6 +56,9 @@ enum aarch64_code_model {
   /* Static code, data and GOT/PLT fit within a 4GB region.
  The default PIC code model.  */
   AARCH64_CMODEL_SMALL_PIC,
+  /* -fpic for small memory model.
+ GOT size to 28KiB (4K*8-4K) or 3580 entries.  */
+  AARCH64_CMODEL_SMALL_SPIC,
   /* No assumptions about addresses of code and data.
  The PIC variant is not yet implemented.  */
   AARCH64_CMODEL_LARGE
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 36bd051..9b506d5 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -62,6 +62,13 @@ enum aarch64_symbol_context
 
This corresponds to the small PIC model of the compiler.
 
+   SYMBOL_SMALL_GOT_28K: Similar to SYMBOL_SMALL_GOT_4G, but used for symbol
+   restricted within 28K GOT table size.
+
+   ldr reg, [gp, #:gotpage_lo15:sym]
+
+   This corresponds to -fpic model for small memory model of the compiler.
+
SYMBOL_SMALL_TLSGD
SYMBOL_SMALL_TLSDESC
SYMBOL_SMALL_GOTTPREL
@@ -95,6 +102,7 @@ enum aarch64_symbol_context
 enum aarch64_symbol_type
 {
   SYMBOL_SMALL_ABSOLUTE,
+  SYMBOL_SMALL_GOT_28K,
   SYMBOL_SMALL_GOT_4G,
   SYMBOL_SMALL_TLSGD,
   SYMBOL_SMALL_TLSDESC,
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 776600f..2a1be00 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -814,6 +814,66 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm,
   emit_insn (gen_rtx_SET (dest, imm));
   return;
 
+case SYMBOL_SMALL_GOT_28K:
+  {
+	machine_mode mode = GET_MODE (dest);
+	rtx gp_rtx = pic_offset_table_rtx;
+
+	/* NOTE: pic_offset_table_rtx can be NULL_RTX, because we can reach
+	   here before rtl expand.  Tree IVOPT will generate rtl pattern to
+	   decide rtx costs, in which case pic_offset_table_rtx is not
+	   initialized.  For that case no need to generate the first adrp
+	   instruction as the the final cost for global variable access is
+	   one instruction.  */
+	if (gp_rtx != NULL)
+	  {
+	/* -fpic for -mcmodel=small allow 32K GOT table size (but we are
+	   using the page base as GOT base, the first page may be wasted,
+	   in the worst scenario, there is only 28K space for GOT).
+
+	   The generate instruction sequence for accessing global variable
+	   is:
+
+	 ldr reg, [pic_offset_table_rtx, #:gotpage_lo15:sym]
+
+	   Only one instruction needed. But we must initialize
+	   pic_offset_table_rtx properly.  We generate initialize insn for
+	   every global access, and allow CSE to remove all redundant.
+
+	   The final instruction sequences will look like the following
+	   for multiply global variables access.
+
+	 adrp pic_offset_table_rtx, _GLOBAL_OFFSET_TABLE_
+
+	 ldr reg, [pic_offset_table_rtx, #:gotpage_lo15:sym1]
+	 ldr reg, [pic_offset_table_rtx, #:gotpage_lo15:sym2]
+	 ldr reg, [pic_offset_table_rtx, #:gotpage_lo15:sym3]
+	 ...  */
+
+	rtx s = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
+	crtl->uses_pic_offset_table = 1;
+	emit_move_insn (gp_rtx, gen_rtx_HIGH (Pmode, s));
+
+	if (mode != GET_MODE (gp_rtx))
+	  gp_rt

Re: [patch] PR debug/66653: avoid late_global_decl on decl_type_context()s

2015-06-26 Thread Richard Biener
On Thu, Jun 25, 2015 at 6:56 PM, Jason Merrill  wrote:
> On 06/24/2015 11:12 PM, Aldy Hernandez wrote:
>>
>> The problem here is that we are trying to call
>> dwarf2out_late_global_decl() on a static variable in a template which
>> has a type of TEMPLATE_TYPE_PARM:
>>
>> template  class A
>> {
>>static __thread T a;
>> };
>>
>> We are calling late_global_decl because we are about to remove the
>> unused static from the symbol table:
>
>
> The problem here is that 'a' should never have been in the symbol table in
> the first place, since it's an uninstantiated template.  It's there because
> of honza's change to store the TLS model in the symbol table, so TLS
> templates end up with varpool entries that, of course, will never be
> referenced.

Can we defer TLS model setting to template instantiation?

> I guess either we need to avoid putting these templates in the symbol table
> or we need to mark these fake entries somehow.
>
> Jason
>


Re: [patch] Remove fold-const.h as a dependency for gimple.h

2015-06-26 Thread Richard Biener
On Thu, Jun 25, 2015 at 10:57 PM, Jeff Law  wrote:
> On 06/25/2015 02:31 PM, Andrew MacLeod wrote:
>>
>> I proposed including fold-const.h into gimple.h, but didn't notice that
>> its actually only needed by one inline function. Moving that function to
>> gimple.c means its no longer required.
>>
>> 160 places need cgraph.h, so by removing this dependency, the number of
>> those files which still need fold-const.h drops to 108 uses.
>> The other 2 files are generally used by many of the files which include
>> gimple.h, so trying to break those dependencies doesn't accomplish much.
>>
>> This patch is currently undergoing testing, but expect no problems .
>> Assuming it bootstraps on x86_64-unknown-linux-gnu with no new
>> regressions, OK for trunk?
>
> OK.

Well, it's also just lazy in using build_fold_addr_expr_loc because it
doesn't want to spell out the all-tree.h

   build1_loc (gimple_location (gs), ADDR_EXPR, build_pointer_type
(decl), decl);

there is nothing to be simplified (setting a location here is also a waste).

Richard.

> Jeff


Re: Remove redundant AND from count reduction loop

2015-06-26 Thread Richard Biener
On Fri, Jun 26, 2015 at 12:39 AM, Marc Glisse  wrote:
> On Wed, 24 Jun 2015, Richard Biener wrote:
>
>> On Wed, Jun 24, 2015 at 11:57 AM, Richard Sandiford
>>  wrote:
>>>
>>> Richard Biener  writes:

 On Tue, Jun 23, 2015 at 11:27 PM, Marc Glisse 
 wrote:
>
> On Tue, 23 Jun 2015, Richard Sandiford wrote:
>
>> +/* Vector comparisons are defined to produce all-one or all-zero
>> results.
>> */
>> +(simplify
>> + (vec_cond @0 integer_all_onesp@1 integer_zerop@2)
>> + (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
>> +   (convert @0)))
>
>
>
> I am trying to understand why the test tree_nop_conversion_p is the
> right
> one (at least for the transformations not using VIEW_CONVERT_EXPR). By
> definition of VEC_COND_EXPR, type and TREE_TYPE (@0) are both integer
> vector
> types of the same size and number of elements. It thus seems like a
> conversion is always fine. For vectors, tree_nop_conversion_p
> apparently
> only checks that they have the same mode (quite often VOIDmode I
> guess).


 The only conversion we seem to allow is changing the signed vector from
 the comparison result to an unsigned vector (same number of elements
 and same mode of the elements).  That is, a check using
 TYPE_MODE (type) == TYPE_MODE (TREE_TYPE (@0)) would probably
 be better (well, technically a TYPE_VECTOR_SUBPARTS && element
 mode compare should be better as generic vectors might not have a vector
 mode).
>>>
>>>
>>> OK.  The reason I was being paranoid was that I couldn't see anywhere
>>> where we enforced that the vector condition in a VEC_COND had to have
>>> the same element width as the values being selected.
>>
>>
>> We don't require that indeed.
>>
>>>  tree-cfg.c
>>> only checks that rhs2 and rhs3 are compatible with the result.
>>> There doesn't seem to be any checking of rhs1 vs. the other types.
>>> So I wasn't sure whether anything stopped us from, e.g., comparing two
>>> V4HIs and using the result to select between two V4SIs.
>>
>>
>> Nothing does (or should).
>
>
> The documentation patch you approved in
> https://gcc.gnu.org/ml/gcc-patches/2012-10/msg01109.html says something
> different. If it is really wrong, could you fix it?

Hmm, that simplifies things.  It would be nice if these constraints
would also be
checked in the gimple verifier...

Richard.

> --
> Marc Glisse


Re: [Patch, C++, PR65882] Check tf_warning flag in build_new_op_1

2015-06-26 Thread James Greenhalgh
On Wed, Jun 24, 2015 at 09:28:34PM +0100, Mikhail Maltsev wrote:
> On 06/24/2015 06:52 PM, Christophe Lyon wrote:
> > Hi Mikhail,
> > 
> > In the gcc-5-branch, I can see that your new inhibit-warn-2.C test
> > fails (targets ARM and AArch64).
> > 
> > I can see this error message in g++.log:
> > /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C:
> > In function 'void fn1()':
> > /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C:29:3:
> > error: 'typename A<(F
> >> ::type>::value || B:: value)>::type D::operator=(Expr) [with Expr =
> > int; typename A<(F
> >> ::type>::value || B:: value)>::type = int]' is private
> > /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C:35:7:
> > error: within this context
> > 
> > Christophe.
> > 
> Oops. Sorry for that, it seems that I messed up with my testing box and
> the backport did not actually get regtested :(.
> 
> The problem is caused by difference in wording of diagnostics. GCC 6
> gives an error on line 35 and a note on line 29:
> 
> $ ./cc1plus ~/gcc/src/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C
>  void fn1()
> /home/miyuki/gcc/src/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C:35:7:
> error: 'typename A<(F
> >::type>::value || B:: value)>::type D::operator=(Expr) [with Expr =
> int; typename A<(F >::type>::value
> || B:: value)>::type = int]' is private within this context
>opt = 0;
> /home/miyuki/gcc/src/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C:29:3:
> note: declared private here
>operator=(Expr);
> 
> GCC 5 gives two errors:
> 
> /home/miyuki/gcc/src/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C:29:3:
> error: 'typename A<(F
> >::type>::value || B:: value)>::type D::operator=(Expr) [with Expr =
> int; typename A<(F >::type>::value
> || B:: value)>::type = int]' is private
>operator=(Expr);
> /home/miyuki/gcc/src/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C:35:7:
> error: within this context
>opt = 0;
> 
> It can probably be fixed like this:
> 
> diff --git a/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C
> b/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C
> index cb16b4c..f658c1d 100644
> --- a/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C
> +++ b/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C
> @@ -26,11 +26,11 @@ class D
>  {
>template 
>typename A::type>::value || B::value>::type
> -  operator=(Expr); // { dg-message "declared" }
> +  operator=(Expr); // { dg-message "private" }
>  };
> 
>  void fn1()
>  {
>D opt;
> -  opt = 0; // { dg-error "private" }
> +  opt = 0; // { dg-error "this context" }
>  }
> 
> But I am not sure, what should I do in this case. Maybe it is better to
> remove the failing testcase from GCC 5 branch (provided that
> inhibit-warn-1.C tests a fix for the same bug and does not fail)?

Your fix looks sensible to me, and I'd like to see it applied before
the 5.2 cut. Hopefully someone with the authority to OK the fixup will
be along shortly!

Thanks,
James




[committed] C++ PATCH to use INDIRECT_REF_P

2015-06-26 Thread Marek Polacek
As the subject says.

Bootstrapped/regtested on x86_64-linux, applying to trunk.

2015-06-26  Marek Polacek  

* cp-array-notation.c (expand_sec_reduce_builtin): Use INDIRECT_REF_P.
* cp-ubsan.c (cp_ubsan_check_member_access_r): Likewise.

diff --git gcc/cp/cp-array-notation.c gcc/cp/cp-array-notation.c
index 3b8610f..9b8034e 100644
--- gcc/cp/cp-array-notation.c
+++ gcc/cp/cp-array-notation.c
@@ -345,7 +345,7 @@ expand_sec_reduce_builtin (tree an_builtin_fn, tree 
*new_var)
 array_ind_value = get_temp_regvar (TREE_TYPE (func_parm), func_parm);
 
   array_op0 = (*array_operand)[0];
-  if (TREE_CODE (array_op0) == INDIRECT_REF)
+  if (INDIRECT_REF_P (array_op0))
 array_op0 = TREE_OPERAND (array_op0, 0);
   switch (an_type)
 {
diff --git gcc/cp/cp-ubsan.c gcc/cp/cp-ubsan.c
index 0c1b047..c0d1ffc 100644
--- gcc/cp/cp-ubsan.c
+++ gcc/cp/cp-ubsan.c
@@ -200,7 +200,7 @@ cp_ubsan_check_member_access_r (tree *stmt_p, int 
*walk_subtrees, void *data)
 {
 case ADDR_EXPR:
   t = TREE_OPERAND (stmt, 0);
-  while ((TREE_CODE (t) == MEM_REF || TREE_CODE (t) == INDIRECT_REF)
+  while ((TREE_CODE (t) == MEM_REF || INDIRECT_REF_P (t))
 && TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR)
t = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
   if (handled_component_p (t))

Marek


[Ada] Implement custom version of -Waggressive-loop-optimizations

2015-06-26 Thread Eric Botcazou
-Waggressive-loop-optimizations only warns in very specific cases, notably 
only if the bounds of the loop are constant, and this is not sufficient to 
catch all the interesting cases in Ada.  Hence this custom implementation.

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


2015-06-26  Eric Botcazou  

* gcc-interface/trans.c (loop_info_d): Add low_bound, high_bound,
artificial, has_checks and warned_aggressive_loop_optimizations.
(gigi): Set warn_aggressive_loop_optimizations to 0.
(inside_loop_p): New inline predicate.
(push_range_check_info): Rename into...
(find_loop_for): ...this and do not push range_check_info_d object.
(Loop_Statement_to_gnu): Set artificial, low_bound and high_bound
fields of gnu_loop_info.  Adjust detection of checks enabled by
-funswitch-loops and adds one for -faggressive-loop-optimizations.
(gnat_to_gnu) : If aggressive loop optimizations
are enabled, warn for loops overrunning an array of size 1 not at the
end of a record.


2015-06-26  Eric Botcazou  

* gnat.dg/warn11.adb: Add missing dg directive.
* gnat.dg/warn12.adb: New test.
* gnat.dg/warn12_pkg.ads: New helper.


-- 
Eric BotcazouIndex: gcc-interface/trans.c
===
--- gcc-interface/trans.c	(revision 224993)
+++ gcc-interface/trans.c	(working copy)
@@ -209,7 +209,12 @@ typedef struct range_check_info_d *range
 struct GTY(()) loop_info_d {
   tree stmt;
   tree loop_var;
+  tree low_bound;
+  tree high_bound;
   vec *checks;
+  bool artificial;
+  bool has_checks;
+  bool warned_aggressive_loop_optimizations;
 };
 
 typedef struct loop_info_d *loop_info;
@@ -671,6 +676,10 @@ gigi (Node_Id gnat_root,
   /* Now translate the compilation unit proper.  */
   Compilation_Unit_to_gnu (gnat_root);
 
+  /* Disable -Waggressive-loop-optimizations since we implement our own
+ version of the warning.  */
+  warn_aggressive_loop_optimizations = 0;
+
   /* Then process the N_Validate_Unchecked_Conversion nodes.  We do this at
  the very end to avoid having to second-guess the front-end when we run
  into dummy nodes during the regular processing.  */
@@ -2622,12 +2631,19 @@ Case_Statement_to_gnu (Node_Id gnat_node
   return gnu_result;
 }
 
-/* Find out whether VAR is an iteration variable of an enclosing loop in the
-   current function.  If so, push a range_check_info structure onto the stack
-   of this enclosing loop and return it.  Otherwise, return NULL.  */
+/* Return true if we are in the body of a loop.  */
 
-static struct range_check_info_d *
-push_range_check_info (tree var)
+static inline bool
+inside_loop_p (void)
+{
+  return !vec_safe_is_empty (gnu_loop_stack);
+}
+
+/* Find out whether VAR is the iteration variable of an enclosing loop in the
+   current function.  If so, return the loop; otherwise, return NULL.  */
+
+static struct loop_info_d *
+find_loop_for (tree var)
 {
   struct loop_info_d *iter = NULL;
   unsigned int i;
@@ -2648,14 +2664,7 @@ push_range_check_info (tree var)
 if (var == iter->loop_var)
   break;
 
-  if (iter)
-{
-  struct range_check_info_d *rci = ggc_alloc ();
-  vec_safe_push (iter->checks, rci);
-  return rci;
-}
-
-  return NULL;
+  return iter;
 }
 
 /* Return true if VAL (of type TYPE) can equal the minimum value if MAX is
@@ -2746,6 +2755,7 @@ Loop_Statement_to_gnu (Node_Id gnat_node
 
   /* Save the statement for later reuse.  */
   gnu_loop_info->stmt = gnu_loop_stmt;
+  gnu_loop_info->artificial = !Comes_From_Source (gnat_node);
 
   /* Set the condition under which the loop must keep going.
  For the case "LOOP  END LOOP;" the condition is always true.  */
@@ -2941,6 +2951,8 @@ Loop_Statement_to_gnu (Node_Id gnat_node
 	  SET_DECL_INDUCTION_VAR (gnu_loop_var, gnu_loop_iv);
 	}
   gnu_loop_info->loop_var = gnu_loop_var;
+  gnu_loop_info->low_bound = gnu_low;
+  gnu_loop_info->high_bound = gnu_high;
 
   /* Do all the arithmetics in the base type.  */
   gnu_loop_var = convert (gnu_base_type, gnu_loop_var);
@@ -5334,7 +5346,7 @@ Raise_Error_to_gnu (Node_Id gnat_node, t
 	{
 	  Node_Id gnat_range, gnat_index, gnat_type;
 	  tree gnu_index, gnu_low_bound, gnu_high_bound;
-	  struct range_check_info_d *rci;
+	  struct loop_info_d *loop;
 
 	  switch (Nkind (Right_Opnd (gnat_cond)))
 	{
@@ -5382,24 +5394,36 @@ Raise_Error_to_gnu (Node_Id gnat_node, t
 	 one of which has the checks eliminated and the other has
 	 the original checks reinstated, and a run time selection.
 	 The former loop will be suitable for vectorization.  */
-	  if (flag_unswitch_loops
-	  && !vec_safe_is_empty (gnu_loop_stack)
+	  if (optimize
+	  && flag_unswitch_loops
+	  && inside_loop_p ()
 	  && (!gnu_low_bound
 		  || (gnu_low_bound = gnat_invariant_expr (gnu_low_bound)))
 	  && (!gnu_high_bound
 		  || (gnu_high_bound

C++ PATCH to use VECTOR_TYPE_P

2015-06-26 Thread Marek Polacek
This patch makes the C++ FE use VECTOR_TYPE_P where appropriate.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2015-06-26  Marek Polacek  

* call.c: Use VECTOR_TYPE_P.
* constexpr.c: Likewise.
* cvt.c: Likewise.
* decl.c: Likewise.
* decl2.c: Likewise.
* init.c: Likewise.
* semantics.c: Likewise.
* tree.c: Likewise.
* typeck.c: Likewise.
* typeck2.c: Likewise.

diff --git gcc/cp/call.c gcc/cp/call.c
index 0e8840b..cfb0de0 100644
--- gcc/cp/call.c
+++ gcc/cp/call.c
@@ -4559,8 +4559,8 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree 
arg2, tree arg3,
   arg2_type = TREE_TYPE (arg2);
   arg3_type = TREE_TYPE (arg3);
 
-  if (TREE_CODE (arg2_type) != VECTOR_TYPE
- && TREE_CODE (arg3_type) != VECTOR_TYPE)
+  if (!VECTOR_TYPE_P (arg2_type)
+ && !VECTOR_TYPE_P (arg3_type))
{
  /* Rely on the error messages of the scalar version.  */
  tree scal = build_conditional_expr_1 (loc, integer_one_node,
@@ -4612,8 +4612,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree 
arg2, tree arg3,
  arg3_type = vtype;
}
 
-  if ((TREE_CODE (arg2_type) == VECTOR_TYPE)
- != (TREE_CODE (arg3_type) == VECTOR_TYPE))
+  if (VECTOR_TYPE_P (arg2_type) != VECTOR_TYPE_P (arg3_type))
{
  enum stv_conv convert_flag =
scalar_to_vector (loc, VEC_COND_EXPR, arg2, arg3,
diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c
index 9cb45ea..a38c753 100644
--- gcc/cp/constexpr.c
+++ gcc/cp/constexpr.c
@@ -61,7 +61,7 @@ bool
 literal_type_p (tree t)
 {
   if (SCALAR_TYPE_P (t)
-  || TREE_CODE (t) == VECTOR_TYPE
+  || VECTOR_TYPE_P (t)
   || TREE_CODE (t) == REFERENCE_TYPE
   || (VOID_TYPE_P (t) && cxx_dialect >= cxx14))
 return true;
@@ -2101,7 +2101,7 @@ cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t,
   /* We're done building this CONSTRUCTOR, so now we can interpret an
  element without an explicit initializer as value-initialized.  */
   CONSTRUCTOR_NO_IMPLICIT_ZERO (t) = false;
-  if (TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE)
+  if (VECTOR_TYPE_P (TREE_TYPE (t)))
 t = fold (t);
   return t;
 }
@@ -2289,7 +2289,7 @@ cxx_fold_indirect_ref (location_t loc, tree type, tree 
op0, bool *empty_base)
   (type, TREE_TYPE (optype
return fold_build1_loc (loc, REALPART_EXPR, type, op);
   /* *(foo *)&vectorfoo => BIT_FIELD_REF */
-  else if (TREE_CODE (optype) == VECTOR_TYPE
+  else if (VECTOR_TYPE_P (optype)
   && (same_type_ignoring_top_level_qualifiers_p
   (type, TREE_TYPE (optype
{
@@ -2335,7 +2335,7 @@ cxx_fold_indirect_ref (location_t loc, tree type, tree 
op0, bool *empty_base)
  op00type = TREE_TYPE (op00);
 
  /* ((foo*)&vectorfoo)[1] => BIT_FIELD_REF */
- if (TREE_CODE (op00type) == VECTOR_TYPE
+ if (VECTOR_TYPE_P (op00type)
  && (same_type_ignoring_top_level_qualifiers_p
  (type, TREE_TYPE (op00type
{
diff --git gcc/cp/cvt.c gcc/cp/cvt.c
index d29c64b..a277678 100644
--- gcc/cp/cvt.c
+++ gcc/cp/cvt.c
@@ -708,7 +708,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags,
 conversion.  */
   else if (TREE_CODE (type) == COMPLEX_TYPE)
return fold_if_not_in_template (convert_to_complex (type, e));
-  else if (TREE_CODE (type) == VECTOR_TYPE)
+  else if (VECTOR_TYPE_P (type))
return fold_if_not_in_template (convert_to_vector (type, e));
   else if (TREE_CODE (e) == TARGET_EXPR)
{
diff --git gcc/cp/decl.c gcc/cp/decl.c
index 1fa28b2..bd544ef 100644
--- gcc/cp/decl.c
+++ gcc/cp/decl.c
@@ -5393,7 +5393,7 @@ reshape_init_vector (tree type, reshape_iter *d, 
tsubst_flags_t complain)
 {
   tree max_index = NULL_TREE;
 
-  gcc_assert (TREE_CODE (type) == VECTOR_TYPE);
+  gcc_assert (VECTOR_TYPE_P (type));
 
   if (COMPOUND_LITERAL_P (d->cur->value))
 {
@@ -5410,7 +5410,7 @@ reshape_init_vector (tree type, reshape_iter *d, 
tsubst_flags_t complain)
 }
 
   /* For a vector, we initialize it as an array of the appropriate size.  */
-  if (TREE_CODE (type) == VECTOR_TYPE)
+  if (VECTOR_TYPE_P (type))
 max_index = size_int (TYPE_VECTOR_SUBPARTS (type) - 1);
 
   return reshape_init_array_1 (TREE_TYPE (type), max_index, d, complain);
@@ -5718,7 +5718,7 @@ reshape_init_r (tree type, reshape_iter *d, bool 
first_initializer_p,
 return reshape_init_class (type, d, first_initializer_p, complain);
   else if (TREE_CODE (type) == ARRAY_TYPE)
 return reshape_init_array (type, d, complain);
-  else if (TREE_CODE (type) == VECTOR_TYPE)
+  else if (VECTOR_TYPE_P (type))
 return reshape_init_vector (type, d, complain);
   else
 gcc_unreachable();
@@ -5920,7 +5920,7 @@ check_initializer (tree decl, tree init, int flags, 
vec **cleanups)
   "not by %<{...}%>",
 

C++ PATCH to use VAR_P

2015-06-26 Thread Marek Polacek
Since Gaby's cleanup in 2013 many uses of TREE_CODE (decl) == VAR_DECL
have crept back in.  This is another cleanup in this area.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2015-06-26  Marek Polacek  

* call.c (set_up_extended_ref_temp): Use VAR_P.
* class.c: Use VAR_P throughout.
* constexpr.c (cxx_eval_constant_expression): Use VAR_P.
* cp-array-notation.c (make_triplet_val_inv): Likewise.
* decl.c: Use VAR_OR_FUNCTION_DECL_P or VAR_P
throughout.
* decl2.c: Likewise.
* error.c (dump_decl): Use VAR_P.
* mangle.c (decl_implicit_alias_p): Likewise.
* parser.c: Use VAR_P throughout.
* pt.c: Likewise.
* semantics.c: Likewise.
* vtable-class-hierarchy.c: Likewise.
* tree.c (handle_abi_tag_attribute): Use VAR_OR_FUNCTION_DECL_P.

diff --git gcc/cp/call.c gcc/cp/call.c
index 0e8840b..e5ed53b 100644
--- gcc/cp/call.c
+++ gcc/cp/call.c
@@ -9697,7 +9697,7 @@ set_up_extended_ref_temp (tree decl, tree expr, vec **cleanups,
 }
   /* Avoid -Wunused-variable warning (c++/38958).  */
   if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type)
-  && TREE_CODE (decl) == VAR_DECL)
+  && VAR_P (decl))
 TREE_USED (decl) = DECL_READ_P (decl) = true;
 
   *initp = init;
diff --git gcc/cp/class.c gcc/cp/class.c
index f4e4f85..6c7fa99 100644
--- gcc/cp/class.c
+++ gcc/cp/class.c
@@ -1399,7 +1399,7 @@ check_tag (tree tag, tree id, tree *tp, abi_tag_data *p)
   p->t, tag, *tp))
inform (location_of (*tp), "%qT declared here", *tp);
}
-  else if (TREE_CODE (p->t) == VAR_DECL)
+  else if (VAR_P (p->t))
{
  if (warning (OPT_Wabi_tag, "%qD inherits the %E ABI tag "
   "that %qT (used in its type) has", p->t, tag, *tp))
@@ -1588,7 +1588,7 @@ check_abi_tags (tree t, tree subob)
 void
 check_abi_tags (tree decl)
 {
-  if (TREE_CODE (decl) == VAR_DECL)
+  if (VAR_P (decl))
 check_abi_tags (decl, TREE_TYPE (decl));
   else if (TREE_CODE (decl) == FUNCTION_DECL
   && !mangle_return_type_p (decl))
@@ -3040,7 +3040,7 @@ finish_struct_anon_r (tree field, bool complain)
{
  /* We already complained about static data members in
 finish_static_data_member_decl.  */
- if (complain && TREE_CODE (elt) != VAR_DECL)
+ if (complain && !VAR_P (elt))
{
  if (is_union)
permerror (input_location,
diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c
index 9cb45ea..4fce5e0 100644
--- gcc/cp/constexpr.c
+++ gcc/cp/constexpr.c
@@ -3033,7 +3033,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, 
tree t,
   if (TREE_CODE (r) == TARGET_EXPR
  && TREE_CODE (TARGET_EXPR_INITIAL (r)) == CONSTRUCTOR)
r = TARGET_EXPR_INITIAL (r);
-  if (TREE_CODE (r) == VAR_DECL)
+  if (VAR_P (r))
if (tree *p = ctx->values->get (r))
  r = *p;
   if (DECL_P (r))
diff --git gcc/cp/cp-array-notation.c gcc/cp/cp-array-notation.c
index 3b8610f..4daa57c 100644
--- gcc/cp/cp-array-notation.c
+++ gcc/cp/cp-array-notation.c
@@ -87,7 +87,7 @@ make_triplet_val_inv (tree *value)
 {
   if (TREE_CODE (*value) != INTEGER_CST
   && TREE_CODE (*value) != PARM_DECL
-  && TREE_CODE (*value) != VAR_DECL)
+  && !VAR_P (*value))
 *value = get_temp_regvar (ptrdiff_type_node, *value);
 }
 
diff --git gcc/cp/decl.c gcc/cp/decl.c
index 1fa28b2..9594223 100644
--- gcc/cp/decl.c
+++ gcc/cp/decl.c
@@ -2476,14 +2476,15 @@ duplicate_decls (tree newdecl, tree olddecl, bool 
newdecl_is_friend)
  {
 struct symtab_node *snode = NULL;
 
-if (TREE_CODE (newdecl) == VAR_DECL
-   && (TREE_STATIC (olddecl) || TREE_PUBLIC (olddecl) || 
DECL_EXTERNAL (olddecl)))
+   if (VAR_P (newdecl)
+   && (TREE_STATIC (olddecl) || TREE_PUBLIC (olddecl)
+   || DECL_EXTERNAL (olddecl)))
  snode = symtab_node::get (olddecl);
memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
(char *) newdecl + sizeof (struct tree_decl_common),
size - sizeof (struct tree_decl_common)
+ TREE_CODE_LENGTH (TREE_CODE (newdecl)) * sizeof (char *));
-if (TREE_CODE (newdecl) == VAR_DECL)
+   if (VAR_P (newdecl))
  olddecl->decl_with_vis.symtab_node = snode;
  }
  break;
@@ -2496,8 +2497,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool 
newdecl_is_friend)
}
 }
 
-  if (TREE_CODE (newdecl) == FUNCTION_DECL
-  || TREE_CODE (newdecl) == VAR_DECL)
+  if (VAR_OR_FUNCTION_DECL_P (newdecl))
 {
   if (DECL_EXTERNAL (olddecl)
  || TREE_PUBLIC (olddecl)
@@ -2522,7 +2522,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool 
newdecl_is_friend)
}
}
 
-  if (TREE_CODE (newdecl) == VAR_DECL
+  if (VAR_P (newdecl)
  && DEC

Re: Add .def file for public target instructions

2015-06-26 Thread Richard Sandiford
Richard Sandiford  writes:
> Markus Trippelsdorf  writes:
>> On 2015.06.23 at 19:41 +0100, Richard Sandiford wrote:
>>> 
>>> gcc/
>>> * Makefile.in (TARGET_DEF): Add target-insns.def.
>>> (.PRECIOUS, simple_rtl_generated_h): Add insn-target-def.h.
>>> (build/gentarget-def.o): New rule.
>>> (genprogrtl): Add target-def.
>>> * target-insns.def, gentarget-def.c: New files.
>>> * target.def: Add targetm.have_* and targetm.gen_* hooks,
>>> based on the contents of target-insns.def.
>>> * defaults.h (HAVE_simple_return, gen_simple_return): Delete.
>>> (HAVE_return, gen_return): Delete.
>>> * target-def.h: Include insn-target-def.h.
>>> * cfgrtl.c (force_nonfallthru_and_redirect): Use targetm interface
>>> instead of direct calls.  Rely on them to do the appropriate assertions.
>>> * function.c (gen_return_pattern): Likewise.  Return an rtx_insn *.
>>> (convert_jumps_to_returns): Use targetm interface instead of
>>> direct calls.
>>> (thread_prologue_and_epilogue_insns): Likewise.
>>> * reorg.c (find_end_label, dbr_schedule): Likewise.
>>> * shrink-wrap.h (SHRINK_WRAPPING_ENABLED): Likewise.
>>> * shrink-wrap.c (convert_to_simple_return): Likewise.
>>> (try_shrink_wrapping): Use SHRINK_WRAPPING_ENABLED.
>>
>> The patch breaks bootstrap on ppc64le. During libgcc configuration:
>
> Yeah, sorry about that.  The problem is due to confusion about whether
> the generator should emit a barrier or not.  After the final instruction
> in a sequence, it should always be up to the caller to insert any
> necessary barriers, just like it is for define_insns, and for define_expands
> implemented in C++ with DONE.
>
> I'm testing the following patch.

Committed after bootstrapping & regression-testing on x86_64-linux-gnu
and testing that Anton's testcase worked on ppc64le.  (The emit-rtl.c
part seemed obvious given the generator changes.)

Sorry again for the breakage.

Thanks,
Richard

> gcc/
>   * rtl.h (emit): Add an optional boolean parameter to control
>   whether barriers are emitted.
>   * emit-rtl.c (emit): Likewise.
>   * gensupport.c (get_emit_function): Return null rather than "emit".
>   * genemit.c (gen_emit_seq): Handle the null return value.
>   Don't emit barriers after the final instruction in the sequence.
>   * gentarget-def.c (main): Don't emit barriers after the instruction.
>
> Index: gcc/rtl.h
> ===
> --- gcc/rtl.h 2015-06-26 09:09:10.128602409 +0100
> +++ gcc/rtl.h 2015-06-26 09:09:10.316600233 +0100
> @@ -3494,7 +3494,7 @@ extern void add_insn (rtx_insn *);
>  extern void add_insn_before (rtx, rtx, basic_block);
>  extern void add_insn_after (rtx, rtx, basic_block);
>  extern void remove_insn (rtx);
> -extern rtx_insn *emit (rtx);
> +extern rtx_insn *emit (rtx, bool = true);
>  extern void emit_insn_at_entry (rtx);
>  extern rtx gen_lowpart_SUBREG (machine_mode, rtx);
>  extern rtx gen_const_mem (machine_mode, rtx);
> Index: gcc/emit-rtl.c
> ===
> --- gcc/emit-rtl.c2015-06-26 09:09:10.124602455 +0100
> +++ gcc/emit-rtl.c2015-06-26 09:09:10.316600233 +0100
> @@ -5303,11 +5303,14 @@ set_dst_reg_note (rtx insn, enum reg_not
>return NULL_RTX;
>  }
>  
> -/* Emit the rtl pattern X as an appropriate kind of insn.
> +/* Emit the rtl pattern X as an appropriate kind of insn.  Also emit a
> +   following barrier if the instruction needs one and if ALLOW_BARRIER_P
> +   is true.
> +
> If X is a label, it is simply added into the insn chain.  */
>  
>  rtx_insn *
> -emit (rtx x)
> +emit (rtx x, bool allow_barrier_p)
>  {
>enum rtx_code code = classify_insn (x);
>  
> @@ -5320,7 +5323,8 @@ emit (rtx x)
>  case  JUMP_INSN:
>{
>   rtx_insn *insn = emit_jump_insn (x);
> - if (any_uncondjump_p (insn) || GET_CODE (x) == RETURN)
> + if (allow_barrier_p
> + && (any_uncondjump_p (insn) || GET_CODE (x) == RETURN))
> return emit_barrier ();
>   return insn;
>}
> Index: gcc/gensupport.c
> ===
> --- gcc/gensupport.c  2015-06-26 09:09:10.124602455 +0100
> +++ gcc/gensupport.c  2015-06-26 09:09:10.316600233 +0100
> @@ -2983,7 +2983,9 @@ get_pattern_stats (struct pattern_stats
>  stats->max_scratch_opno)) + 1;
>  }
>  
> -/* Return the emit_* function that should be used for pattern X.  */
> +/* Return the emit_* function that should be used for pattern X, or NULL
> +   if we can't pick a particular type at compile time and should instead
> +   fall back to "emit".  */
>  
>  const char *
>  get_emit_function (rtx x)
> @@ -3000,7 +3002,7 @@ get_emit_function (rtx x)
>return "emit_jump_insn";
>  
>  case UNKNOWN:
> -  return "emit";
> +  return NULL;
>  
>  default:
>gcc_unreachable ();
> Index: gcc

Re: [PATCH, ARM] Restrict pr65647 testcase to ARMv6-M effective target

2015-06-26 Thread James Greenhalgh
On Fri, Jun 26, 2015 at 09:50:33AM +0100, Richard Earnshaw wrote:
> On 26/06/15 09:45, Thomas Preud'homme wrote:
> > Hi,
> > 
> > Testcase for PR65647 assumes that the compiler can compile for ARMv6-M
> > which might not be the case if passing some extra options via
> > RUNTESTFLAGS (eg. -marm/-mcpu=cortex-a9). This patch restricts the
> > testcase to ARMv6-M effective targets.
> > 
> > 
> > Testsuite ChangeLog entry is as follows:
> > 
> > 2015-06-25  Thomas Preud'homme  
> > 
> > * gcc.target/arm/pr65647.c: Restrict to ARMv6-M effective targets.
> > 
> > 
> > diff --git a/gcc/testsuite/gcc.target/arm/pr65647.c 
> > b/gcc/testsuite/gcc.target/arm/pr65647.c
> > index d3b44b2..d828d23 100644
> > --- a/gcc/testsuite/gcc.target/arm/pr65647.c
> > +++ b/gcc/testsuite/gcc.target/arm/pr65647.c
> > @@ -1,4 +1,5 @@
> >  /* { dg-do compile } */
> > +/* { dg-require-effective-target arm_arch_v6m_ok } */
> >  /* { dg-options "-march=armv6-m -mthumb -O3 -w -mfloat-abi=soft" } */
> >  
> >  a, b, c, e, g = &e, h, i = 7, l = 1, m, n, o, q = &m, r, s = &r, u, w = 9, 
> > x,
> > 
> > 
> > Patch was tested by running the testcase once with -mcpu=cortex-a9
> > (skipped as expected) and once with -mcpu=cortex-m0 (passes).
> > 
> > Is this ok for trunk?
> > 
> 
> OK.

This should already have been covered by:

  https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01105.html

2015-06-16  James Greenhalgh  

* gcc.target/arm/pr65647.c: Do not override -mfloat-abi directives
passed by the testsuite driver.

Thanks,
James

---
diff --git a/gcc/testsuite/gcc.target/arm/pr65647.c 
b/gcc/testsuite/gcc.target/arm/pr65647.c
index d3b44b2..26b4e39 100644
--- a/gcc/testsuite/gcc.target/arm/pr65647.c
+++ b/gcc/testsuite/gcc.target/arm/pr65647.c
@@ -1,4 +1,6 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target arm_arch_v6m_ok } */
+/* { dg-skip-if "do not override -mfloat-abi" { *-*-* } { "-mfloat-abi=*" } 
{"-mfloat-abi=soft" } } */
 /* { dg-options "-march=armv6-m -mthumb -O3 -w -mfloat-abi=soft" } */
 
 a, b, c, e, g = &e, h, i = 7, l = 1, m, n, o, q = &m, r, s = &r, u, w = 9, x,

> > Best regards,
> > 
> > Thomas
> > 
> > 
> 


[Ada] Housekeeping work in gigi

2015-06-26 Thread Eric Botcazou
Mainly for the set of create_* functions in utils.c.

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


2015-06-26  Eric Botcazou  

* gcc-interface/gigi.h (create_var_decl_1): Rename into...
(create_var_decl): ...this.  Add default value for last parameter.
(create_type_stub_decl): Adjust.
(create_type_decl): Likewise.
(create_field_decl): Likewise.
(create_param_decl): Likewise.
(create_label_decl): Likewise.
(create_subprog_decl): Likewise.
* gcc-interface/utils.c (create_var_decl_1): Rename into...
(create_var_decl): ...this.  Rename var_name into name and var_init
into init, move const_decl_allowed_p last and adjust accordingly.
(create_type_stub_decl): Rename type_name into name and adjust.
(create_type_decl): Likewise.
(create_field_decl): Likewise for field_name and field_type.
(create_param_decl): Likewise for param_name and param_type.
(create_label_decl): Likewise for label_name.
(create_subprog_decl): Likewise for subprog_name and subprog_type.
* gcc-interface/decl.c (gnat_to_gnu_entity): Adjust couple of calls
to create_var_decl_1.


-- 
Eric BotcazouIndex: gcc-interface/utils.c
===
--- gcc-interface/utils.c	(revision 224993)
+++ gcc-interface/utils.c	(working copy)
@@ -2238,31 +2238,31 @@ create_range_type (tree type, tree min,
   return range_type;
 }
 
-/* Return a TYPE_DECL node suitable for the TYPE_STUB_DECL field of a type.
-   TYPE_NAME gives the name of the type and TYPE is a ..._TYPE node giving
-   its data type.  */
+/* Return a TYPE_DECL node suitable for the TYPE_STUB_DECL field of TYPE.
+   NAME gives the name of the type to be used in the declaration.  */
 
 tree
-create_type_stub_decl (tree type_name, tree type)
+create_type_stub_decl (tree name, tree type)
 {
-  tree type_decl = build_decl (input_location, TYPE_DECL, type_name, type);
+  tree type_decl = build_decl (input_location, TYPE_DECL, name, type);
   DECL_ARTIFICIAL (type_decl) = 1;
   TYPE_ARTIFICIAL (type) = 1;
   return type_decl;
 }
 
-/* Return a TYPE_DECL node.  TYPE_NAME gives the name of the type and TYPE
-   is a ..._TYPE node giving its data type.  ARTIFICIAL_P is true if the
-   declaration was generated by the compiler.  DEBUG_INFO_P is true if we
-   need to write debug information about this type.  GNAT_NODE is used for
-   the position of the decl.  */
+/* Return a TYPE_DECL node for TYPE.  NAME gives the name of the type to be
+   used in the declaration.  ARTIFICIAL_P is true if the declaration was
+   generated by the compiler.  DEBUG_INFO_P is true if we need to write
+   debug information about this type.  GNAT_NODE is used for the position
+   of the decl.  */
 
 tree
-create_type_decl (tree type_name, tree type, bool artificial_p,
-		  bool debug_info_p, Node_Id gnat_node)
+create_type_decl (tree name, tree type, bool artificial_p, bool debug_info_p,
+		  Node_Id gnat_node)
 {
   enum tree_code code = TREE_CODE (type);
-  bool named = TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL;
+  bool is_named
+= TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL;
   tree type_decl;
 
   /* Only the builtin TYPE_STUB_DECL should be used for dummy types.  */
@@ -2270,13 +2270,13 @@ create_type_decl (tree type_name, tree t
 
   /* If the type hasn't been named yet, we're naming it; preserve an existing
  TYPE_STUB_DECL that has been attached to it for some purpose.  */
-  if (!named && TYPE_STUB_DECL (type))
+  if (!is_named && TYPE_STUB_DECL (type))
 {
   type_decl = TYPE_STUB_DECL (type);
-  DECL_NAME (type_decl) = type_name;
+  DECL_NAME (type_decl) = name;
 }
   else
-type_decl = build_decl (input_location, TYPE_DECL, type_name, type);
+type_decl = build_decl (input_location, TYPE_DECL, name, type);
 
   DECL_ARTIFICIAL (type_decl) = artificial_p;
   TYPE_ARTIFICIAL (type) = artificial_p;
@@ -2293,7 +2293,7 @@ create_type_decl (tree type_name, tree t
  from multiple contexts, and "type_decl" references a copy of it: in such a
  case, do not mess TYPE_STUB_DECL: we do not want to re-use the TYPE_DECL
  with the mechanism above.  */
-  if (!named && type != DECL_ORIGINAL_TYPE (type_decl))
+  if (!is_named && type != DECL_ORIGINAL_TYPE (type_decl))
 TYPE_STUB_DECL (type) = type_decl;
 
   /* Do not generate debug info for UNCONSTRAINED_ARRAY_TYPE that the
@@ -2306,8 +2306,8 @@ create_type_decl (tree type_name, tree t
 
 /* Return a VAR_DECL or CONST_DECL node.
 
-   VAR_NAME gives the name of the variable.  ASM_NAME is its assembler name
-   (if provided).  TYPE is its data type (a GCC ..._TYPE node).  VAR_INIT is
+   NAME gives the name of the variable.  ASM_NAME is its assembler name
+   (if provided).  TYPE is its data type (a GCC ..._TYPE node).  INIT is
the GCC tree for an optional initial expression; NU

[Ada] Defer compilation of global variables

2015-06-26 Thread Eric Botcazou
In gigi we defer the generation of debug info for global types, so we need 
to arrange to emit (again) the debug info for global variables after that, 
otherwise the debug info can be incorrect.


2015-06-26  Eric Botcazou  

* gcc-interface/gigi.h (note_types_used_by_globals): Delete.
(gnat_write_global_declarations): New prototype.
* gcc-interface/utils.c (type_decls): Rename back to...
(global_decls): ...this.
(gnat_pushdecls): Revert previous change.
(create_var_decl): Do not output global variables.
(note_types_used_by_globals): Rename back to...
(gnat_write_global_declarations): ...this.  Output variables on the
global_decls vector.
* gcc-interface/misc.c (gnat_parse_file): Adjust to above renaming.


-- 
Eric BotcazouIndex: gcc-interface/utils.c
===
--- gcc-interface/utils.c	(revision 225002)
+++ gcc-interface/utils.c	(working copy)
@@ -218,8 +218,8 @@ static GTY((deletable)) struct gnat_bind
 /* The context to be used for global declarations.  */
 static GTY(()) tree global_context;
 
-/* An array of global type declarations.  */
-static GTY(()) vec *type_decls;
+/* An array of global declarations.  */
+static GTY(()) vec *global_decls;
 
 /* An array of builtin function declarations.  */
 static GTY(()) vec *builtin_decls;
@@ -753,10 +753,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_n
 	vec_safe_push (builtin_decls, decl);
 	}
   else if (global_bindings_p ())
-	{
-	  if (TREE_CODE (decl) == TYPE_DECL)
-	vec_safe_push (type_decls, decl);
-	}
+	vec_safe_push (global_decls, decl);
   else
 	{
 	  DECL_CHAIN (decl) = BLOCK_VARS (current_binding_level->block);
@@ -2439,19 +2436,13 @@ create_var_decl (tree name, tree asm_nam
   /* Add this decl to the current binding level.  */
   gnat_pushdecl (var_decl, gnat_node);
 
-  if (TREE_CODE (var_decl) == VAR_DECL)
+  if (TREE_CODE (var_decl) == VAR_DECL && asm_name)
 {
-  if (asm_name)
-	{
-	  /* Let the target mangle the name if this isn't a verbatim asm.  */
-	  if (*IDENTIFIER_POINTER (asm_name) != '*')
-	asm_name = targetm.mangle_decl_assembler_name (var_decl, asm_name);
-
-	  SET_DECL_ASSEMBLER_NAME (var_decl, asm_name);
-	}
+  /* Let the target mangle the name if this isn't a verbatim asm.  */
+  if (*IDENTIFIER_POINTER (asm_name) != '*')
+	asm_name = targetm.mangle_decl_assembler_name (var_decl, asm_name);
 
-  if (global_bindings_p ())
-	rest_of_decl_compilation (var_decl, true, 0);
+  SET_DECL_ASSEMBLER_NAME (var_decl, asm_name);
 }
 
   return var_decl;
@@ -5200,13 +5191,12 @@ smaller_form_type_p (tree type, tree ori
   return tree_int_cst_lt (size, osize) != 0;
 }
 
-/* Keep track of types used at the global level and emit debug info
-   for all global types.  */
+/* Perform final processing on global declarations.  */
 
 static GTY (()) tree dummy_global;
 
 void
-note_types_used_by_globals (void)
+gnat_write_global_declarations (void)
 {
   unsigned int i;
   tree iter;
@@ -5235,13 +5225,20 @@ note_types_used_by_globals (void)
 	}
 }
 
-  /* Output debug information for all global type declarations.  This ensures
- that global types whose compilation cannot been finalized earlier, e.g.
- pointers to Taft amendment types, have their compilation finalized in
- the right context.  */
-  FOR_EACH_VEC_SAFE_ELT (type_decls, i, iter)
-if (!DECL_IGNORED_P (iter))
+  /* Output debug information for all global type declarations first.  This
+ ensures that global types whose compilation hasn't been finalized yet,
+ for example pointers to Taft amendment types, have their compilation
+ finalized in the right context.  */
+  FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
+if (TREE_CODE (iter) == TYPE_DECL && !DECL_IGNORED_P (iter))
   debug_hooks->type_decl (iter, false);
+
+  /* Then output the global variables.  We need to do that after the debug
+ information is emitted above so that "forward" type declarations are
+ properly merged with their definition in the debug information.  */
+  FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
+if (TREE_CODE (iter) == VAR_DECL)
+  rest_of_decl_compilation (iter, true, 0);
 }
 
 /* 
Index: gcc-interface/gigi.h
===
--- gcc-interface/gigi.h	(revision 225002)
+++ gcc-interface/gigi.h	(working copy)
@@ -531,9 +531,8 @@ extern tree gnat_type_for_size (unsigned
an unsigned type; otherwise a signed type is returned.  */
 extern tree gnat_type_for_mode (machine_mode mode, int unsignedp);
 
-/* Keep track of types used at the global level and emit debug info
-   for all global types.  */
-extern void note_types_used_by_globals (void);
+/* Perform final processing on global declarations.  */
+extern void gnat_write_global_declarations (void);
 
 /*

Re: [i386, PATCH, 1/3] IA MCU psABI support: GCC changes.

2015-06-26 Thread Uros Bizjak
On Mon, Jun 22, 2015 at 4:36 PM, Kirill Yukhin  wrote:
> Hello,
> This patch introduces basic support into GCC.
>
> Bootstrapped and regtested.
>
> /
> * configure.ac (ospace_frag): Enable for i?86*-*-elfiamcu
> target.
> * configure: Regenerate.
> gcc/
> * config.gcc: Support i[34567]86-*-elfiamcu target.
> * config/i386/iamcu.h: New.
> * config/i386/i386.opt: Add -miamcu.
> * doc/invoke.texi: Document -miamcu.
> * common/config/i386/i386-common.c  (ix86_handle_option): Turn
> off x87/MMX/SSE/AVX codegen for -miamcu.
> * config/i386/i386-c.c (ix86_target_macros_internal): Define
> __iamcu/__iamcu__ for -miamcu.
> * config/i386/i386.h (PREFERRED_STACK_BOUNDARY_DEFAULT): Set
> to MIN_STACK_BOUNDARY if TARGET_IAMCU is true.
> (BIGGEST_ALIGNMENT): Set to 32 if TARGET_IAMCU is true.
> * config/i386/i386.c (ix86_option_override_internal):
>   - Ignore and warn -mregparm for Intel MCU. Turn
> on -mregparm=3 for Intel MCU by default.
>   - Default long double to 64-bit for Intel MCU.
>   - Turn on -freg-struct-return for Intel MCU.
>   - Issue an error when -miamcu is used in 64-bit or x32 mode,
> or if x87, MMX, SSE or AVX is turned on.

Please avoid lines here. Just go with the sentences one after another,
separated with two spaces.

> (function_arg_advance_32): Pass value whose
> size is no larger than 8 bytes in registers for Intel MCU.
> (function_arg_32): Likewise.
> (ix86_return_in_memory): Return value whose size is no larger
> than 8 bytes in registers for Intel MCU.
> (iamcu_alignment): New function.
> (ix86_data_alignment): Call iamcu_alignment if TARGET_IAMCU is
> true.
> (ix86_local_alignment): Don't increase
> alignment for Intel MCU.
> (x86_field_alignment): Return iamcu_alignment if TARGET_IAMCU is
> true.
>
> Is it OK for trunk?

OK.

Thanks,
Uros.

>
> --
> Thanks, K
>
> diff --git a/configure b/configure
> index bced9de..82e45f3 100755
> --- a/configure
> +++ b/configure
> @@ -6914,7 +6914,7 @@ case "${enable_target_optspace}:${target}" in
>:d30v-*)
>  ospace_frag="config/mt-d30v"
>  ;;
> -  :m32r-* | :d10v-* | :fr30-*)
> +  :m32r-* | :d10v-* | :fr30-* | :i?86*-*-elfiamcu)
>  ospace_frag="config/mt-ospace"
>  ;;
>no:* | :*)
> diff --git a/configure.ac b/configure.ac
> index 7c06e6b..dc77a1b 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -2560,7 +2560,7 @@ case "${enable_target_optspace}:${target}" in
>:d30v-*)
>  ospace_frag="config/mt-d30v"
>  ;;
> -  :m32r-* | :d10v-* | :fr30-*)
> +  :m32r-* | :d10v-* | :fr30-* | :i?86*-*-elfiamcu)
>  ospace_frag="config/mt-ospace"
>  ;;
>no:* | :*)
> diff --git a/gcc/common/config/i386/i386-common.c 
> b/gcc/common/config/i386/i386-common.c
> index 0f8c3e1..79b2472 100644
> --- a/gcc/common/config/i386/i386-common.c
> +++ b/gcc/common/config/i386/i386-common.c
> @@ -223,7 +223,7 @@ along with GCC; see the file COPYING3.  If not see
>
>  bool
>  ix86_handle_option (struct gcc_options *opts,
> -   struct gcc_options *opts_set ATTRIBUTE_UNUSED,
> +   struct gcc_options *opts_set,
> const struct cl_decoded_option *decoded,
> location_t loc)
>  {
> @@ -232,6 +232,20 @@ ix86_handle_option (struct gcc_options *opts,
>
>switch (code)
>  {
> +case OPT_miamcu:
> +  if (value)
> +   {
> + /* Turn off x87/MMX/SSE/AVX codegen for -miamcu.  */
> + opts->x_target_flags &= ~MASK_80387;
> + opts_set->x_target_flags |= MASK_80387;
> + opts->x_ix86_isa_flags &= ~(OPTION_MASK_ISA_MMX_UNSET
> + | OPTION_MASK_ISA_SSE_UNSET);
> + opts->x_ix86_isa_flags_explicit |= (OPTION_MASK_ISA_MMX_UNSET
> + | OPTION_MASK_ISA_SSE_UNSET);
> +
> +   }
> +  return true;
> +
>  case OPT_mmmx:
>if (value)
> {
> diff --git a/gcc/config.gcc b/gcc/config.gcc
> index 805638d..2b3af82 100644
> --- a/gcc/config.gcc
> +++ b/gcc/config.gcc
> @@ -1389,6 +1389,9 @@ x86_64-*-darwin*)
> tmake_file="${tmake_file} ${cpu_type}/t-darwin64 t-slibgcc"
> tm_file="${tm_file} ${cpu_type}/darwin64.h"
> ;;
> +i[34567]86-*-elfiamcu)
> +   tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h 
> newlib-stdint.h i386/iamcu.h"
> +   ;;
>  i[34567]86-*-elf*)
> tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h 
> newlib-stdint.h i386/i386elf.h"
> ;;
> diff --git a/gcc/config/i386/i386-c.c b/gcc/config/i386/i386-c.c
> index 0228f4b..66f7e37 100644
> --- a/gcc/config/i386/i386-c.c
> +++ b/gcc/config/i386/i386-c.c
> @@ -426,6 +426,11 @@ ix86_target_macros_internal (HOST_WIDE_INT isa_flag,
>  def_or_undef (pa

[patch] Fix PR middle-end/66633

2015-06-26 Thread Eric Botcazou
Hi,

this is a regression present on the mainline and 5 branch.  For the attached 
Fortran testcase, the GIMPLE verifier stops the compiler on an error mark 
inserted by omp-low.c:omp_copy_decl for a FRAME variable created during the 
nested function lowering pass because it is not marked as shared since it is 
created too late (it is created at the end of the pass when optimization is 
disabled after the change for PR debug/53927).

Fixed by teaching convert_local_omp_clauses about this case, tested on x86_64-
suse-linux, OK for the mainline and 5 branch?


2015-06-26  Eric Botcazou  

PR middle-end/66633
* tree-nested.c (convert_local_omp_clauses): Initialize need_frame to
true if not optimizing.


2015-06-26  Eric Botcazou  

* gfortran.dg/pr66633.f90: New test.


-- 
Eric BotcazouIndex: tree-nested.c
===
--- tree-nested.c	(revision 224993)
+++ tree-nested.c	(working copy)
@@ -1697,7 +1697,9 @@ static bool
 convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi)
 {
   struct nesting_info *const info = (struct nesting_info *) wi->info;
-  bool need_frame = false, need_stmts = false;
+  /* If not optimizing, we will force the creation of the FRAME object in
+ convert_all_function_calls, so we need to take it into account here.  */
+  bool need_frame = !optimize, need_stmts = false;
   tree clause, decl;
   int dummy;
   bitmap new_suppress;
! PR middle-end/66633
! Testcase by Andrew Benson 

! { dg-do compile }
! { dg-options "-fopenmp" }
! { dg-require-effective-target fopenmp }

module spls
contains
  function spl()
!$omp parallel
write (0,*) igrt(fli)
!$omp end parallel
  contains
double precision function fli()
end function fli
  end function spl
end module spls


RE: [PATCH, ARM] Restrict pr65647 testcase to ARMv6-M effective target

2015-06-26 Thread Thomas Preud'homme
> From: James Greenhalgh [mailto:james.greenha...@arm.com]
> Sent: Friday, June 26, 2015 6:15 PM
> 
> This should already have been covered by:
> 
>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01105.html
> 
>   2015-06-16  James Greenhalgh  
> 
>   * gcc.target/arm/pr65647.c: Do not override -mfloat-abi
> directives
>   passed by the testsuite driver.

Indeed, time to git pull. Sorry for the noise :-(

Best regards,

Thomas




Re: [patch] Fix PR middle-end/66633

2015-06-26 Thread Jakub Jelinek
On Fri, Jun 26, 2015 at 12:38:48PM +0200, Eric Botcazou wrote:
> this is a regression present on the mainline and 5 branch.  For the attached 
> Fortran testcase, the GIMPLE verifier stops the compiler on an error mark 
> inserted by omp-low.c:omp_copy_decl for a FRAME variable created during the 
> nested function lowering pass because it is not marked as shared since it is 
> created too late (it is created at the end of the pass when optimization is 
> disabled after the change for PR debug/53927).
> 
> Fixed by teaching convert_local_omp_clauses about this case, tested on x86_64-
> suse-linux, OK for the mainline and 5 branch?

Don't you need to handle convert_nonlocal_omp_clauses similarly (need_chain
in that case)?
At least looking at your r211308 commit, for !optimize you force not just
the frame, but also chain.

> 2015-06-26  Eric Botcazou  
> 
>   * gfortran.dg/pr66633.f90: New test.

The test should go into gfortran.dg/gomp/, without the
! { dg-require-effective-target fopenmp }
line.

Thanks for working on this.

Jakub


Re: [i386, PATCH, 2/3] IA MCU psABI support: changes to libraries.

2015-06-26 Thread Uros Bizjak
On Mon, Jun 22, 2015 at 5:39 PM, Kirill Yukhin  wrote:
> Hello,
> Patch in the bottom adds support of IA MCU psABI to libgcc
> (enables soft-fp) and libdecnumber (enables it for IA MCU).
>
> Bootstrapped and regtested on top of [1/3] patch.
>
> config/
> * dfp.m4 (enable_decimal_float): Also set to yes for
>  i?86*-*-elfiamcu target.
> gcc/
> * configure: Regenerated.
> libdecnumber/
> * configure: Regenerated.
> libgcc/
> * config.host: Support i[34567]86-*-elfiamcu target.
> * config/i386/32/t-iamcu: New file.
> * configure: Regenerated.
>
> Is it OK for trunk?

Please introduce config/t-softfp-sfdftf as an union of t-softfp-sfdf
and t-softfp-tf and use it instead of config/t-softfp-sfdf. You will
be able to remove all softfp stuff from t-iamcu then.

OK with the above improvement.

Thanks,
Uros.

> --
> Thanks, K
>
> diff --git a/config/dfp.m4 b/config/dfp.m4
> index 48683f0..5b29089 100644
> --- a/config/dfp.m4
> +++ b/config/dfp.m4
> @@ -21,7 +21,7 @@ Valid choices are 'yes', 'bid', 'dpd', and 'no'.]) ;;
>  [
>case $1 in
>  powerpc*-*-linux* | i?86*-*-linux* | x86_64*-*-linux* | s390*-*-linux* | 
> \
> -i?86*-*-gnu* | \
> +i?86*-*-elfiamcu | i?86*-*-gnu* | \
>  i?86*-*-mingw* | x86_64*-*-mingw* | \
>  i?86*-*-cygwin* | x86_64*-*-cygwin*)
>enable_decimal_float=yes
> diff --git a/gcc/configure b/gcc/configure
> index b26a86f..64eeac6 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -7317,7 +7317,7 @@ else
>
>case $target in
>  powerpc*-*-linux* | i?86*-*-linux* | x86_64*-*-linux* | s390*-*-linux* | 
> \
> -i?86*-*-gnu* | \
> +i?86*-*-elfiamcu | i?86*-*-gnu* | \
>  i?86*-*-mingw* | x86_64*-*-mingw* | \
>  i?86*-*-cygwin* | x86_64*-*-cygwin*)
>enable_decimal_float=yes
> diff --git a/libdecnumber/configure b/libdecnumber/configure
> index 2720f46..964837d 100755
> --- a/libdecnumber/configure
> +++ b/libdecnumber/configure
> @@ -4614,7 +4614,7 @@ else
>
>case $target in
>  powerpc*-*-linux* | i?86*-*-linux* | x86_64*-*-linux* | s390*-*-linux* | 
> \
> -i?86*-*-gnu* | \
> +i?86*-*-elfiamcu | i?86*-*-gnu* | \
>  i?86*-*-mingw* | x86_64*-*-mingw* | \
>  i?86*-*-cygwin* | x86_64*-*-cygwin*)
>enable_decimal_float=yes
> diff --git a/libgcc/config.host b/libgcc/config.host
> index 4df..dd8e356 100644
> --- a/libgcc/config.host
> +++ b/libgcc/config.host
> @@ -562,6 +562,9 @@ x86_64-*-darwin*)
> tm_file="$tm_file i386/darwin-lib.h"
> extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o 
> crtfastmath.o"
> ;;
> +i[34567]86-*-elfiamcu)
> +   tmake_file="$tmake_file i386/t-crtstuff t-softfp-sfdf 
> i386/32/t-softfp i386/32/t-iamcu i386/t-softfp t-softfp t-dfprules"
> +   ;;
>  i[34567]86-*-elf*)
> tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
> ;;
> diff --git a/libgcc/config/i386/32/t-iamcu b/libgcc/config/i386/32/t-iamcu
> new file mode 100644
> index 000..0752bff
> --- /dev/null
> +++ b/libgcc/config/i386/32/t-iamcu
> @@ -0,0 +1,6 @@
> +softfp_float_modes += tf
> +softfp_extensions += sftf dftf xftf
> +softfp_truncations += tfsf tfdf tfxf
> +softfp_exclude_libgcc2 := n
> +
> +HOST_LIBGCC2_CFLAGS += -mlong-double-80
> diff --git a/libgcc/configure b/libgcc/configure
> index ce66d1d..e22cbcb 100644
> --- a/libgcc/configure
> +++ b/libgcc/configure
> @@ -4436,7 +4436,7 @@ else
>
>case $host in
>  powerpc*-*-linux* | i?86*-*-linux* | x86_64*-*-linux* | s390*-*-linux* | 
> \
> -i?86*-*-gnu* | \
> +i?86*-*-elfiamcu | i?86*-*-gnu* | \
>  i?86*-*-mingw* | x86_64*-*-mingw* | \
>  i?86*-*-cygwin* | x86_64*-*-cygwin*)
>enable_decimal_float=yes
>
>
>


[PATCH][5/n] Remove GENERIC stmt combining from SCCVN

2015-06-26 Thread Richard Biener

This moves some equality comparison patterns from fold-const.c to 
match.pd.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2015-06-26  Richard Biener  

* fold-const.c (fold_binary_loc): Remove -A CMP -B -> A CMP B
and -A CMP CST -> A CMP -CST which is redundant with a pattern
in match.pd.
Move (A | C) == D where C & ~D != 0 -> 0, (X ^ Y) ==/!= 0 -> X ==/!= Y,
(X ^ Y) ==/!= {Y,X} -> {X,Y} ==/!= 0 and
(X ^ C1) op C2 -> X op (C1 ^ C2) to ...
* match.pd: ... patterns here.

* gcc.dg/tree-ssa/forwprop-25.c: Adjust.

Index: gcc/fold-const.c
===
*** gcc/fold-const.c(revision 224943)
--- gcc/fold-const.c(working copy)
*** fold_binary_loc (location_t loc,
*** 12165,12179 
  type);
}
  
-   /* Similarly for a NEGATE_EXPR.  */
-   if (TREE_CODE (arg0) == NEGATE_EXPR
- && TREE_CODE (arg1) == INTEGER_CST
- && 0 != (tem = negate_expr (fold_convert_loc (loc, TREE_TYPE (arg0),
-   arg1)))
- && TREE_CODE (tem) == INTEGER_CST
- && !TREE_OVERFLOW (tem))
-   return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), tem);
- 
/* Similarly for a BIT_XOR_EXPR;  X ^ C1 == C2 is X == (C1 ^ C2).  */
if (TREE_CODE (arg0) == BIT_XOR_EXPR
  && TREE_CODE (arg1) == INTEGER_CST
--- 12165,12170 
*** fold_binary_loc (location_t loc,
*** 12358,12379 
return omit_one_operand_loc (loc, type, rslt, arg0);
}
  
-   /* If we have (A | C) == D where C & ~D != 0, convert this into 0.
-Similarly for NE_EXPR.  */
-   if (TREE_CODE (arg0) == BIT_IOR_EXPR
- && TREE_CODE (arg1) == INTEGER_CST
- && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST)
-   {
- tree notd = fold_build1_loc (loc, BIT_NOT_EXPR, TREE_TYPE (arg1), 
arg1);
- tree candnotd
-   = fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (arg0),
-  TREE_OPERAND (arg0, 1),
-  fold_convert_loc (loc, TREE_TYPE (arg0), notd));
- tree rslt = code == EQ_EXPR ? integer_zero_node : integer_one_node;
- if (integer_nonzerop (candnotd))
-   return omit_one_operand_loc (loc, type, rslt, arg0);
-   }
- 
/* If this is a comparison of a field, we may be able to simplify it.  
*/
if ((TREE_CODE (arg0) == COMPONENT_REF
   || TREE_CODE (arg0) == BIT_FIELD_REF)
--- 12349,12354 
*** fold_binary_loc (location_t loc,
*** 12431,12462 
}
}
  
-   /* (X ^ Y) == 0 becomes X == Y, and (X ^ Y) != 0 becomes X != Y.  */
-   if (integer_zerop (arg1)
- && TREE_CODE (arg0) == BIT_XOR_EXPR)
-   return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0),
-   TREE_OPERAND (arg0, 1));
- 
-   /* (X ^ Y) == Y becomes X == 0.  We know that Y has no side-effects.  */
-   if (TREE_CODE (arg0) == BIT_XOR_EXPR
- && operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0))
-   return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0),
-   build_zero_cst (TREE_TYPE (arg0)));
-   /* Likewise (X ^ Y) == X becomes Y == 0.  X has no side-effects.  */
-   if (TREE_CODE (arg0) == BIT_XOR_EXPR
- && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)
- && reorder_operands_p (TREE_OPERAND (arg0, 1), arg1))
-   return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 1),
-   build_zero_cst (TREE_TYPE (arg0)));
- 
-   /* (X ^ C1) op C2 can be rewritten as X op (C1 ^ C2).  */
-   if (TREE_CODE (arg0) == BIT_XOR_EXPR
- && TREE_CODE (arg1) == INTEGER_CST
- && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST)
-   return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0),
-   fold_build2_loc (loc, BIT_XOR_EXPR, TREE_TYPE 
(arg1),
-TREE_OPERAND (arg0, 1), arg1));
- 
/* Fold (~X & C) == 0 into (X & C) != 0 and (~X & C) != 0 into
 (X & C) == 0 when C is a single bit.  */
if (TREE_CODE (arg0) == BIT_AND_EXPR
--- 12406,12411 
*** fold_binary_loc (location_t loc,
*** 12510,12523 
  return omit_one_operand_loc (loc, type, res, arg0);
}
  
-   /* Fold -X op -Y as X op Y, where op is eq/ne.  */
-   if (TREE_CODE (arg0) == NEGATE_EXPR
-   && TREE_CODE (arg1) == NEGATE_EXPR)
-   return fold_build2_loc (loc, code, type,
-   TREE_OPERAND (arg0, 0),
-   fold_convert_loc (loc, TREE_TYPE (arg0),
- TREE_OPERAND (arg1, 0)));
- 
/* Fold (X & C) o

Re: [i386, PATCH, 3/3] IA MCU psABI support: testsuite.

2015-06-26 Thread Uros Bizjak
On Tue, Jun 23, 2015 at 11:38 AM, Kirill Yukhin  wrote:
> Hello,
> This patch introduces tests for new psABI.
>
> gcc/testsuite/
> * gcc.target/i386/iamcu/abi-iamcu.exp: New file.
> * gcc.target/i386/iamcu/args.h: Likewise.
> * gcc.target/i386/iamcu/asm-support.S: Likewise.
> * gcc.target/i386/iamcu/defines.h: Likewise.
> * gcc.target/i386/iamcu/macros.h: Likewise.
> * gcc.target/i386/iamcu/test_3_element_struct_and_unions.c: Likewise.
> * gcc.target/i386/iamcu/test_basic_64bit_returning.c: Likewise.
> * gcc.target/i386/iamcu/test_basic_alignment.c: Likewise.
> * gcc.target/i386/iamcu/test_basic_array_size_and_align.c: Likewise.
> * gcc.target/i386/iamcu/test_basic_returning.c: Likewise.
> * gcc.target/i386/iamcu/test_basic_sizes.c: Likewise.
> * gcc.target/i386/iamcu/test_basic_struct_size_and_align.c: Likewise.
> * gcc.target/i386/iamcu/test_basic_union_size_and_align.c: Likewise.
> * gcc.target/i386/iamcu/test_bitfields.c: Likewise.
> * gcc.target/i386/iamcu/test_complex_returning.c: Likewise.
> * gcc.target/i386/iamcu/test_passing_floats.c: Likewise.
> * gcc.target/i386/iamcu/test_passing_integers.c: Likewise.
> * gcc.target/i386/iamcu/test_passing_structs.c: Likewise.
> * gcc.target/i386/iamcu/test_passing_structs_and_unions.c: Likewise.
> * gcc.target/i386/iamcu/test_passing_unions.c: Likewise.
> * gcc.target/i386/iamcu/test_struct_returning.c: Likewise.
> * gcc.target/i386/iamcu/test_varargs.c: Likewise.
>
> New tests pass, when run on for 32b target.
> Is it ok for trunk?

I didn't look in all the details, but the patch LGTM.

So, OK.

Thanks,
Uros.

> --
> Thanks, K
>
> diff --git a/gcc/testsuite/gcc.target/i386/iamcu/abi-iamcu.exp 
> b/gcc/testsuite/gcc.target/i386/iamcu/abi-iamcu.exp
> new file mode 100644
> index 000..b5b3261
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/iamcu/abi-iamcu.exp
> @@ -0,0 +1,42 @@
> +# Copyright (C) 2015 Free Software Foundation, Inc.
> +
> +# This program 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 of the License, or
> +# (at your option) any later version.
> +#
> +# This program 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.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with GCC; see the file COPYING3.  If not see
> +# .
> +
> +# The Intel MCU psABI testsuite needs one additional assembler file for
> +# most testcases.  For simplicity we will just link it into each test.
> +
> +load_lib c-torture.exp
> +load_lib target-supports.exp
> +load_lib torture-options.exp
> +
> +if { (![istarget x86_64-*-linux*] && ![istarget i?86-*-linux*])
> + || ![is-effective-target ia32] } then {
> +  return
> +}
> +
> +
> +torture-init
> +set-torture-options $C_TORTURE_OPTIONS
> +set additional_flags "-miamcu -W -Wall -Wno-abi"
> +
> +foreach src [lsort [glob -nocomplain $srcdir/$subdir/test_*.c]] {
> +if {[runtest_file_p $runtests $src]} {
> +   c-torture-execute [list $src \
> +   $srcdir/$subdir/asm-support.S] \
> +   $additional_flags
> +}
> +}
> +
> +torture-finish
> diff --git a/gcc/testsuite/gcc.target/i386/iamcu/args.h 
> b/gcc/testsuite/gcc.target/i386/iamcu/args.h
> new file mode 100644
> index 000..f8abde4
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/iamcu/args.h
> @@ -0,0 +1,77 @@
> +#ifndef INCLUDED_ARGS_H
> +#define INCLUDED_ARGS_H
> +
> +/* This defines the calling sequences for integers and floats.  */
> +#define I0 eax
> +#define I1 edx
> +#define I2 ecx
> +
> +typedef unsigned int size_t;
> +
> +extern void (*callthis)(void);
> +extern unsigned long eax,ebx,ecx,edx,esi,edi,esp,ebp;
> +extern unsigned long sret_eax;
> +extern volatile unsigned long volatile_var;
> +extern void snapshot (void);
> +extern void snapshot_ret (void);
> +extern void *iamcu_memset (void *, int, size_t);
> +#define WRAP_CALL(N) \
> +  (callthis = (void (*)()) (N), (typeof (&N)) snapshot)
> +#define WRAP_RET(N) \
> +  (callthis = (void (*)()) (N), (typeof (&N)) snapshot_ret)
> +
> +/* Clear all scratch integer registers.  */
> +#define clear_int_hardware_registers \
> +  asm __volatile__ ("xor %%eax, %%eax\n\t" \
> +   "xor %%edx, %%edx\n\t" \
> +   "xor %%ecx, %%ecx\n\t" \
> +   ::: "eax", "edx", "ecx");
> +
> +/* Clear all scratch integer registers, excluding the one used to return
> +   aggregate.  */
> +#define clear_non_sret_int_hardware_registers \
> +  asm __volatile__ ("xor %%edx

[PATCH PR66638]Fix assertion failure by skip the case.

2015-06-26 Thread Bin Cheng
Hi,
This patch fixes GCC's profiled bootstrap failure.  As comment added by in
patch, it may still be possible to prove no overflow information for some
scev, unfortunately it's a rare case observed during GCC profiled bootstrap.
So for now I just skip it.

Is this OK?

Thanks,
bin

2015-06-26  Bin Cheng  

PR bootstrap/66638
* tree-ssa-loop-niter.c (loop_exits_before_overflow): Skip if
assertion failed.  Remove assertion itself.

Index: gcc/tree-ssa-loop-niter.c
===
--- gcc/tree-ssa-loop-niter.c   (revision 224827)
+++ gcc/tree-ssa-loop-niter.c   (working copy)
@@ -3955,7 +3955,21 @@ loop_exits_before_overflow (tree base, tree step,
if (!CONVERT_EXPR_P (e) || !operand_equal_p (e, unsigned_base, 0))
  continue;
e = TREE_OPERAND (e, 0);
-   gcc_assert (operand_equal_p (e, base, 0));
+   /* It may still be possible to prove no overflow even if condition
+  "operand_equal_p (e, base, 0)" isn't satisfied here, like below
+  example:
+
+e : ssa_var ; unsigned long type
+base  : (int) ssa_var
+unsigned_base : (unsigned int) ssa_var
+
+  Unfortunately this is a rare case observed during GCC profiled
+  bootstrap.  See PR66638 for more information.
+
+  For now, we just skip the possibility.  */
+   if (!operand_equal_p (e, base, 0))
+ continue;
+
if (tree_int_cst_sign_bit (step))
  {
code = LT_EXPR;


Re: [PATCH PR66638]Fix assertion failure by skip the case.

2015-06-26 Thread Richard Biener
On Fri, Jun 26, 2015 at 1:03 PM, Bin Cheng  wrote:
> Hi,
> This patch fixes GCC's profiled bootstrap failure.  As comment added by in
> patch, it may still be possible to prove no overflow information for some
> scev, unfortunately it's a rare case observed during GCC profiled bootstrap.
> So for now I just skip it.
>
> Is this OK?

Ok.

Thanks,
Richard.

> Thanks,
> bin
>
> 2015-06-26  Bin Cheng  
>
> PR bootstrap/66638
> * tree-ssa-loop-niter.c (loop_exits_before_overflow): Skip if
> assertion failed.  Remove assertion itself.
>


[PATCH] Fix PR66677

2015-06-26 Thread Richard Biener

Bootstrap & regtest running on x86_64-unknown-linux-gnu.

Richard.

2015-06-26  Richard Biener  

PR tree-optimization/66677
* tree-vect-stmts.c (vect_transform_stmt): Make assert about
STMT_VINFO_VEC_STMT clobbering less strict.

* gcc.dg/vect/pr66677.c: New testcase.

Index: gcc/tree-vect-stmts.c
===
--- gcc/tree-vect-stmts.c   (revision 225007)
+++ gcc/tree-vect-stmts.c   (working copy)
@@ -7620,14 +7620,8 @@ vect_transform_stmt (gimple stmt, gimple
   /* Verify SLP vectorization doesn't mess with STMT_VINFO_VEC_STMT.
  This would break hybrid SLP vectorization.  */
   if (slp_node)
-{
-  if (PURE_SLP_STMT (stmt_info))
-   gcc_assert (!old_vec_stmt && !vec_stmt
-   && !STMT_VINFO_VEC_STMT (stmt_info));
-  else if (HYBRID_SLP_STMT (stmt_info))
-   gcc_assert (!vec_stmt
-   && STMT_VINFO_VEC_STMT (stmt_info) == old_vec_stmt);
-}
+gcc_assert (!vec_stmt
+   && STMT_VINFO_VEC_STMT (stmt_info) == old_vec_stmt);
 
   /* Handle inner-loop stmts whose DEF is used in the loop-nest that
  is being vectorized, but outside the immediately enclosing loop.  */
Index: gcc/testsuite/gcc.dg/vect/pr66677.c
===
--- gcc/testsuite/gcc.dg/vect/pr66677.c (revision 0)
+++ gcc/testsuite/gcc.dg/vect/pr66677.c (working copy)
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-msse4" { target x86_64-*-* i?86-*-* } } */
+
+int *a, *b;
+void fn1(char *p1)
+{
+  int x;
+  for (; x; x += 2)
+{
+  a[x] = p1[0];
+  a[x + 1] = 0;
+  b[x] = b[x + 1] = p1[1];
+  p1 += 4;
+}
+}


[PATCH] Fix PR c++/30044

2015-06-26 Thread Patrick Palka
Here is a more modest approach to fixing this PR.  Instead of updating
current_template_parms with each newly processed template parameter,
this patch just updates it with a "dummy" parameter level once per
parameter list.  So now in tsubst(), to fix the reported ICE we just
have to avoid substituting a template parameter if it corresponds to an
empty "dummy" argument level.

One caveat with this approach is that since template template decls will
now have dummy parameter levels in their DECL_TEMPLATE_PARMS fields, we
have to avoid emitting such dummy levels inside error messages when
printing template template parameters.  Otherwise the parameter B in

  template class B> struct Foo { };

would get printed in error messages as

  template<> template  class B>

Two new test files are added in this version: shadow2.C, which checks
that we emit a shadowing error for identical template parameter names
across nested parameter lists, and error55.C, which checks that we
correctly emit template template decls in error messages.

With this approach the test case provided by Markus no longer takes
forever to compile because the added parameter lists are always empty so
when doing structural type comparison of a TEMPLATE_TEMPLATE_PARM there
is nothing extra to recurse into.

Does this approach seem sensible?

gcc/cp/ChangeLog:

PR c++/30044
* pt.c (begin_template_parm_list): Add a dummy parameter level
to current_template_parms.
(end_template_parm_list): Remove the dummy parameter level
before adding the real one.
(tsubst): Don't attempt to substitute for template parameters
corresponding to a dummy argument level.
(template_parms_to_args): Remove obsolete hack for
giving template template arguments the proper level.
(splite_late_return_type): Remove obsolete hack for giving
template template arguments the proper level.
* error.c (dump_template_decl): Don't print dummy template
levels.

gcc/testsuite/ChangeLog

PR c++/30044
* g++.dg/cpp0x/auto45.C: New test.
* g++.dg/template/pr30044.C: New test.
* g++.dg/template/shadow2.C: New test.
* g++.dg/template/error55.C: New test.
* g++.dg/template/crash83.C: Accept any error string.
* g++.dg/cpp0x/variadic18.C: Adjust to avoid shadowing template
parameters.
* g++.dg/cpp0x/variadic18.C: Likewise
* g++.dg/template/canon-type-13.C: Likewise.
* g++.old-deja/g++.pt/ttp42.C: Likewise.
* g++.dg/torture/20070621-1.C: Likewise.
---
 gcc/cp/error.c|  7 ++
 gcc/cp/pt.c   | 32 +--
 gcc/testsuite/g++.dg/cpp0x/auto45.C   |  5 +
 gcc/testsuite/g++.dg/cpp0x/variadic18.C   |  2 +-
 gcc/testsuite/g++.dg/cpp0x/variadic19.C   |  2 +-
 gcc/testsuite/g++.dg/template/canon-type-13.C |  2 +-
 gcc/testsuite/g++.dg/template/crash83.C   |  2 +-
 gcc/testsuite/g++.dg/template/error55.C   |  8 +++
 gcc/testsuite/g++.dg/template/pr30044.C   | 14 
 gcc/testsuite/g++.dg/template/shadow2.C   |  3 +++
 gcc/testsuite/g++.dg/torture/20070621-1.C |  2 +-
 gcc/testsuite/g++.old-deja/g++.pt/ttp42.C |  2 +-
 12 files changed, 54 insertions(+), 27 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/auto45.C
 create mode 100644 gcc/testsuite/g++.dg/template/error55.C
 create mode 100644 gcc/testsuite/g++.dg/template/pr30044.C
 create mode 100644 gcc/testsuite/g++.dg/template/shadow2.C

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 96fa94d..b21befe 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -1296,6 +1296,13 @@ dump_template_decl (cxx_pretty_printer *pp, tree t, int 
flags)
  tree inner_parms = INNERMOST_TEMPLATE_PARMS (parms);
  int len = TREE_VEC_LENGTH (inner_parms);
 
+ if (len == 0)
+   {
+ /* Skip over the dummy template levels of a template template 
parm.  */
+ gcc_assert (TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TEMPLATE_PARM);
+ continue;
+   }
+
  pp_cxx_ws_string (pp, "template");
  pp_cxx_begin_template_argument_list (pp);
 
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index fe5fc14..e7c35d3 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -658,6 +658,12 @@ begin_template_parm_list (void)
   ++processing_template_decl;
   ++processing_template_parmlist;
   note_template_header (0);
+
+  /* Add a dummy parameter level while we process the parameter list.  */
+  current_template_parms
+= tree_cons (size_int (processing_template_decl),
+make_tree_vec (0),
+current_template_parms);
 }
 
 /* This routine is called when a specialization is declared.  If it is
@@ -3854,6 +3860,9 @@ end_template_parm_list (tree parms)
   tree parm, next;
   tree saved_parmlist = make_tree_vec (list_length (parms));
 
+  /* Pop the dummy parameter 

[PATCH 1/4][PR target/65697][5.1] Backport stronger barriers for GCC,__sync builtins on Aarch64

2015-06-26 Thread Matthew Wahab

Hello,

The __sync builtins are implemented using barriers that are too weak for ARMv8
targets, this has been fixed on trunk for Aarch64. Since GCC-5.1 is also
generating the incorrect code, it should also be fixed.

The fix on trunk involved changes to the way that memory orders represent
barriers for __sync builtins and changes to the code generated by the
Aarch64 back-end. This patch backports the changes made to the handling of 
memory
orders.

The trunk patch submission is at
https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00557.html.
The commit is at https://gcc.gnu.org/viewcvs?rev=223096&root=gcc&view=rev

Testing:
- Checked aarch64-none-linux-gnu with check-gcc
- Bootstrapped x86_64-unknown-linux-gnu
- Built all targets (for c and c++) in config-list.mk with no new compiliation
  errors. (I needed to remove the --enable-werror-always flag to get round a
  printf format warning that I believe is unrelated to the change.)

Ok for the branch?
Matthew

2015-06-26  Matthew Wahab  

Backport from trunk
2015-05-12  Andrew MacLeod  

PR target/65697
* coretypes.h (MEMMODEL_SYNC, MEMMODEL_BASE_MASK): New macros.
(enum memmodel): Add SYNC_{ACQUIRE,RELEASE,SEQ_CST}.
* tree.h (memmodel_from_int, memmodel_base, is_mm_relaxed,
is_mm_consume,is_mm_acquire, is_mm_release, is_mm_acq_rel,
is_mm_seq_cst, is_mm_sync): New accessor functions.
* builtins.c (expand_builtin_sync_operation,
expand_builtin_compare_and_swap): Use MEMMODEL_SYNC_SEQ_CST.
(expand_builtin_sync_lock_release): Use MEMMODEL_SYNC_RELEASE.
(get_memmodel,  expand_builtin_atomic_compare_exchange,
expand_builtin_atomic_load, expand_builtin_atomic_store,
expand_builtin_atomic_clear): Use new accessor routines.
(expand_builtin_sync_synchronize): Use MEMMODEL_SYNC_SEQ_CST.
* optabs.c (expand_compare_and_swap_loop): Use MEMMODEL_SYNC_SEQ_CST.
(maybe_emit_sync_lock_test_and_set): Use new accessors and
MEMMODEL_SYNC_ACQUIRE.
(expand_sync_lock_test_and_set): Use MEMMODEL_SYNC_ACQUIRE.
(expand_mem_thread_fence, expand_mem_signal_fence, expand_atomic_load,
expand_atomic_store): Use new accessors.
* emit-rtl.c (need_atomic_barrier_p): Add additional enum cases.
* tsan.c (instrument_builtin_call): Update check for memory model beyond
final enum to use MEMMODEL_LAST.
* c-family/c-common.c: Use new accessor for memmodel_base.
* config/aarch64/aarch64.c (aarch64_expand_compare_and_swap): Use new
accessors.
* config/aarch64/atomics.md (atomic_load,atomic_store,
arch64_load_exclusive, aarch64_store_exclusive,
mem_thread_fence, *dmb): Likewise.
* config/alpha/alpha.c (alpha_split_compare_and_swap,
alpha_split_compare_and_swap_12): Likewise.
* config/arm/arm.c (arm_expand_compare_and_swap,
arm_split_compare_and_swap, arm_split_atomic_op): Likewise.
* config/arm/sync.md (atomic_load, atomic_store,
atomic_loaddi): Likewise.
* config/i386/i386.c (ix86_destroy_cost_data, ix86_memmodel_check):
Likewise.
* config/i386/sync.md (mem_thread_fence, atomic_store): Likewise.
* config/ia64/ia64.c (ia64_expand_atomic_op): Add new memmodel cases and
use new accessors.
* config/ia64/sync.md (mem_thread_fence, atomic_load,
atomic_store, atomic_compare_and_swap,
atomic_exchange): Use new accessors.
* config/mips/mips.c (mips_process_sync_loop): Likewise.
* config/pa/pa.md (atomic_loaddi, atomic_storedi): Likewise.
* config/rs6000/rs6000.c (rs6000_pre_atomic_barrier,
rs6000_post_atomic_barrier): Add new cases.
(rs6000_expand_atomic_compare_and_swap): Use new accessors.
* config/rs6000/sync.md (mem_thread_fence): Add new cases.
(atomic_load): Add new cases and use new accessors.
(store_quadpti): Add new cases.
* config/s390/s390.md (mem_thread_fence, atomic_store): Use new
accessors.
* config/sparc/sparc.c (sparc_emit_membar_for_model): Use new accessors.
* doc/extend.texi: Update docs to indicate 16 bits are used for memory
model, not 8.

From 4797f71dc0946cbb5a7541abd90932cef25fbfa1 Mon Sep 17 00:00:00 2001
From: amacleod 
Date: Tue, 12 May 2015 20:01:47 +
Subject: [PATCH 1/4] Backport 2015-05-12  Andrew MacLeod 
 

	PR target/65697
	* coretypes.h (MEMMODEL_SYNC, MEMMODEL_BASE_MASK): New macros.
	(enum memmodel): Add SYNC_{ACQUIRE,RELEASE,SEQ_CST}.
	* tree.h (memmodel_from_int, memmodel_base, is_mm_relaxed,
	is_mm_consume,is_mm_acquire, is_mm_release, is_mm_acq_rel,
	is_mm_seq_cst, is_mm_sync): New accessor functions.
	* builtins.c (expand_builtin_sync_operation,
	expand_builtin_compare_and_swap): Use MEMMODEL_SYNC_SEQ_CST.
	(expand_builtin_sync_lock_release): Use MEMMODEL_SYNC_RELEASE.
	(get_memmodel,  expand_builtin_atomic_compa

Re: [PATCH] Make muser-mode the default for LEON3

2015-06-26 Thread Daniel Cederman


Do they lack the CASA instruction with supervisor-mode ASI?  What happens when
the CASA instruction with user-mode ASI is executed in supervisor mode?



For all LEON3 (with CASA support) the CASA instruction works in 
supervisor-mode regardless of ASI used. In user-mode CASA only works 
with the user-mode ASI. So CASA with user-mode ASI works for both 
user-mode and supervisor-mode. By having user-mode ASI as default, one 
would not need to change flag when compiling user or kernel code.


On a few old LEON3 systems the CASA instruction only works in supervisor 
mode. Using the CASA instruction with the user-mode ASI on these systems 
is not legal and will cause a trap.


--
Daniel Cederman


Re: [PATCH 2/2] Add leon3r0 and leon3r0v7 CPU targets

2015-06-26 Thread Daniel Cederman



On 2015-06-26 09:45, Eric Botcazou wrote:

Early variants of LEON3, revision 0, do not support the CASA instruction.
This patch adds two new targets, leon3r0 and leon3r0v7, that are equivalent
to leon3 and leon3v7, except that they do not support CASA.


Why not use leon instead of leon3 for them?



The UT699 is a leon3r0 system which does not support CASA. However, to 
enable the errata fixes for UT699 with -mfix-ut699 requires the CPU 
target to be leon3. This causes the CASA instruction to be generated for 
UT699.


The instruction timing also differs between leon and leon3 and they are 
represented by different targets in binutils.


--
Daniel Cederman


[PATCH 2/4][PR target/65697][5.1][Aarch64] Backport stronger barriers for __sync,fetch-op builtins.

2015-06-26 Thread Matthew Wahab


This patch backports the changes made to strengthen the barriers emitted for
the __sync fetch-and-op/op-and-fetch builtins.

The trunk patch submission is at
https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01989.html
The commit is at https://gcc.gnu.org/ml/gcc-cvs/2015-06/msg00076.html

Tested the series for aarch64-none-linux-gnu with check-gcc

Ok for the branch?
Matthew

2015-06-26  Matthew Wahab  

Backport from trunk.
2015-06-01  Matthew Wahab  

PR target/65697
* config/aarch64/aarch64.c (aarch64_emit_post_barrier):New.
(aarch64_split_atomic_op): Check for __sync memory models, emit
appropriate initial loads and final barriers.

From d6d3351b4547d0ad52e4d7e9955fafdced11491a Mon Sep 17 00:00:00 2001
From: mwahab 
Date: Mon, 1 Jun 2015 15:18:19 +
Subject: [PATCH 2/4] [Aarch64][5.1] Strengthen barriers for sync-fetch-op
 builtin.

PR target/65697
	* config/aarch64/aarch64.c (aarch64_emit_post_barrier):New.
	(aarch64_split_atomic_op): Check for __sync memory models, emit
	appropriate initial loads and final barriers.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223983 138bc75d-0d04-0410-961f-82ee72b054a4

Conflicts:
	gcc/ChangeLog
	gcc/config/aarch64/aarch64.c

Change-Id: I45600c4dd0002b4c2d48de36d695c83581fe50da
---
 gcc/config/aarch64/aarch64.c | 31 ++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index b8b37b8..708fc23 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -9066,6 +9066,23 @@ aarch64_expand_compare_and_swap (rtx operands[])
   emit_insn (gen_rtx_SET (VOIDmode, bval, x));
 }
 
+/* Emit a barrier, that is appropriate for memory model MODEL, at the end of a
+   sequence implementing an atomic operation.  */
+
+static void
+aarch64_emit_post_barrier (enum memmodel model)
+{
+  const enum memmodel base_model = memmodel_base (model);
+
+  if (is_mm_sync (model)
+  && (base_model == MEMMODEL_ACQUIRE
+	  || base_model == MEMMODEL_ACQ_REL
+	  || base_model == MEMMODEL_SEQ_CST))
+{
+  emit_insn (gen_mem_thread_fence (GEN_INT (MEMMODEL_SEQ_CST)));
+}
+}
+
 /* Split a compare and swap pattern.  */
 
 void
@@ -9128,6 +9145,8 @@ aarch64_split_atomic_op (enum rtx_code code, rtx old_out, rtx new_out, rtx mem,
 {
   machine_mode mode = GET_MODE (mem);
   machine_mode wmode = (mode == DImode ? DImode : SImode);
+  const enum memmodel model = memmodel_from_int (INTVAL (model_rtx));
+  const bool is_sync = is_mm_sync (model);
   rtx_code_label *label;
   rtx x;
 
@@ -9142,7 +9161,13 @@ aarch64_split_atomic_op (enum rtx_code code, rtx old_out, rtx new_out, rtx mem,
 old_out = new_out;
   value = simplify_gen_subreg (wmode, value, mode, 0);
 
-  aarch64_emit_load_exclusive (mode, old_out, mem, model_rtx);
+  /* The initial load can be relaxed for a __sync operation since a final
+ barrier will be emitted to stop code hoisting.  */
+ if (is_sync)
+aarch64_emit_load_exclusive (mode, old_out, mem,
+ GEN_INT (MEMMODEL_RELAXED));
+  else
+aarch64_emit_load_exclusive (mode, old_out, mem, model_rtx);
 
   switch (code)
 {
@@ -9178,6 +9203,10 @@ aarch64_split_atomic_op (enum rtx_code code, rtx old_out, rtx new_out, rtx mem,
   x = gen_rtx_IF_THEN_ELSE (VOIDmode, x,
 			gen_rtx_LABEL_REF (Pmode, label), pc_rtx);
   aarch64_emit_unlikely_jump (gen_rtx_SET (VOIDmode, pc_rtx, x));
+
+  /* Emit any final barrier needed for a __sync operation.  */
+  if (is_sync)
+aarch64_emit_post_barrier (model);
 }
 
 static void
-- 
1.9.1



[PATCH, i386]: Fix PR 66648, incorrect memcpy expansion with unrolled_loop strategy

2015-06-26 Thread Uros Bizjak
Hello!

As explained in the PR [1], we have to emit check for main loop
execution UNLESS we guarantee that min_size is at least equal to
size_needed. In this testcase, VRP declared minimum copying size, and
after unaligned prologue adjustment, min_size was still non-zero. The
!min_size check didn't account for the case that min_size can be
non-zero, but still less than size_needed.

2015-06-26  Uros Bizjak  

PR target/66648
* config/i386/i386.c (ix86_expand_set_or_movmem): Emit main loop
execution guard when min_size is less than size_needed.

testsuite/ChangeLog:

2015-06-26  Uros Bizjak  

PR target/66648
* gcc.target/i386/pr66648.c: New test.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Honza, does the patch look OK to you?

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66648

Uros.
Index: config/i386/i386.c
===
--- config/i386/i386.c  (revision 224993)
+++ config/i386/i386.c  (working copy)
@@ -25008,7 +25008,8 @@ ix86_expand_set_or_movmem (rtx dst, rtx src, rtx c
   dst = change_address (dst, BLKmode, destreg);
   set_mem_align (dst, desired_align * BITS_PER_UNIT);
   epilogue_size_needed = 0;
-  if (need_zero_guard && !min_size)
+  if (need_zero_guard
+ && min_size < (unsigned HOST_WIDE_INT) size_needed)
{
  /* It is possible that we copied enough so the main loop will not
 execute.  */
@@ -25140,7 +25141,7 @@ ix86_expand_set_or_movmem (rtx dst, rtx src, rtx c
  max_size -= align_bytes;
}
   if (need_zero_guard
- && !min_size
+ && min_size < (unsigned HOST_WIDE_INT) size_needed
  && (count < (unsigned HOST_WIDE_INT) size_needed
  || (align_bytes == 0
  && count < ((unsigned HOST_WIDE_INT) size_needed
Index: testsuite/gcc.target/pr66648.c
===
--- testsuite/gcc.target/pr66648.c  (revision 0)
+++ testsuite/gcc.target/pr66648.c  (working copy)
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -mstringop-strategy=unrolled_loop -mtune=nocona" } */
+
+#define PATTERN 0xdeadbeef
+#define SIZE32
+
+struct S { int i; char str[SIZE]; int j; };
+
+void __attribute__((noclone, noinline))
+my_memcpy (char *, const char *, unsigned int);
+
+void
+my_memcpy (char *dst, const char *src, unsigned int len)
+{
+  if (len < 8)
+__builtin_abort ();
+
+  __builtin_memcpy (dst, src, len);
+}
+
+int
+main (void)
+{
+  const char str[SIZE]= "1234567890123456789012345678901";
+  struct S *s = __builtin_malloc (sizeof (struct S));
+
+  s->j = PATTERN;
+  my_memcpy (s->str, str, SIZE);
+  if (s->j != PATTERN)
+__builtin_abort ();
+
+  return 0;
+}


[PATCH 3/4][PR target/65697][5.1][Aarch64] Backport stronger barriers for __sync,compare-and-swap builtins.

2015-06-26 Thread Matthew Wahab

This patch backports the changes made to strengthen the barriers emitted for
the __sync compare-and-swap builtins.

The trunk patch submission is at
https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01990.html
The commit is at https://gcc.gnu.org/ml/gcc-cvs/2015-06/msg00077.html

Tested the series for aarch64-none-linux-gnu with check-gcc

Ok for the branch?
Matthew

2015-06-26  Matthew Wahab  

Backport from trunk.
2015-06-01  Matthew Wahab  

PR target/65697
* config/aarch64/aarch64.c (aarch64_split_compare_and_swap): Check
for __sync memory models, emit initial loads and final barriers as
appropriate.


From 5fbfcc46e6eb2b8b61aa96c9c96da9a572bc4d12 Mon Sep 17 00:00:00 2001
From: mwahab 
Date: Mon, 1 Jun 2015 15:21:02 +
Subject: [PATCH 3/4] [Aarch64][5.1] Strengthen barriers for sync-compare-swap
 builtins

	PR target/65697
	* config/aarch64/aarch64.c (aarch64_split_compare_and_swap): Check
	for __sync memory models, emit initial loads and final barriers as
	appropriate.

Change-Id: I65d8000c081d582246b81c7f3892c509a64b136c
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223984 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/config/aarch64/aarch64.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 708fc23..59d2e3a 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -9093,14 +9093,18 @@ aarch64_split_compare_and_swap (rtx operands[])
   bool is_weak;
   rtx_code_label *label1, *label2;
   rtx x, cond;
+  enum memmodel model;
+  rtx model_rtx;
 
   rval = operands[0];
   mem = operands[1];
   oldval = operands[2];
   newval = operands[3];
   is_weak = (operands[4] != const0_rtx);
+  model_rtx = operands[5];
   scratch = operands[7];
   mode = GET_MODE (mem);
+  model = memmodel_from_int (INTVAL (model_rtx));
 
   label1 = NULL;
   if (!is_weak)
@@ -9110,7 +9114,13 @@ aarch64_split_compare_and_swap (rtx operands[])
 }
   label2 = gen_label_rtx ();
 
-  aarch64_emit_load_exclusive (mode, rval, mem, operands[5]);
+  /* The initial load can be relaxed for a __sync operation since a final
+ barrier will be emitted to stop code hoisting.  */
+  if (is_mm_sync (model))
+aarch64_emit_load_exclusive (mode, rval, mem,
+ GEN_INT (MEMMODEL_RELAXED));
+  else
+aarch64_emit_load_exclusive (mode, rval, mem, model_rtx);
 
   cond = aarch64_gen_compare_reg (NE, rval, oldval);
   x = gen_rtx_NE (VOIDmode, cond, const0_rtx);
@@ -9118,7 +9128,7 @@ aarch64_split_compare_and_swap (rtx operands[])
 			gen_rtx_LABEL_REF (Pmode, label2), pc_rtx);
   aarch64_emit_unlikely_jump (gen_rtx_SET (VOIDmode, pc_rtx, x));
 
-  aarch64_emit_store_exclusive (mode, scratch, mem, newval, operands[5]);
+  aarch64_emit_store_exclusive (mode, scratch, mem, newval, model_rtx);
 
   if (!is_weak)
 {
@@ -9135,6 +9145,10 @@ aarch64_split_compare_and_swap (rtx operands[])
 }
 
   emit_label (label2);
+
+  /* Emit any final barrier needed for a __sync operation.  */
+  if (is_mm_sync (model))
+aarch64_emit_post_barrier (model);
 }
 
 /* Split an atomic operation.  */
-- 
1.9.1



[PATCH 4/4][PR target/65697][5.1][Aarch64] Backport tests for __sync_builtins.

2015-06-26 Thread Matthew Wahab

This patch backports the tests added for the code generated by the Aarch64 
backend
for the __sync builtins.

The trunk patch submission is at
https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01992.html
The commit is at https://gcc.gnu.org/ml/gcc-cvs/2015-06/msg00079.html

Tested the series for aarch64-none-linux-gnu with check-gcc

Ok for the branch?
Matthew

2015-06-26  Matthew Wahab  

Backport from trunk
2015-06-01  Matthew Wahab  

PR target/65697
* gcc.target/aarch64/sync-comp-swap.c: New.
* gcc.target/aarch64/sync-comp-swap.x: New.
* gcc.target/aarch64/sync-op-acquire.c: New.
* gcc.target/aarch64/sync-op-acquire.x: New.
* gcc.target/aarch64/sync-op-full.c: New.
* gcc.target/aarch64/sync-op-full.x: New.
* gcc.target/aarch64/sync-op-release.c: New.
* gcc.target/aarch64/sync-op-release.x: New.

From 704058e9acd56043c3b8549c3bbe14acf1c370e3 Mon Sep 17 00:00:00 2001
From: mwahab 
Date: Mon, 1 Jun 2015 15:24:37 +
Subject: [PATCH 4/4] [Aarch64][5.1] Add tests for __sync_builtins.

	PR target/65697
	* gcc.target/aarch64/sync-comp-swap.c: New.
	* gcc.target/aarch64/sync-comp-swap.x: New.
	* gcc.target/aarch64/sync-op-acquire.c: New.
	* gcc.target/aarch64/sync-op-acquire.x: New.
	* gcc.target/aarch64/sync-op-full.c: New.
	* gcc.target/aarch64/sync-op-full.x: New.
	* gcc.target/aarch64/sync-op-release.c: New.
	* gcc.target/aarch64/sync-op-release.x: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223986 138bc75d-0d04-0410-961f-82ee72b054a4

Conflicts:
	gcc/testsuite/ChangeLog

Change-Id: I1cc83df41532588a7d91c5b021838392e5547e85
---
 gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c  |  8 +++
 gcc/testsuite/gcc.target/aarch64/sync-comp-swap.x  | 13 
 gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c |  8 +++
 gcc/testsuite/gcc.target/aarch64/sync-op-acquire.x |  7 +++
 gcc/testsuite/gcc.target/aarch64/sync-op-full.c|  8 +++
 gcc/testsuite/gcc.target/aarch64/sync-op-full.x| 73 ++
 gcc/testsuite/gcc.target/aarch64/sync-op-release.c |  6 ++
 gcc/testsuite/gcc.target/aarch64/sync-op-release.x |  7 +++
 8 files changed, 130 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sync-comp-swap.x
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sync-op-acquire.x
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sync-op-full.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sync-op-full.x
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sync-op-release.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sync-op-release.x

diff --git a/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c b/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c
new file mode 100644
index 000..126b997
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-ipa-icf" } */
+
+#include "sync-comp-swap.x"
+
+/* { dg-final { scan-assembler-times "ldxr\tw\[0-9\]+, \\\[x\[0-9\]+\\\]" 2 } } */
+/* { dg-final { scan-assembler-times "stlxr\tw\[0-9\]+, w\[0-9\]+, \\\[x\[0-9\]+\\\]" 2 } } */
+/* { dg-final { scan-assembler-times "dmb\tish" 2 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.x b/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.x
new file mode 100644
index 000..eda52e40
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.x
@@ -0,0 +1,13 @@
+int v = 0;
+
+int
+sync_bool_compare_swap (int a, int b)
+{
+  return __sync_bool_compare_and_swap (&v, &a, &b);
+}
+
+int
+sync_val_compare_swap (int a, int b)
+{
+  return __sync_val_compare_and_swap (&v, &a, &b);
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c b/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c
new file mode 100644
index 000..2639f9f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include "sync-op-acquire.x"
+
+/* { dg-final { scan-assembler-times "ldxr\tw\[0-9\]+, \\\[x\[0-9\]+\\\]" 1 } } */
+/* { dg-final { scan-assembler-times "stxr\tw\[0-9\]+, w\[0-9\]+, \\\[x\[0-9\]+\\\]" 1 } } */
+/* { dg-final { scan-assembler-times "dmb\tish" 1 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.x b/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.x
new file mode 100644
index 000..4c4548c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.x
@@ -0,0 +1,7 @@
+int v;
+
+int
+sync_lock_test_and_set (int a)
+{
+  return __sync_lock_test_and_set (&v, a);
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sync-op-full.c b/gcc/testsuite/gcc.target/aarch64/sync-op-full.c
new file mode 100644
index 000..10fc8fc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sync-op-full.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-optio

Re: fix PR46029: reimplement if conversion of loads and stores

2015-06-26 Thread Alan Lawrence

Sebastian Pop wrote:

On Thu, Jun 25, 2015 at 4:43 AM, Richard Biener
 wrote:

when the new scheme triggers vectorization cannot succeed on the
result as we get

  if (cond)
*p = val;

if-converted to

  tem = cond ? p : &scratch;
  *tem = val;


That's correct.


and

   if (cond)
 val = *p;

if-converted to

  scatch = val;
  tem = cond ? p : &scratch;
  val = *tem;


The patch does this slightly differently:

   tem = cond ? p : &scratch;
   val = cond ? *tem : val;

I think I like your version better as it has only one cond_expr.


Another slight concern...by reusing scratchpad's, are we at risk of creating 
lots of false dependencies here, that restrict instruction scheduling / other 
opts later?



[...]
and thus the store and loads appear as scather/gather ones to
the vectorizer (if-conversion could directly generate masked
load/stores of course and not use a scratch-pad at all in that case).


Thank you Richard for much better expressing what I was thinking here too :)


Abe also suggested to continue optimizing the other way in cases
where we know to write or load from the same location on all branches:

if (c)
  A[i] = ...
else
  A[i] = ...


The store here really should be commoned, yes.

(Related but different?: BZ 56625.)


I might add, I find this code much easier to follow than the old (removed) code 
about data references, memrefs_read_unconditionally, and 
write_memrefs_written_at_least-once...


Thanks, Alan



[nvptx] small cleanup patch

2015-06-26 Thread Nathan Sidwell

Bernd,
I've applied this small patch to trunk.  It removes some unused variables in the 
ptx md file and silences some build warnings.


nathan
--
Nathan Sidwell
2015-06-26  Nathan Sidwell  

	* config/nvptx/nvptx.md (call_operation): Remove unused variables.

Index: config/nvptx/nvptx.md
===
--- config/nvptx/nvptx.md	(revision 225008)
+++ config/nvptx/nvptx.md	(working copy)
@@ -197,20 +197,17 @@
 (define_predicate "call_operation"
   (match_code "parallel")
 {
-  unsigned i;
+  int i;
 
   for (i = 1; i < XVECLEN (op, 0); i++)
 {
   rtx elt = XVECEXP (op, 0, i);
-  enum machine_mode mode;
-  unsigned regno;
 
   if (GET_CODE (elt) != USE
   || GET_CODE (XEXP (elt, 0)) != REG
   || XEXP (elt, 0) == frame_pointer_rtx
   || XEXP (elt, 0) == arg_pointer_rtx
   || XEXP (elt, 0) == stack_pointer_rtx)
-
 return false;
 }
   return true;


[gomp4] openacc id builtin

2015-06-26 Thread Nathan Sidwell
I discovered a latent bug in the openacc thread id builtin and associated 
unspec.  They should not be treated as constant functions, because that causes 
the compiler to consider them constant across threads.  Which of course they are 
not.


Applied to gomp4 branch

nathan
2015-06-26  Nathan Sidwell  

	* config/nvptx/nvptx.md (UNSPEC_ID): Rename to ...
	(UNSPECV_ID): ... here.
	(oacc_id): Make volatile.
	* omp-builtins.def (BUILT_IN_GOACC_ID): Not a constant function.

@@ -2802,3 +2809,8 @@ Copyright (C) 2013-2015 Free Software Fo
 Copying and distribution of this file, with or without modification,
 are permitted in any medium without royalty provided the copyright
 notice and this notice are preserved.
+
+Local Variables:
+mode: change-log
+change-log-default-name: "ChangeLog.gomp"
+End:
Index: config/nvptx/nvptx.md
===
--- config/nvptx/nvptx.md	(revision 224987)
+++ config/nvptx/nvptx.md	(working copy)
@@ -50,7 +50,6 @@
UNSPEC_ALLOCA
 
UNSPEC_NID
-   UNSPEC_ID
 
UNSPEC_SHARED_DATA
 ])
@@ -61,6 +60,7 @@
UNSPECV_XCHG
UNSPECV_WARP_BCAST
UNSPECV_BARSYNC
+   UNSPECV_ID
 ])
 
 (define_attr "subregs_ok" "false,true"
@@ -1313,7 +1313,8 @@
 
 (define_insn "oacc_id"
   [(set (match_operand:SI 0 "nvptx_register_operand" "")
-	(unspec:SI [(match_operand:SI 1 "const_int_operand" "")] UNSPEC_ID))]
+	(unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "")]
+			UNSPECV_ID))]
   ""
 {
   static const char *const asms[] =
Index: omp-builtins.def
===
--- omp-builtins.def	(revision 224987)
+++ omp-builtins.def	(working copy)
@@ -62,7 +62,7 @@ DEF_GOACC_BUILTIN (BUILT_IN_GOACC_WAIT,
 		   BT_FN_VOID_INT_INT_VAR,
 		   ATTR_NOTHROW_LIST)
 DEF_GOACC_BUILTIN (BUILT_IN_GOACC_ID, "GOACC_id",
-		   BT_FN_UINT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST)
+		   BT_FN_UINT_UINT, ATTR_NOTHROW_LEAF_LIST)
 DEF_GOACC_BUILTIN (BUILT_IN_GOACC_NID, "GOACC_nid",
 		   BT_FN_UINT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_GOACC_BUILTIN (BUILT_IN_GOACC_GET_GANGLOCAL_PTR, "GOACC_get_ganglocal_ptr",


Re: [Patch AArch64 1/4] Define candidates for instruction fusion in a .def file

2015-06-26 Thread Marcus Shawcroft
On 23 June 2015 at 09:49, James Greenhalgh  wrote:
>
> Hi,
>
> This patch moves the instruction fusion pairs from a set of #defines
> to an enum which we can generate from a .def file.
>
> We'll use that .def file again, and the friendly names it introduces
> shortly.
>
> OK?
>
> Thanks,
> James
>
> ---
> 2015-06-23  James Greenhalgh  
>
> * config/aarch64/aarch64-fusion-pairs.def: New.
> * config/aarch64/aarch64-protos.h (aarch64_fusion_pairs): New.
> * config/aarch64/aarch64.c (AARCH64_FUSE_NOTHING): Move to
> aarch64_fusion_pairs.
> (AARCH64_FUSE_MOV_MOVK): Likewise.
> (AARCH64_FUSE_ADRP_ADD): Likewise.
> (AARCH64_FUSE_MOVK_MOVK): Likewise.
> (AARCH64_FUSE_ADRP_LDR): Likewise.
> (AARCH64_FUSE_CMP_BRANCH): Likewise.
>

OK /Marcus


Re: [Patch AArch64 2/4] Control the FMA steering pass in tuning structures rather than as core property

2015-06-26 Thread Marcus Shawcroft
On 23 June 2015 at 09:49, James Greenhalgh  wrote:
>
> Hi,
>
> The FMA steering pass should be enabled through the tuning structures
> rather than be an intrinsic property of the core.  This patch moves
> the control of the pass to the tuning structures - turning it off for
> everything other than a Cortex-A57 system (i.e. -mcpu=cortex-a57
> or -mcpu=cortex-a57.cortex-a53).
>
> Some CPU's share the cortexa57 tuning structs, but do not use this
> steering pass. For those I've taken a copy of the cortexa57 tuning
> structures and called it cortexa72.
>
> Tested with a compiler build and all known values of -mcpu to make sure
> the pass runs in the expected configurations.
>
> OK?
>
> Thanks,
> James
>
> ---
> 2015-06-23  James Greenhalgh  
>
> * config/aarch64/aarch64.h (AARCH64_FL_USE_FMA_STEERING_PASS): Delete.
> (aarch64_tune_flags): Likewise.
> (AARCH64_TUNE_FMA_STEERING): Likewise.
> * config/aarch64/aarch64-cores.def (cortex-a57): Remove reference
> to AARCH64_FL_USE_FMA_STEERING_PASS.
> (cortex-a57.cortex-a53): Likewise.
> (cortex-a72): Use cortexa72_tunings.
> (cortex-a72.cortex-a53): Likewise.
> (exynos-m1): Likewise.
> * config/aarch64/aarch64-protos.h (tune_params): Add
> a field: extra_tuning_flags.
> * config/aarch64/aarch64-tuning-flags.def: New.
> * config/aarch64/aarch64-protos.h (AARCH64_EXTRA_TUNING_OPTION): New.
> (aarch64_extra_tuning_flags): Likewise.
> (aarch64_tune_params): Declare here.
> * config/aarch64/aarch64.c (generic_tunings): Set extra_tuning_flags.
> (cortexa53_tunings): Likewise.
> (cortexa57_tunings): Likewise.
> (thunderx_tunings): Likewise.
> (xgene1_tunings): Likewise.
> (cortexa72_tunings): New.
> * config/aarch64/cortex-a57-fma-steering.c: Include aarch64-protos.h.
>  (gate): Check against aarch64_tune_params.
> * config/aarch64/t-aarch64 (cortex-a57-fma-steering.o): Depend on
> aarch64-protos.h.
>

OK /Marcus


Re: [Patch AArch64 3/4] De-const-ify struct tune_params

2015-06-26 Thread Marcus Shawcroft
On 23 June 2015 at 09:49, James Greenhalgh  wrote:
>
> Hi,
>
> If we want to overwrite parts of this structure, we're going to need it
> to be more malleable than it is presently.
>
> Run through and remove const from each of the members, create a non-const
> tuning structure we can modify, and set aarch64_tune_params to always
> point to this new structure. Change the -mtune parsing code to take a
> copy of the tuning structure in use rather than just taking the
> reference from within the processor struct. Change all the current
> users of aarch64_tune_params which no longer need to dereference a
> pointer.
>
> Checked on aarch64-none-linux-gnueabi with no issues.
>
> OK?
>
> Thanks,
> James
>
> ---
> 2015-06-23  James Greenhalgh  
>
> * config/aarch64/aarch64-protos.h (tune_params): Remove
> const from members.
> (aarch64_tune_params): Remove const, change to no longer be
> a pointer.
> * config/aarch64/aarch64.c (aarch64_tune_params): Remove const,
> change to no longer be a pointer, initialize to generic_tunings.
> (aarch64_min_divisions_for_recip_mul): Change dereference of
> aarch64_tune_params to member access.
> (aarch64_reassociation_width): Likewise.
> (aarch64_rtx_mult_cost): Likewise.
> (aarch64_address_cost): Likewise.
> (aarch64_branch_cost): Likewise.
> (aarch64_rtx_costs): Likewise.
> (aarch64_register_move_cost): Likewise.
> (aarch64_memory_move_cost): Likewise.
> (aarch64_sched_issue_rate): Likewise.
> (aarch64_builtin_vectorization_cost): Likewise.
> (aarch64_override_options): Take a copy of the selected tuning
> struct in to aarch64_tune_params, rather than just setting
> a pointer, change dereferences of aarch64_tune_params to member
> accesses.
> (aarch64_override_options_after_change): Change dereferences of
> aarch64_tune_params to member access.
> (aarch64_macro_fusion_p): Likewise.
> (aarch_macro_fusion_pair_p): Likewise.
> * config/aarch64/cortex-a57-fma-steering.c (gate): Likewise.
>

OK
/Marcus


Re: [Patch AArch64 4/4] Add -moverride tuning command, and wire it up for control of fusion and fma-steering

2015-06-26 Thread Marcus Shawcroft
On 23 June 2015 at 09:49, James Greenhalgh  wrote:
>
> Hi,
>
> This final patch adds support for the new command line option
> "-moverride". The purpose of this command line is to allow expert-level users
> of the compiler, and those comfortable with experimenting with the compiler,
> *unsupported* full access to the tuning structures used in the AArch64
> back-end.
>
> For now, we only enable command-line access to the fusion pairs to
> enable and whether or not to use the Cortex-A57 FMA register renaming
> pass. Though in future we can expand this further.
>
> With this patch, you might write something like:
>
>   -moverride=fuse=adrp+add.cmp+branch:tune=rename_fma_regs
>
> To enable fusion of adrp+add and cmp+branch and to enable the
> fma-rename pass.
>
> I've bootstrapped and tested the patch set on aarch64-none-linux-gnu
> with BOOT_CFLAGS set to the example string above, and again in the
> standard configuration with no issues.
>
> OK?
>
> Thanks,
> James
>
> ---
> 2015-06-23  James Greenhalgh  
>
> * config/aarch64/aarch64.opt: (override): New.
> * doc/invoke.texi (override): Document.
> * config/aarch64/aarch64.c (aarch64_flag_desc): New
> (aarch64_fusible_pairs): Likewise.
> (aarch64_tuning_flags): Likewise.
> (aarch64_tuning_override_function): Likewise.
> (aarch64_tuning_override_functions): Likewise.
> (aarch64_parse_one_option_token): Likewise.
> (aarch64_parse_boolean_options): Likewise.
> (aarch64_parse_fuse_string): Likewise.
> (aarch64_parse_tune_string): Likewise.
> (aarch64_parse_one_override_token): Likewise.
> (aarch64_parse_override_string): Likewise.
> (aarch64_override_options): Parse the -override string if it
> is present.
>

+static const struct aarch64_tuning_override_function
+  aarch64_tuning_override_functions[] =

The indentation looks odd here, but otherwise OK /Marcus


Re: [AArch64][2/2] Implement -fpic for -mcmodel=small

2015-06-26 Thread Marcus Shawcroft
On 26 June 2015 at 10:32, Jiong Wang  wrote:
>
> This patch respin https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01804.html.
>
> A new symbol classification "SYMBOL_SMALL_GOT_28K" added to represent symbol
> which needs go through GOT table and it's under -fpic/-mcmodel-small. the 
> "_28K"
> suffix can reflect the symbol's attribute better, and by introducing this new
> symbol type, we could avoid checking aarch64_cmodel at some extent
> though still needs the check somewhere.
>
> All other code logic not changed.
>
> OK for trunk?
>
> Thanks.
>
> 2015-06-26  Jiong. Wang  
>
> gcc/
>   * config/aarch64/aarch64-protos.h (aarch64_symbol_type): New type
>   SYMBOL_SMALL_GOT_28K.
>   * config/aarch64/aarch64.md: (ldr_got_small_): Support new GOT
>   relocation modifiers.
>   (unspec): New enum "UNSPEC_GOTMALLPIC28K.
>   (ldr_got_small_28k_): New.
>   (ldr_got_small_28k_sidi): New.
>   * config/aarch64/iterators.md (got_modifier): New mode iterator.
>   * config/aarch64/aarch64-otps.h (aarch64_code_model): New model.
>   * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Support
>   SYMBOL_SMALL_GOT_28K.
>   (aarch64_rtx_costs): Add costs for new instruction sequences.
>   (initialize_aarch64_code_model): Initialize new model.
>   (aarch64_classify_symbol): Recognize new model and new symbol 
> classification.
>   (aarch64_asm_preferred_eh_data_format): Support new model.
>   (aarch64_load_symref_appropriately): Generate new instruction
>   sequences for -fpic.
>   (TARGET_USE_PSEUDO_PIC_REG): New definition.
>   (aarch64_use_pseudo_pic_reg): New function.
>
> gcc/testsuite/
>   * gcc.target/aarch64/pic-small.c: New testcase.


OK, Thanks Jiong.  Could you prepare a NEWS entry for this change?
Cheers
/Marcus


Re: [AArch64][1/2] Rename SYMBOL_SMALL_GOT to SYMBOL_SMALL_GOT_4G

2015-06-26 Thread Marcus Shawcroft
On 26 June 2015 at 10:23, Jiong Wang  wrote:

> OK. Reworked this patch. Removed those redundant memory model check by
> adding new symbol classification. Patch splitted into two:
>
>   * [1/2] Rename SYMBOL_SMALL_GOT to SYMBOL_SMALL_GOT_4G
>   * [2/2] Implement -fpic for -mcmodel=small
>
> This is the first patch which only renmae SYMBOL_SMALL_GOT into
> SYMBOL_SMALL_GOT_4G. Please review, Thanks.
>
> 2015-06-26  Jiong Wang  
>
> gcc/
>   * config/aarch64/aarch64-protos.h (aarch64_symbol_type): Rename
>   SYMBOL_SMALL_GOT to SYMBOL_SMALL_GOT_4G.
>   * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Ditto.
>   (aarch64_expand_mov_immediate): Ditto.
>   (aarch64_print_operand): Ditto.
>   (aarch64_classify_symbol): Ditto.
>

OK, thanks Jiong.  /Marcus


[gomp4.1] Add support for non-static data member iterators

2015-06-26 Thread Jakub Jelinek
Hi!

As private/lastprivate/linear clauses now allow non-static data members
in C++, it (unfortunately) means that also the iterator variables
of distribute/for/simd/taskloop loops can be non-static data members.

This patch implements it; tested on x86_64-linux, committed to
gomp-4_1-branch.

2015-06-26  Jakub Jelinek  

* gimplify.c (enum omp_region_type): Add ORT_NONE.
(gimplify_bind_expr, omp_firstprivatize_variable,
omp_add_variable, omp_notice_variable): Handle ORT_NONE.
(gimplify_omp_for): For OMP_FOR_PRE_BODY of taskloop,
temporarily switch on ORT_NONE gimplify_omp_ctxp
if it is NULL.
gcc/cp/
* cp-tree.h (push_omp_privatization_clauses): Add bool
argument.
(omp_privatize_field): New prototype.
* parser.c (cp_parser_omp_for_incr): For processing_template_decl
use cp_tree_equals.
(cp_parser_omp_for_loop_init): Change return type to tree,
handle non-static data member iterators, return decl to
add to private clause if one should be added.
(cp_parser_omp_for_loop): Adjust caller.  For OMP_SIMD,
add OMP_CLAUSE_LINEAR or OMP_CLAUSE_LASTPRIVATE instead of
OMP_CLAUSE_PRIVATE.  Handle NULL TREE_TYPE as non-pointer.
(cp_parser_pragma): Adjust push_omp_privatization_clauses callers.
* pt.c (tsubst_omp_clauses): If there is a single OMP_CLAUSE_LINEAR
with NULL OMP_CLAUSE_LINEAR_STEP, make sure it is NULL even after
finish_omp_clauses.
(omp_parallel_combined_clauses): New variable.
(tsubst_omp_for_iterator): Handle non-static data members,
for combined parallel for move lastprivate clause from parallel
to for and avoid making already private iterator private again.
(tsubst_expr): Adjust push_omp_privatization_clauses callers.
For OMP_PARALLEL with OMP_PARALLEL_COMBINED temporarily set
omp_parallel_combined_clauses and clear it in OMP_FOR
and OMP_SECTIONS.
(instantiate_decl): Call save_omp_privatization_clauses
and restore_omp_privatization_clauses if nested.
(dependent_omp_for_p): Return true even if the iterator
is non-type dependent SCOPE_REF.
* semantics.c (omp_private_member_ignore_next): New variable.
(omp_privatize_field): No longer static.
(push_omp_privatization_clauses): Add ignore_next argument.
Set omp_private_member_ignore_next to it, return NULL early
if omp_private_member_ignore_next was set before.
(pop_omp_privatization_clauses): Do nothing if stmt is NULL.
(save_omp_privatization_clauses): Save also
omp_private_member_ignore_next flag in the vector.
(restore_omp_privatization_clauses): And restore it.
(finish_omp_for): For OMP_SIMD, fill in OMP_CLAUSE_LINEAR_STEP
for the iterator if NULL.
libgomp/
* testsuite/libgomp.c++/member-1.C: Remove dg-options.
* testsuite/libgomp.c++/member-2.C: Remove dg-options.
* testsuite/libgomp.c++/member-3.C: New test.
* testsuite/libgomp.c++/member-4.C: New test.
* testsuite/libgomp.c++/member-5.C: New test.

--- gcc/gimplify.c.jj   2015-06-24 12:04:02.0 +0200
+++ gcc/gimplify.c  2015-06-25 19:14:25.994242855 +0200
@@ -121,7 +121,10 @@ enum omp_region_type
   /* Data region.  */
   ORT_TARGET_DATA = 16,
   /* Data region with offloading.  */
-  ORT_TARGET = 32
+  ORT_TARGET = 32,
+  /* Dummy OpenMP region, used to disable expansion of
+ DECL_VALUE_EXPRs in taskloop pre body.  */
+  ORT_NONE = 64
 };
 
 /* Gimplify hashtable helper.  */
@@ -1083,7 +1086,7 @@ gimplify_bind_expr (tree *expr_p, gimple
  struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp;
 
  /* Mark variable as local.  */
- if (ctx && !DECL_EXTERNAL (t)
+ if (ctx && ctx->region_type != ORT_NONE && !DECL_EXTERNAL (t)
  && (! DECL_SEEN_IN_BIND_EXPR_P (t)
  || splay_tree_lookup (ctx->variables,
(splay_tree_key) t) == NULL))
@@ -5554,7 +5557,7 @@ omp_firstprivatize_variable (struct gimp
 {
   splay_tree_node n;
 
-  if (decl == NULL || !DECL_P (decl))
+  if (decl == NULL || !DECL_P (decl) || ctx->region_type == ORT_NONE)
 return;
 
   do
@@ -5646,7 +5649,7 @@ omp_add_variable (struct gimplify_omp_ct
   unsigned int nflags;
   tree t;
 
-  if (error_operand_p (decl))
+  if (error_operand_p (decl) || ctx->region_type == ORT_NONE)
 return;
 
   /* Never elide decls whose type has TREE_ADDRESSABLE set.  This means
@@ -5799,6 +5802,9 @@ omp_notice_variable (struct gimplify_omp
   if (error_operand_p (decl))
 return false;
 
+  if (ctx->region_type == ORT_NONE)
+return lang_hooks.decls.omp_disregard_value_expr (decl, false);
+
   /* Threadprivate variables are predetermined.  */
   if (is_global_var (decl))
 {
@@ -7195,7 +7201,20 @@ gimplify_omp_for (tree *expr_p, gimple_s
}
  

Re: [12/12] Simplify uses of hash_map

2015-06-26 Thread Rainer Orth
Jeff Law  writes:

> On 06/23/2015 08:57 AM, Richard Sandiford wrote:
>> At this point all hash_map traits know what kind of key they're
>> dealing with, so we can make that a traits typedef, like it is for
>> hash_table traits.  Then, if we make the default hash traits for
>> T be T, we can use hash_table-style traits as the first template
>> parameter to hash_map, without the need for a third.  That is, if
>> foo_hash hashes elements of type foo_type:
>>
>>typedef simple_hashmap_traits  foo_traits;
>>hash_map  x;
>>
>> becomes just:
>>
>>hash_map  x;
>>
>> just like a hash_table of foo_types would be:
>>
>>hash_table  y;
>>
>> This patch makes that simplification.
>>
>>
>> gcc/
>>  * hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
>>  (unbounded_int_hashmap_traits::key_type): Likewise.
>>  * hash-map.h (hash_map): Get the key type from the traits.
>>  * hash-traits.h (default_hash_traits): By default, inherit from the
>>  template parameter.
>>  * alias.c (alias_set_traits): Delete.
>>  (alias_set_entry_d::children): Use alias_set_hash as the first
>>  template parameter.
>>  (record_alias_subset): Update accordingly.
>>  * except.c (tree_hash_traits): Delete.
>>  (type_to_runtime_map): Use tree_hash as the first template parameter.
>>  (init_eh): Update accordingly.
>>  * genmatch.c (capture_id_map_hasher): Delete.
>>  (cid_map_t): Use nofree_string_hash as first template parameter.
>>  * ipa-icf.h (symbol_compare_hashmap_traits): Delete.
>>  * ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
>>  Use symbol_compare_hash as the first template parameter in
>>  subdivide_hash_map.
>>  * mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
>>  (mem_usage_pair::mem_map_t): Use mem_location_hash as the first
>>  template parameter.
>>  * passes.c (pass_registry_hasher): Delete.
>>  (name_to_pass_map): Use nofree_string_hash as the first template
>>  parameter.
>>  (register_pass_name): Update accordingly.
>>  * sanopt.c (sanopt_tree_map_traits): Delete.
>>  (sanopt_tree_triplet_map_traits): Delete.
>>  (sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
>>  template parameter.
>>  (sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
>>  the first template parameter.
>>  * sese.c (rename_map_hasher): Delete.
>>  (rename_map_type): Use tree_ssa_name_hash as the first template
>>  parameter.
>>  * symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
>>  (function_summary::m_map): Use map_hash as the first template
>>  parameter.
>>  (function_summary::release): Update accordingly.
>>  * tree-if-conv.c (phi_args_hash_traits): Delete.
>>  (predicate_scalar_phi): Use tree_operand_hash as the first template
>>  parameter to phi_arg_map.
>>  * tree-inline.h (dependence_hasher): Delete.
>>  (copy_body_data::dependence_map): Use dependence_hash as the first
>>  template parameter.
>>  * tree-inline.c (remap_dependence_clique): Update accordingly.
>>  * tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
>>  (decl_to_stridxlist_htab): Use tree_decl_hash as the first template
>>  parameter.
>>  (addr_stridxptr): Update accordingly.
>>  * value-prof.c (profile_id_traits): Delete.
>>  (cgraph_node_map): Use profile_id_hash as the first template
>>  parameter.
>>  (init_node_map): Update accordingly.
>>  * config/alpha/alpha.c (string_traits): Delete.
>>  (machine_function::links): Use nofree_string_hash as the first
>>  template parameter.
>>  (alpha_use_linkage, alpha_write_linkage): Update accordingly.
>>  * config/m32c/m32c.c (pragma_traits): Delete.
>>  (pragma_htab): Use nofree_string_hash as the first template parameter.
>>  (m32c_note_pragma_address): Update accordingly.
>>  * config/mep/mep.c (pragma_traits): Delete.
>>  (pragma_htab): Use nofree_string_hash as the first template parameter.
>>  (mep_note_pragma_flag): Update accordingly.
>>  * config/mips/mips.c (mips16_flip_traits): Delete.
>>  (mflip_mips16_htab): Use nofree_string_hash as the first template
>>  parameter.
>>  (mflip_mips16_use_mips16_p): Update accordingly.
>>  (local_alias_traits): Delete.
>>  (mips16_local_aliases): Use nofree_string_hash as the first template
>>  parameter.
>>  (mips16_local_alias): Update accordingly.
> Phew.  OK.

According to a reghunt, this patch broke bootstrap (at least with g++
4.7 as bootstrap compiler):

/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c: In function 'void 
build_wrapper_type(wrapper_data*)':
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:436:77: error: no matching 
function for call to 'hash_map::traverse(auto_vec*)'
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:436:77: note: candidates are:
In file included from /vol/g

[AArch64/wwwdoc] Document -fpic support for small memory model

2015-06-26 Thread Jiong Wang

Marcus Shawcroft writes:

> On 26 June 2015 at 10:32, Jiong Wang  wrote:
>>
>> This patch respin https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01804.html.
>>
>> A new symbol classification "SYMBOL_SMALL_GOT_28K" added to represent symbol
>> which needs go through GOT table and it's under -fpic/-mcmodel-small. the 
>> "_28K"
>> suffix can reflect the symbol's attribute better, and by introducing this new
>> symbol type, we could avoid checking aarch64_cmodel at some extent
>> though still needs the check somewhere.
>>
>> All other code logic not changed.
>>
>> OK for trunk?
>>
>> Thanks.
>>
>> 2015-06-26  Jiong. Wang  
>>
>> gcc/
>>   * config/aarch64/aarch64-protos.h (aarch64_symbol_type): New type
>>   SYMBOL_SMALL_GOT_28K.
>>   * config/aarch64/aarch64.md: (ldr_got_small_): Support new GOT
>>   relocation modifiers.
>>   (unspec): New enum "UNSPEC_GOTMALLPIC28K.
>>   (ldr_got_small_28k_): New.
>>   (ldr_got_small_28k_sidi): New.
>>   * config/aarch64/iterators.md (got_modifier): New mode iterator.
>>   * config/aarch64/aarch64-otps.h (aarch64_code_model): New model.
>>   * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Support
>>   SYMBOL_SMALL_GOT_28K.
>>   (aarch64_rtx_costs): Add costs for new instruction sequences.
>>   (initialize_aarch64_code_model): Initialize new model.
>>   (aarch64_classify_symbol): Recognize new model and new symbol 
>> classification.
>>   (aarch64_asm_preferred_eh_data_format): Support new model.
>>   (aarch64_load_symref_appropriately): Generate new instruction
>>   sequences for -fpic.
>>   (TARGET_USE_PSEUDO_PIC_REG): New definition.
>>   (aarch64_use_pseudo_pic_reg): New function.
>>
>> gcc/testsuite/
>>   * gcc.target/aarch64/pic-small.c: New testcase.
>
>
> OK, Thanks Jiong.  Could you prepare a NEWS entry for this change?
> Cheers
> /Marcus

How about this one?

2015-06-26  Jiong Wang  

wwwdocs/
  * htdocs/gcc-6/changes.html (AArch64): Document -fpic for small model.

Index: gcc-6/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-6/changes.html,v
retrieving revision 1.12
diff -u -r1.12 changes.html
--- gcc-6/changes.html	16 Jun 2015 08:48:02 -	1.12
+++ gcc-6/changes.html	26 Jun 2015 13:30:05 -
@@ -90,6 +90,15 @@
If GCC is unable to detect the host CPU these options have no effect.
  

+   
+ 
+   -fpic is now supported on AArch64 for small memory
+   model.  Compared with -fPIC, -fpic
+   will guide GCC to generate more efficient position independent
+   instruction sequences when accessing global objects and
+   28KiB/15KiB global offset table size supported under ILP64/32.
+ 
+   
 
 
 


[hsa] C++ification of operands and instructions

2015-06-26 Thread Martin Jambor
Hello,

the following patch provides constructors and operators new for
(almost) all classes representing operands, instructions and
basic-blocks in HSA.  

There were three reasons for this.  First and foremost, some classes
already contained auto_vec fields which meant they had constructors,
which however were not properly invoked.  Even if they were, many of
them were memset to zero after allocation, which surprisingly worked
but certainly was not correct and was susceptible to weird breakage in
future.  Second, we needed to allow more operands than the statically
allocated five for phi-nodes and I wanted to use an auto_vec for that
as well.  Finally, it just makes sense to use the standard C++
concepts as much as possible in completely new code and, to my best
knowledge this is it.

The patch relies on the fact that the pool allocator does not invoke
placement new, which would construct the object twice if it did not
fail because I made many default constructors private.  Martin already
has another allocator-pool patch in the works that will provide
untyped allocators for these types of usage.  I will merge from trunk
again after these get in.

Finally, the auto_vecs in code reference operands mean that hsa_cfun
gets constructors and destructors, which is undesirable for statically
allocated object, so I made it a pointer to a dynamically allocated
ones.

I have committed the patch after standard testing so that Martin can
re-base his work now.  I will post a followup which will change how we
do some necessary destruction of the HSAIL representation soon.

Thanks,

Martin


2015-06-26  Martin Jambor  

* hsa.h (hsa_bb): Made a class with constructors, destructor and a
new operator.
(hsa_function_representation): Turned into a class, added
constructor and destructor.
(hsa_cfun): Turned into a pointer update all users.

* hsa-gen.c (hsa_bb::hsa_bb): New.
(hsa_bb::operator new): Likewise.
(hsa_bb::~hsa_bb): Likewise.
(hsa_deinit_data_for_cfun): Call destructor.

2015-06-26  Martin Jambor  

* hsa.h (hsa_insn_basic): Use class keyword, added constructors and
new operator, operands turned into a vector.
(hsa_insn_phi): Use class keyword, added a constructor and new
operator.
(hsa_insn_br): Likewise.
(hsa_insn_cmp): Likewise.
(hsa_insn_mem): Likewise.
(hsa_insn_atomic): Likewise.
(hsa_insn_seg): Likewise.
(hsa_insn_addr): Removed, converted all users to use hsa_insn_basic.
(hsa_insn_call): Use class keyword, added a constructor and new
operator.
(hsa_insn_call_block): Likewise.
* hsa-gen.c (hsa_insn_basic::hsa_insn_basic): New.
(hsa_insn_basic::operator new) Likewise.
(hsa_alloc_basic_insn): Removed, turned all users into uses of
operator new.
(hsa_insn_phi::hsa_insn_phi): New.
(hsa_insn_phi::operator new): Likewise.
(gen_hsa_phi_from_gimple_phi): Use operator new.  Removed max
predecessor number limitation.
(hsa_insn_br::hsa_insn_br): New.
(hsa_insn_br::operator new): Likewise.
(hsa_build_cbr_insn): Removed, turned all users into uses of
operator new.
(hsa_insn_cmp::hsa_insn_cmp): New.
(hsa_insn_cmp::operator new): Likewise.
(hsa_alloc_cmp_insn): Removed, turned all users into uses of
operator new.
(hsa_insn_mem::hsa_insn_mem): New.
(hsa_insn_mem::operator new): Likewise.
(hsa_alloc_mem_insn): Removed, turned all users into uses of
operator new.
(hsa_insn_atomic::hsa_insn_atomic) New.
(hsa_insn_atomic::operator new): Likewise.
(hsa_alloc_atomic_insn): Removed, turned all users into uses of
operator new.
(hsa_allocp_inst_addr): Removed.
(hsa_alloc_addr_insn): Likewise.
(hsa_insn_seg::hsa_insn_seg): New.
(hsa_insn_seg::operator new): Likewise.
(hsa_alloc_seg_insn): Removed, turned all users into uses of operator
new.
(hsa_insn_call::hsa_insn_call): New.
(hsa_insn_call::operator new): Likewise.
(hsa_alloc_call_insn): Removed, turned all users into uses of operator
new.
(hsa_insn_call_block::hsa_insn_call_block): New.
(hsa_insn_call_block::operator new): Likewise.
(hsa_alloc_call_block_insn): Removed, turned all users into uses of
operator new.
* hsa-brig.c (emit_insn): Check LDA instruction according to opcode,
not class type.
(emit_cvt_insn): Use auto_vec also for operand offsets.
(emit_basic_insn): Likewise.
* hsa-dump.c (dump_hsa_insn): Check for LDA instructions based on
opcode, not class.
(dump_hsa_insn): Adjusted to use operand vector.
(dump_hsa_insn): Likewise.
* hsa-regalloc.c (naive_process_phi): Likewise.
(linear_scan_regalloc): Likewise.
(hsa

Re: [Aarch64] Expand +rdma documentation, small changes to march and mcpu text.

2015-06-26 Thread Marcus Shawcroft
On 22 June 2015 at 17:17, Matthew Wahab  wrote:
> Hello,
>
> The documentation for the ARMv8.1 +rdma option doesn't mention that enabling
> it
> also implies enabling Adv.SIMD. This patch fixes that.
>
> The documentation for the -march and -mcpu options are also a little messy,
> this
> patch tries to make the text clearer and adds a (texinfo) link to the
> subsection
> documenting the feature modifiers.
>
> Tested by checking the html output.
>
> Ok for trunk?
> Matthew
>
> 2015-06-22  Matthew Wahab  
>
> * doc/invoke.texi (Aarch64 Options, -march): Split out arch and
> feature description, split out the native option, add a link to
> the feature documentation, rearrange and slightly rewrite text.
> (Aarch64 options, -mcpu): Likewise.
> (Aarch64 options, Feature Modifiers): Add an anchor.  Mention +rdma
> implies Adv. SIMD.

OK /Marcus


Re: [AArch64][TLSLE][1/N] Rename SYMBOL_SMALL_TPREL to SYMBOL_TLSLE

2015-06-26 Thread Marcus Shawcroft
On 20 May 2015 at 11:56, Jiong Wang  wrote:

> 2015-05-19  Marcus Shawcroft  
> Jiong Wang  
>
> gcc/
>   * config/aarch64/aarch64-protos.h (arch64_symbol_type): Rename
>   SYMBOL_SMALL_TPREL to SYMBOL_TLSLE.
>   (aarch64_symbol_context): Ditto.
>   * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Ditto.
>   (aarch64_expand_mov_immediate): Ditto.
>   (aarch64_print_operand): Ditto.
>   (aarch64_classify_tls_symbol): Ditto.
> --
> Regards,
> Jiong
>

OK /Marcus


Re: [12/12] Simplify uses of hash_map

2015-06-26 Thread Richard Sandiford
Rainer Orth  writes:
> Jeff Law  writes:
>
>> On 06/23/2015 08:57 AM, Richard Sandiford wrote:
>>> At this point all hash_map traits know what kind of key they're
>>> dealing with, so we can make that a traits typedef, like it is for
>>> hash_table traits.  Then, if we make the default hash traits for
>>> T be T, we can use hash_table-style traits as the first template
>>> parameter to hash_map, without the need for a third.  That is, if
>>> foo_hash hashes elements of type foo_type:
>>>
>>>typedef simple_hashmap_traits  foo_traits;
>>>hash_map  x;
>>>
>>> becomes just:
>>>
>>>hash_map  x;
>>>
>>> just like a hash_table of foo_types would be:
>>>
>>>hash_table  y;
>>>
>>> This patch makes that simplification.
>>>
>>>
>>> gcc/
>>> * hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
>>> (unbounded_int_hashmap_traits::key_type): Likewise.
>>> * hash-map.h (hash_map): Get the key type from the traits.
>>> * hash-traits.h (default_hash_traits): By default, inherit from the
>>> template parameter.
>>> * alias.c (alias_set_traits): Delete.
>>> (alias_set_entry_d::children): Use alias_set_hash as the first
>>> template parameter.
>>> (record_alias_subset): Update accordingly.
>>> * except.c (tree_hash_traits): Delete.
>>> (type_to_runtime_map): Use tree_hash as the first template parameter.
>>> (init_eh): Update accordingly.
>>> * genmatch.c (capture_id_map_hasher): Delete.
>>> (cid_map_t): Use nofree_string_hash as first template parameter.
>>> * ipa-icf.h (symbol_compare_hashmap_traits): Delete.
>>> * ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
>>> Use symbol_compare_hash as the first template parameter in
>>> subdivide_hash_map.
>>> * mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
>>> (mem_usage_pair::mem_map_t): Use mem_location_hash as the first
>>> template parameter.
>>> * passes.c (pass_registry_hasher): Delete.
>>> (name_to_pass_map): Use nofree_string_hash as the first template
>>> parameter.
>>> (register_pass_name): Update accordingly.
>>> * sanopt.c (sanopt_tree_map_traits): Delete.
>>> (sanopt_tree_triplet_map_traits): Delete.
>>> (sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
>>> template parameter.
>>> (sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
>>> the first template parameter.
>>> * sese.c (rename_map_hasher): Delete.
>>> (rename_map_type): Use tree_ssa_name_hash as the first template
>>> parameter.
>>> * symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
>>> (function_summary::m_map): Use map_hash as the first template
>>> parameter.
>>> (function_summary::release): Update accordingly.
>>> * tree-if-conv.c (phi_args_hash_traits): Delete.
>>> (predicate_scalar_phi): Use tree_operand_hash as the first template
>>> parameter to phi_arg_map.
>>> * tree-inline.h (dependence_hasher): Delete.
>>> (copy_body_data::dependence_map): Use dependence_hash as the first
>>> template parameter.
>>> * tree-inline.c (remap_dependence_clique): Update accordingly.
>>> * tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
>>> (decl_to_stridxlist_htab): Use tree_decl_hash as the first template
>>> parameter.
>>> (addr_stridxptr): Update accordingly.
>>> * value-prof.c (profile_id_traits): Delete.
>>> (cgraph_node_map): Use profile_id_hash as the first template
>>> parameter.
>>> (init_node_map): Update accordingly.
>>> * config/alpha/alpha.c (string_traits): Delete.
>>> (machine_function::links): Use nofree_string_hash as the first
>>> template parameter.
>>> (alpha_use_linkage, alpha_write_linkage): Update accordingly.
>>> * config/m32c/m32c.c (pragma_traits): Delete.
>>> (pragma_htab): Use nofree_string_hash as the first template parameter.
>>> (m32c_note_pragma_address): Update accordingly.
>>> * config/mep/mep.c (pragma_traits): Delete.
>>> (pragma_htab): Use nofree_string_hash as the first template parameter.
>>> (mep_note_pragma_flag): Update accordingly.
>>> * config/mips/mips.c (mips16_flip_traits): Delete.
>>> (mflip_mips16_htab): Use nofree_string_hash as the first template
>>> parameter.
>>> (mflip_mips16_use_mips16_p): Update accordingly.
>>> (local_alias_traits): Delete.
>>> (mips16_local_aliases): Use nofree_string_hash as the first template
>>> parameter.
>>> (mips16_local_alias): Update accordingly.
>> Phew.  OK.
>
> According to a reghunt, this patch broke bootstrap (at least with g++
> 4.7 as bootstrap compiler):

Which target are you using?  I just tried with a gcc 4.7 host compiler
on x86_64-linux-gnu and it seemed to work.

Thanks,
Richard



Re: [AArch64][TLSLE][3/N] Add UNSPEC_TLSLE

2015-06-26 Thread Marcus Shawcroft
On 20 May 2015 at 12:21, Jiong Wang  wrote:
>
> Add new unspec name UNSPEC_TLSLE, use it for all tlsle pattern.
>
> ok for trunk?
>
> 2015-05-19  Jiong Wang  
>
> gcc/
>   * config/aarch64/aarch64.md (UNSPEC_TLSLE): New enumeration.
>   (tlsle): Use new unspec name.
>   (tlsle_): Ditto.

OK /Marcus


Re: [AArch64][TLSLE][2/N] Rename "tlsle_small" to "tlsle"

2015-06-26 Thread Marcus Shawcroft
On 20 May 2015 at 12:19, Jiong Wang  wrote:
>
> Similar to the rename from SYMBOL_SMALL_TPREL to SYMBOL_TLSLE, this
> patch rename the rtl pattern name.
>
> ok for trunk?
>
> 2015-05-19  Jiong Wang  
> gcc/
>   * config/aarch64/aarch64.md (tlsle_small): Rename to tlsle.
>   (tlsle_small_): Rename to tlsle_.
>   * config/aarc64/aarch64.c (aarch64_load_symref_appropriately): Use new
>   pattern name.

OK /Marcus


Re: fix PR46029: reimplement if conversion of loads and stores

2015-06-26 Thread Richard Biener
On June 26, 2015 2:21:22 PM GMT+02:00, Alan Lawrence  
wrote:
>Sebastian Pop wrote:
>> On Thu, Jun 25, 2015 at 4:43 AM, Richard Biener
>>  wrote:
>>> when the new scheme triggers vectorization cannot succeed on the
>>> result as we get
>>>
>>>   if (cond)
>>> *p = val;
>>>
>>> if-converted to
>>>
>>>   tem = cond ? p : &scratch;
>>>   *tem = val;
>> 
>> That's correct.
>> 
>>> and
>>>
>>>if (cond)
>>>  val = *p;
>>>
>>> if-converted to
>>>
>>>   scatch = val;
>>>   tem = cond ? p : &scratch;
>>>   val = *tem;
>> 
>> The patch does this slightly differently:
>> 
>>tem = cond ? p : &scratch;
>>val = cond ? *tem : val;
>> 
>> I think I like your version better as it has only one cond_expr.
>
>Another slight concern...by reusing scratchpad's, are we at risk of
>creating 
>lots of false dependencies here, that restrict instruction scheduling /
>other 
>opts later?

Another possibility is to not share them and make sure to insert clobbers for 
them when they become dead so later stack slot sharing can merge them again.

Richard.

>>> [...]
>>> and thus the store and loads appear as scather/gather ones to
>>> the vectorizer (if-conversion could directly generate masked
>>> load/stores of course and not use a scratch-pad at all in that
>case).
>
>Thank you Richard for much better expressing what I was thinking here
>too :)
>
>> Abe also suggested to continue optimizing the other way in cases
>> where we know to write or load from the same location on all
>branches:
>> 
>> if (c)
>>   A[i] = ...
>> else
>>   A[i] = ...
>
>The store here really should be commoned, yes.
>
>(Related but different?: BZ 56625.)
>
>
>I might add, I find this code much easier to follow than the old
>(removed) code 
>about data references, memrefs_read_unconditionally, and 
>write_memrefs_written_at_least-once...
>
>Thanks, Alan




Re: [AArch64][TLSLE][5/N] Recognize -mtls-size

2015-06-26 Thread Marcus Shawcroft
On 21 May 2015 at 17:44, Jiong Wang  wrote:
>
> This patch add -mtls-size option for AArch64. This option let user to do
> finer control on code generation for various TLS model on AArch64.
>
> For example, for TLS LE, user can specify smaller tls-size, for example
> 4K which is quite usual, to let AArch64 backend generate more efficient
> instruction sequences.
>
> Currently, -mtls-size accept all integer, then will translate it into
> 12(4K), 24(16M), 32(4G), 48(256TB) based on the value.
>
> no functional change.
>
> ok for trunk?
>
> 2015-05-20  Jiong Wang  
>
> gcc/
>   * config/aarch64/aarch64.opt (mtls-size): New entry.
>   * config/aarch64/aarch64.c (initialize_aarch64_tls_size): New function.
>   * doc/invoke.texi (AArch64 Options): Document -mtls-size.

+mtls-size=
+Target RejectNegative Joined UInteger Var(aarch64_tls_size) Init(24)
+Specifies size of the TLS data area, default size is 16M. Accept any
integer, but the value
+will be transformed into 12(4K), 24(16M), 32(4G), 48(256TB)
+

Can we follow the mechanism used by rs6000 and limit the accepted
values here using an Enum to just the valid values: 12, 24, 32, 48?

+@item -mtls-size=@var{size}
+@opindex mtls-size
+Specify the size of TLS area. You can specify smaller value to get better code
+generation for TLS variable access. Currently, we accept any integer, but will
+turn them into 12(4K), 24(16M), 32(4G), 48(256TB) according to the integer
+value.
+

How about:
"Specify bit size of immediate TLS offsets.  Valid values are 12, 24, 32, 48."

Thanks
/Marcus


Re: [12/12] Simplify uses of hash_map

2015-06-26 Thread Rainer Orth
Richard Sandiford  writes:

> Rainer Orth  writes:
>> Jeff Law  writes:
>>
>>> On 06/23/2015 08:57 AM, Richard Sandiford wrote:
 At this point all hash_map traits know what kind of key they're
 dealing with, so we can make that a traits typedef, like it is for
 hash_table traits.  Then, if we make the default hash traits for
 T be T, we can use hash_table-style traits as the first template
 parameter to hash_map, without the need for a third.  That is, if
 foo_hash hashes elements of type foo_type:

typedef simple_hashmap_traits  foo_traits;
hash_map  x;

 becomes just:

hash_map  x;

 just like a hash_table of foo_types would be:

hash_table  y;

 This patch makes that simplification.


 gcc/
* hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
(unbounded_int_hashmap_traits::key_type): Likewise.
* hash-map.h (hash_map): Get the key type from the traits.
* hash-traits.h (default_hash_traits): By default, inherit from the
template parameter.
* alias.c (alias_set_traits): Delete.
(alias_set_entry_d::children): Use alias_set_hash as the first
template parameter.
(record_alias_subset): Update accordingly.
* except.c (tree_hash_traits): Delete.
(type_to_runtime_map): Use tree_hash as the first template parameter.
(init_eh): Update accordingly.
* genmatch.c (capture_id_map_hasher): Delete.
(cid_map_t): Use nofree_string_hash as first template parameter.
* ipa-icf.h (symbol_compare_hashmap_traits): Delete.
* ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
Use symbol_compare_hash as the first template parameter in
subdivide_hash_map.
* mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
(mem_usage_pair::mem_map_t): Use mem_location_hash as the first
template parameter.
* passes.c (pass_registry_hasher): Delete.
(name_to_pass_map): Use nofree_string_hash as the first template
parameter.
(register_pass_name): Update accordingly.
* sanopt.c (sanopt_tree_map_traits): Delete.
(sanopt_tree_triplet_map_traits): Delete.
(sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
template parameter.
(sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
the first template parameter.
* sese.c (rename_map_hasher): Delete.
(rename_map_type): Use tree_ssa_name_hash as the first template
parameter.
* symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
(function_summary::m_map): Use map_hash as the first template
parameter.
(function_summary::release): Update accordingly.
* tree-if-conv.c (phi_args_hash_traits): Delete.
(predicate_scalar_phi): Use tree_operand_hash as the first template
parameter to phi_arg_map.
* tree-inline.h (dependence_hasher): Delete.
(copy_body_data::dependence_map): Use dependence_hash as the first
template parameter.
* tree-inline.c (remap_dependence_clique): Update accordingly.
* tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
(decl_to_stridxlist_htab): Use tree_decl_hash as the first template
parameter.
(addr_stridxptr): Update accordingly.
* value-prof.c (profile_id_traits): Delete.
(cgraph_node_map): Use profile_id_hash as the first template
parameter.
(init_node_map): Update accordingly.
* config/alpha/alpha.c (string_traits): Delete.
(machine_function::links): Use nofree_string_hash as the first
template parameter.
(alpha_use_linkage, alpha_write_linkage): Update accordingly.
* config/m32c/m32c.c (pragma_traits): Delete.
(pragma_htab): Use nofree_string_hash as the first template parameter.
(m32c_note_pragma_address): Update accordingly.
* config/mep/mep.c (pragma_traits): Delete.
(pragma_htab): Use nofree_string_hash as the first template parameter.
(mep_note_pragma_flag): Update accordingly.
* config/mips/mips.c (mips16_flip_traits): Delete.
(mflip_mips16_htab): Use nofree_string_hash as the first template
parameter.
(mflip_mips16_use_mips16_p): Update accordingly.
(local_alias_traits): Delete.
(mips16_local_aliases): Use nofree_string_hash as the first template
parameter.
(mips16_local_alias): Update accordingly.
>>> Phew.  OK.
>>
>> According to a reghunt, this patch broke bootstrap (at least with g++
>> 4.7 as bootstrap compiler):
>
> Which target are you using?  I just tried with a gcc 4.7 host compiler
> on x86_64-linux-gnu and it seemed to work.

I see it on i386-pc-solaris2.1[01] and sparc-sun-solaris2.1[01].

gcc 4.9 works there, though.

Rai

Re: [AArch64][TLSLE][N/N] Implement local executable mode for all memory model

2015-06-26 Thread Marcus Shawcroft
On 21 May 2015 at 17:49, Jiong Wang  wrote:

> 2015-05-14  Jiong Wang  
> gcc/
>   * config/aarch64/aarch64.c (aarch64_print_operand): Support tls_size.
>   * config/aarch64/aarch64.md (tlsle): Choose proper instruction
>   sequences.
>   (tlsle_): New define_insn.
>   (tlsle_movsym_): Ditto.
>   * config/aarch64/constraints.md (Uta): New constraint.
>   (Utb): Ditto.
>   (Utc): Ditto.
>   (Utd): Ditto.
>
> gcc/testsuite/
>   * gcc.target/aarch64/tlsle.c: New test source.
>   * gcc.target/aarch64/tlsle12.c: New testcase.
>   * gcc.target/aarch64/tlsle24.c: New testcase.
>   * gcc.target/aarch64/tlsle32.c: New testcase.
>


  case SYMBOL_TLSLE:
-  asm_fprintf (asm_out_file, ":tprel_lo12_nc:");
+  if (aarch64_tls_size <= 12)
+/* Make sure TLS offset fit into 12bit.  */
+asm_fprintf (asm_out_file, ":tprel_lo12:");
+  else
+asm_fprintf (asm_out_file, ":tprel_lo12_nc:");
   break;

Use the existing classify_symbol mechanism we use throughout the
aarch64 backend.  Specifically rename SYMBOL_TLSLE as SYMBOL_TLSLE24
and introduce the 3 missing flavours then use the symbol
classification to control behaviour such as this modifier selection.

Cheers
/Marcus


Re: [12/12] Simplify uses of hash_map

2015-06-26 Thread Mikhail Maltsev
On 06/26/2015 04:37 PM, Rainer Orth wrote:
> /vol/gcc/src/hg/trunk/local/gcc/hash-map.h:173:8: note: template bool (* f)(tree_node*&, tree_node* const&, Arg)> void hash_map::traverse(Arg) 
> const [with Arg = Arg; bool (* f)(typename Traits::key_type&, const Value&, 
> Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = 
> simple_hashmap_traits >]
> /vol/gcc/src/hg/trunk/local/gcc/hash-map.h:173:8: note:   template argument 
> deduction/substitution failed:
> /vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:747:76: error: could not 
> convert template argument 'fill_decls_vec' to 'bool (*)(tree_node*&, 
> tree_node* const&, auto_vec*)'
> In file included from /vol/gcc/src/hg/trunk/local/gcc/hash-table.h:553:0,
>  from /vol/gcc/src/hg/trunk/local/gcc/coretypes.h:317,
>  from /vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:25:
> /vol/gcc/src/hg/trunk/local/gcc/hash-map.h:181:8: note: template bool (* f)(tree_node*&, tree_node**, Arg)> void hash_map::traverse(Arg) const 
> [with Arg = Arg; bool (* f)(typename Traits::key_type&, Value*, Arg) = f; 
> KeyId = tree_node*; Value = tree_node*; Traits = 
> simple_hashmap_traits >]
> /vol/gcc/src/hg/trunk/local/gcc/hash-map.h:181:8: note:   template argument 
> deduction/substitution failed:
> /vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:747:76: error: could not 
> convert template argument 'fill_decls_vec' to 'bool (*)(tree_node*&, 
> tree_node**, auto_vec*)'
> make: *** [c-family/cilk.o] Error 1
> 
>   Rainer
> 

It seems that I can also reproduce this issue. The following code was
reduced from GCC r224910, genmatch.c:

$ cat ./test2.ii
template  class> class hash_table {
  typedef typename Descriptor::value_type value_type;
  template 
  void traverse(Argument);
};

template  class Allocator>
template <
typename Argument,
int (*)(typename hash_table::value_type *,
Argument)>
void hash_table::traverse(Argument) {}

It is accepted by current GCC and Clang but rejected by EDG:

$ /opt/intel/bin/icpc -V
Intel(R) C++ Intel(R) 64 Compiler XE for applications running on
Intel(R) 64, Version 15.0.3.187 Build 20150407
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.
FOR NON-COMMERCIAL USE ONLY

$ /opt/intel/bin/icpc -c ./test2.ii
./test2.ii(11): error: declaration is incompatible with function
template "void hash_table>::traverse>(Argument)" (declared at line 4)
  void hash_table::traverse(Argument) {}
  ^
compilation aborted for ./test2.ii (code 2)

-- 
Regards,
Mikhail Maltsev


Re: C PATCH to use VECTOR_TYPE_P

2015-06-26 Thread Marc Glisse

On Fri, 26 Jun 2015, Marek Polacek wrote:


-  if (TREE_CODE (TREE_TYPE (mask)) != VECTOR_TYPE
+  if (!VECTOR_TYPE_P (TREE_TYPE (mask))
  || TREE_CODE (TREE_TYPE (TREE_TYPE (mask))) != INTEGER_TYPE)


This one looks like !VECTOR_INTEGER_TYPE_P

--
Marc Glisse


[PATCH][Revised] Fix PR66509

2015-06-26 Thread Jack Howarth
  The attached revised patch adjusts the tests for the filds and fists
mnemonics to use the assembly...

filds (%ebp); fists (%ebp)

and the test for the fildq and fistq mnemonics to use the assembly...

fildq (%ebp); fistpq (%ebp)

which will assemble for both 64-bit and 32-bit mode. This is required
to avoid "ambiguous instructions require an explicit suffix" errors
from the clang-based assembler in Xcode 7. The change also has the
side-benefit of allowing the legacy GNU assembler from Xcode 6.3 or
earlier to properly detect that the filds, fists, fildq and fistq
mnemonics are available on x86_64-apple-darwin. Bootstrapped tested on
x86_64-apple-darwin14 against the Apple Inc version cctools-870, GNU
assembler version 1.38 and on x86_64-apple-darwin15 against the new
clang-based assembler.
Okay for gcc trunk?
   Jack
ps Also confirmed with 'as -32' and 'as -64' on x86_64 Fedora.


PR66509_v2.patch
Description: Binary data


Re: [12/12] Simplify uses of hash_map

2015-06-26 Thread Richard Sandiford
Rainer Orth  writes:
> Richard Sandiford  writes:
>
>> Rainer Orth  writes:
>>> Jeff Law  writes:
>>>
 On 06/23/2015 08:57 AM, Richard Sandiford wrote:
> At this point all hash_map traits know what kind of key they're
> dealing with, so we can make that a traits typedef, like it is for
> hash_table traits.  Then, if we make the default hash traits for
> T be T, we can use hash_table-style traits as the first template
> parameter to hash_map, without the need for a third.  That is, if
> foo_hash hashes elements of type foo_type:
>
>typedef simple_hashmap_traits  foo_traits;
>hash_map  x;
>
> becomes just:
>
>hash_map  x;
>
> just like a hash_table of foo_types would be:
>
>hash_table  y;
>
> This patch makes that simplification.
>
>
> gcc/
>   * hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
>   (unbounded_int_hashmap_traits::key_type): Likewise.
>   * hash-map.h (hash_map): Get the key type from the traits.
>   * hash-traits.h (default_hash_traits): By default, inherit from the
>   template parameter.
>   * alias.c (alias_set_traits): Delete.
>   (alias_set_entry_d::children): Use alias_set_hash as the first
>   template parameter.
>   (record_alias_subset): Update accordingly.
>   * except.c (tree_hash_traits): Delete.
>   (type_to_runtime_map): Use tree_hash as the first template parameter.
>   (init_eh): Update accordingly.
>   * genmatch.c (capture_id_map_hasher): Delete.
>   (cid_map_t): Use nofree_string_hash as first template parameter.
>   * ipa-icf.h (symbol_compare_hashmap_traits): Delete.
>   * ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
>   Use symbol_compare_hash as the first template parameter in
>   subdivide_hash_map.
>   * mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
>   (mem_usage_pair::mem_map_t): Use mem_location_hash as the first
>   template parameter.
>   * passes.c (pass_registry_hasher): Delete.
>   (name_to_pass_map): Use nofree_string_hash as the first template
>   parameter.
>   (register_pass_name): Update accordingly.
>   * sanopt.c (sanopt_tree_map_traits): Delete.
>   (sanopt_tree_triplet_map_traits): Delete.
>   (sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
>   template parameter.
>   (sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
>   the first template parameter.
>   * sese.c (rename_map_hasher): Delete.
>   (rename_map_type): Use tree_ssa_name_hash as the first template
>   parameter.
>   * symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
>   (function_summary::m_map): Use map_hash as the first template
>   parameter.
>   (function_summary::release): Update accordingly.
>   * tree-if-conv.c (phi_args_hash_traits): Delete.
>   (predicate_scalar_phi): Use tree_operand_hash as the first template
>   parameter to phi_arg_map.
>   * tree-inline.h (dependence_hasher): Delete.
>   (copy_body_data::dependence_map): Use dependence_hash as the first
>   template parameter.
>   * tree-inline.c (remap_dependence_clique): Update accordingly.
>   * tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
>   (decl_to_stridxlist_htab): Use tree_decl_hash as the first template
>   parameter.
>   (addr_stridxptr): Update accordingly.
>   * value-prof.c (profile_id_traits): Delete.
>   (cgraph_node_map): Use profile_id_hash as the first template
>   parameter.
>   (init_node_map): Update accordingly.
>   * config/alpha/alpha.c (string_traits): Delete.
>   (machine_function::links): Use nofree_string_hash as the first
>   template parameter.
>   (alpha_use_linkage, alpha_write_linkage): Update accordingly.
>   * config/m32c/m32c.c (pragma_traits): Delete.
>   (pragma_htab): Use nofree_string_hash as the first template parameter.
>   (m32c_note_pragma_address): Update accordingly.
>   * config/mep/mep.c (pragma_traits): Delete.
>   (pragma_htab): Use nofree_string_hash as the first template parameter.
>   (mep_note_pragma_flag): Update accordingly.
>   * config/mips/mips.c (mips16_flip_traits): Delete.
>   (mflip_mips16_htab): Use nofree_string_hash as the first template
>   parameter.
>   (mflip_mips16_use_mips16_p): Update accordingly.
>   (local_alias_traits): Delete.
>   (mips16_local_aliases): Use nofree_string_hash as the first template
>   parameter.
>   (mips16_local_alias): Update accordingly.
 Phew.  OK.
>>>
>>> According to a reghunt, this patch broke bootstrap (at least with g++
>>> 4.7 as bootstrap compiler):
>>
>> Which target are you using?  I just tried with a gcc 4.7 host compiler
>> on x86_64-linux-gnu and it seemed to work.
>
> I see it on i386-pc-solaris2.1[01] and sparc-su

Re: [PATCH][Revised] Fix PR66509

2015-06-26 Thread H.J. Lu
On Fri, Jun 26, 2015 at 9:09 AM, Jack Howarth  wrote:
>   The attached revised patch adjusts the tests for the filds and fists
> mnemonics to use the assembly...
>
> filds (%ebp); fists (%ebp)
>
> and the test for the fildq and fistq mnemonics to use the assembly...
>
> fildq (%ebp); fistpq (%ebp)
>
> which will assemble for both 64-bit and 32-bit mode. This is required
> to avoid "ambiguous instructions require an explicit suffix" errors
> from the clang-based assembler in Xcode 7. The change also has the
> side-benefit of allowing the legacy GNU assembler from Xcode 6.3 or
> earlier to properly detect that the filds, fists, fildq and fistq
> mnemonics are available on x86_64-apple-darwin. Bootstrapped tested on
> x86_64-apple-darwin14 against the Apple Inc version cctools-870, GNU
> assembler version 1.38 and on x86_64-apple-darwin15 against the new
> clang-based assembler.
> Okay for gcc trunk?
>Jack
> ps Also confirmed with 'as -32' and 'as -64' on x86_64 Fedora.

fildq (%ebp); fistpq (%ebp)  are valid for GNU assembler.

-- 
H.J.


[PATCH] Move X - (X / Y) * Y folding to match.pd

2015-06-26 Thread Marek Polacek
This is an attempt to move one pattern from fold-const.c to match.pd.
It ought to be 1:1, but is not, e.g. with this patch we won't fold e.g.

int
f (int a, int b)
{
  return a - (unsigned) ((a / b) * b)
}

anymore, but we're able to fold

int
ff (int a, unsigned int b)
{
  return a - ((a / b) * b); 
}

and fold-const.c is not.  I played around with converts, but didn't find
anything that would work well.  Any suggestions how to make this pattern
better?

More to come...

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2015-06-26  Marek Polacek  

* fold-const.c (fold_binary_loc): Move X - (X / Y) * Y -> X % Y to ...
* match.pd: ... pattern here.

diff --git gcc/fold-const.c gcc/fold-const.c
index 6f12dd0..01e3983 100644
--- gcc/fold-const.c
+++ gcc/fold-const.c
@@ -10509,19 +10509,6 @@ fold_binary_loc (location_t loc,
fold_convert_loc (loc, type,
  TREE_OPERAND (arg0, 0)));
 
-  /* X - (X / Y) * Y is X % Y.  */
-  if ((INTEGRAL_TYPE_P (type) || VECTOR_INTEGER_TYPE_P (type))
- && TREE_CODE (arg1) == MULT_EXPR
- && TREE_CODE (TREE_OPERAND (arg1, 0)) == TRUNC_DIV_EXPR
- && operand_equal_p (arg0,
- TREE_OPERAND (TREE_OPERAND (arg1, 0), 0), 0)
- && operand_equal_p (TREE_OPERAND (TREE_OPERAND (arg1, 0), 1),
- TREE_OPERAND (arg1, 1), 0))
-   return
- fold_convert_loc (loc, type,
-   fold_build2_loc (loc, TRUNC_MOD_EXPR, TREE_TYPE 
(arg0),
-arg0, TREE_OPERAND (arg1, 1)));
-
   if (! FLOAT_TYPE_P (type))
{
  /* Fold A - (A & B) into ~B & A.  */
diff --git gcc/match.pd gcc/match.pd
index b2f8429..2bc158b 100644
--- gcc/match.pd
+++ gcc/match.pd
@@ -238,6 +238,12 @@ along with GCC; see the file COPYING3.  If not see
   && tree_nop_conversion_p (type, TREE_TYPE (@1)))
   (trunc_mod @0 (convert @1
 
+/* X - (X / Y) * Y is the same as X % Y.  */
+(simplify
+ (minus @0 (mult (trunc_div @0 @1) @1))
+ (if (INTEGRAL_TYPE_P (type) || VECTOR_INTEGER_TYPE_P (type))
+  (trunc_mod @0 @1)))
+
 /* Optimize TRUNC_MOD_EXPR by a power of two into a BIT_AND_EXPR,
i.e. "X % C" into "X & (C - 1)", if X and C are positive.
Also optimize A % (C << N)  where C is a power of 2,

Marek


Re: [12/12] Simplify uses of hash_map

2015-06-26 Thread Richard Sandiford
Richard Sandiford  writes:
> Rainer Orth  writes:
>> Richard Sandiford  writes:
>>
>>> Rainer Orth  writes:
 Jeff Law  writes:

> On 06/23/2015 08:57 AM, Richard Sandiford wrote:
>> At this point all hash_map traits know what kind of key they're
>> dealing with, so we can make that a traits typedef, like it is for
>> hash_table traits.  Then, if we make the default hash traits for
>> T be T, we can use hash_table-style traits as the first template
>> parameter to hash_map, without the need for a third.  That is, if
>> foo_hash hashes elements of type foo_type:
>>
>>typedef simple_hashmap_traits  foo_traits;
>>hash_map  x;
>>
>> becomes just:
>>
>>hash_map  x;
>>
>> just like a hash_table of foo_types would be:
>>
>>hash_table  y;
>>
>> This patch makes that simplification.
>>
>>
>> gcc/
>>  * hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
>>  (unbounded_int_hashmap_traits::key_type): Likewise.
>>  * hash-map.h (hash_map): Get the key type from the traits.
>>  * hash-traits.h (default_hash_traits): By default, inherit from the
>>  template parameter.
>>  * alias.c (alias_set_traits): Delete.
>>  (alias_set_entry_d::children): Use alias_set_hash as the first
>>  template parameter.
>>  (record_alias_subset): Update accordingly.
>>  * except.c (tree_hash_traits): Delete.
>>  (type_to_runtime_map): Use tree_hash as the first template parameter.
>>  (init_eh): Update accordingly.
>>  * genmatch.c (capture_id_map_hasher): Delete.
>>  (cid_map_t): Use nofree_string_hash as first template parameter.
>>  * ipa-icf.h (symbol_compare_hashmap_traits): Delete.
>>  * ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
>>  Use symbol_compare_hash as the first template parameter in
>>  subdivide_hash_map.
>>  * mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
>>  (mem_usage_pair::mem_map_t): Use mem_location_hash as the first
>>  template parameter.
>>  * passes.c (pass_registry_hasher): Delete.
>>  (name_to_pass_map): Use nofree_string_hash as the first template
>>  parameter.
>>  (register_pass_name): Update accordingly.
>>  * sanopt.c (sanopt_tree_map_traits): Delete.
>>  (sanopt_tree_triplet_map_traits): Delete.
>>  (sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
>>  template parameter.
>>  (sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
>>  the first template parameter.
>>  * sese.c (rename_map_hasher): Delete.
>>  (rename_map_type): Use tree_ssa_name_hash as the first template
>>  parameter.
>>  * symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
>>  (function_summary::m_map): Use map_hash as the first template
>>  parameter.
>>  (function_summary::release): Update accordingly.
>>  * tree-if-conv.c (phi_args_hash_traits): Delete.
>>  (predicate_scalar_phi): Use tree_operand_hash as the first template
>>  parameter to phi_arg_map.
>>  * tree-inline.h (dependence_hasher): Delete.
>>  (copy_body_data::dependence_map): Use dependence_hash as the first
>>  template parameter.
>>  * tree-inline.c (remap_dependence_clique): Update accordingly.
>>  * tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
>>  (decl_to_stridxlist_htab): Use tree_decl_hash as the first template
>>  parameter.
>>  (addr_stridxptr): Update accordingly.
>>  * value-prof.c (profile_id_traits): Delete.
>>  (cgraph_node_map): Use profile_id_hash as the first template
>>  parameter.
>>  (init_node_map): Update accordingly.
>>  * config/alpha/alpha.c (string_traits): Delete.
>>  (machine_function::links): Use nofree_string_hash as the first
>>  template parameter.
>>  (alpha_use_linkage, alpha_write_linkage): Update accordingly.
>>  * config/m32c/m32c.c (pragma_traits): Delete.
>>  (pragma_htab): Use nofree_string_hash as the first template parameter.
>>  (m32c_note_pragma_address): Update accordingly.
>>  * config/mep/mep.c (pragma_traits): Delete.
>>  (pragma_htab): Use nofree_string_hash as the first template parameter.
>>  (mep_note_pragma_flag): Update accordingly.
>>  * config/mips/mips.c (mips16_flip_traits): Delete.
>>  (mflip_mips16_htab): Use nofree_string_hash as the first template
>>  parameter.
>>  (mflip_mips16_use_mips16_p): Update accordingly.
>>  (local_alias_traits): Delete.
>>  (mips16_local_aliases): Use nofree_string_hash as the first template
>>  parameter.
>>  (mips16_local_alias): Update accordingly.
> Phew.  OK.

 According to a reghunt, this patch broke bootstrap (at least with g++
 4.7 as bootstrap compiler):
>>>
>>> Which target are you using?  I just tried with a gcc 4.7 host compiler
>>> on x86_64-linux-gnu and it see

[patch] Add noexcept to default constructors of std::map, std::set etc.

2015-06-26 Thread Jonathan Wakely

Howard pointed out that we're missing some noexcept guarantees on the
default constructors of RB trees, where libc++ has them.

Up with this I will not put.

I'm committing this to trunk and gcc-5-branch, tested
powerpc64le-linux.


commit 56134d0ab24c603ed62fdff199008ac55804d61a
Author: Jonathan Wakely 
Date:   Fri Jun 26 02:00:00 2015 +0100

	* include/bits/stl_bvector.h (vector::vector()): Add noexcept.
	* include/bits/stl_map.h (map::map()): Likewise.
	* include/bits/stl_multimap.h (multimap::multimap()): Likewise.
	* include/bits/stl_multiset.h (multiset::multiset()): Likewise.
	* include/bits/stl_set.h (set::set()): Likewise.

diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h
index 7b93d95..71bee21 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -573,6 +573,9 @@ template
 
   public:
 vector()
+#if __cplusplus >= 201103L
+  noexcept(is_nothrow_default_constructible::value)
+#endif
 : _Base() { }
 
 explicit
diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h
index df18973..179e3f2 100644
--- a/libstdc++-v3/include/bits/stl_map.h
+++ b/libstdc++-v3/include/bits/stl_map.h
@@ -160,6 +160,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @brief  Default constructor creates no elements.
*/
   map()
+#if __cplusplus >= 201103L
+  noexcept(is_nothrow_default_constructible::value)
+#endif
   : _M_t() { }
 
   /**
diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h
index f3d21ab..10ac0fa 100644
--- a/libstdc++-v3/include/bits/stl_multimap.h
+++ b/libstdc++-v3/include/bits/stl_multimap.h
@@ -158,6 +158,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @brief  Default constructor creates no elements.
*/
   multimap()
+#if __cplusplus >= 201103L
+  noexcept(is_nothrow_default_constructible::value)
+#endif
   : _M_t() { }
 
   /**
diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h
index 7e92836..0a476d1 100644
--- a/libstdc++-v3/include/bits/stl_multiset.h
+++ b/libstdc++-v3/include/bits/stl_multiset.h
@@ -138,6 +138,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @brief  Default constructor creates no elements.
*/
   multiset()
+#if __cplusplus >= 201103L
+  noexcept(is_nothrow_default_constructible::value)
+#endif
   : _M_t() { }
 
   /**
diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h
index 5189234..2e5c89f 100644
--- a/libstdc++-v3/include/bits/stl_set.h
+++ b/libstdc++-v3/include/bits/stl_set.h
@@ -140,6 +140,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @brief  Default constructor creates no elements.
*/
   set()
+#if __cplusplus >= 201103L
+  noexcept(is_nothrow_default_constructible::value)
+#endif
   : _M_t() { }
 
   /**


Re: [PATCH][Revised] Fix PR66509

2015-06-26 Thread Mike Stump
On Jun 26, 2015, at 9:09 AM, Jack Howarth  wrote:
>  The attached revised patch adjusts the tests for the filds and fists
> mnemonics to use the assembly...
> 
> filds (%ebp); fists (%ebp)
> 
> and the test for the fildq and fistq mnemonics to use the assembly...
> 
> fildq (%ebp); fistpq (%ebp)
> 
> which will assemble for both 64-bit and 32-bit mode. This is required
> to avoid "ambiguous instructions require an explicit suffix" errors
> from the clang-based assembler in Xcode 7. The change also has the
> side-benefit of allowing the legacy GNU assembler from Xcode 6.3 or
> earlier to properly detect that the filds, fists, fildq and fistq
> mnemonics are available on x86_64-apple-darwin. Bootstrapped tested on
> x86_64-apple-darwin14 against the Apple Inc version cctools-870, GNU
> assembler version 1.38 and on x86_64-apple-darwin15 against the new
> clang-based assembler.
>Okay for gcc trunk?

Ok.


Re: [12/12] Simplify uses of hash_map

2015-06-26 Thread Richard Sandiford
Richard Sandiford  writes:
> Richard Sandiford  writes:
>> Rainer Orth  writes:
>>> Richard Sandiford  writes:
>>>
 Rainer Orth  writes:
> Jeff Law  writes:
>
>> On 06/23/2015 08:57 AM, Richard Sandiford wrote:
>>> At this point all hash_map traits know what kind of key they're
>>> dealing with, so we can make that a traits typedef, like it is for
>>> hash_table traits.  Then, if we make the default hash traits for
>>> T be T, we can use hash_table-style traits as the first template
>>> parameter to hash_map, without the need for a third.  That is, if
>>> foo_hash hashes elements of type foo_type:
>>>
>>>typedef simple_hashmap_traits  foo_traits;
>>>hash_map  x;
>>>
>>> becomes just:
>>>
>>>hash_map  x;
>>>
>>> just like a hash_table of foo_types would be:
>>>
>>>hash_table  y;
>>>
>>> This patch makes that simplification.
>>>
>>>
>>> gcc/
>>> * hash-map-traits.h (simple_hashmap_traits::key_type): New 
>>> typedef.
>>> (unbounded_int_hashmap_traits::key_type): Likewise.
>>> * hash-map.h (hash_map): Get the key type from the traits.
>>> * hash-traits.h (default_hash_traits): By default, inherit from 
>>> the
>>> template parameter.
>>> * alias.c (alias_set_traits): Delete.
>>> (alias_set_entry_d::children): Use alias_set_hash as the first
>>> template parameter.
>>> (record_alias_subset): Update accordingly.
>>> * except.c (tree_hash_traits): Delete.
>>> (type_to_runtime_map): Use tree_hash as the first template 
>>> parameter.
>>> (init_eh): Update accordingly.
>>> * genmatch.c (capture_id_map_hasher): Delete.
>>> (cid_map_t): Use nofree_string_hash as first template parameter.
>>> * ipa-icf.h (symbol_compare_hashmap_traits): Delete.
>>> * ipa-icf.c 
>>> (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
>>> Use symbol_compare_hash as the first template parameter in
>>> subdivide_hash_map.
>>> * mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): 
>>> Delete.
>>> (mem_usage_pair::mem_map_t): Use mem_location_hash as the first
>>> template parameter.
>>> * passes.c (pass_registry_hasher): Delete.
>>> (name_to_pass_map): Use nofree_string_hash as the first template
>>> parameter.
>>> (register_pass_name): Update accordingly.
>>> * sanopt.c (sanopt_tree_map_traits): Delete.
>>> (sanopt_tree_triplet_map_traits): Delete.
>>> (sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
>>> template parameter.
>>> (sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
>>> the first template parameter.
>>> * sese.c (rename_map_hasher): Delete.
>>> (rename_map_type): Use tree_ssa_name_hash as the first template
>>> parameter.
>>> * symbol-summary.h (function_summary::summary_hashmap_traits): 
>>> Delete.
>>> (function_summary::m_map): Use map_hash as the first template
>>> parameter.
>>> (function_summary::release): Update accordingly.
>>> * tree-if-conv.c (phi_args_hash_traits): Delete.
>>> (predicate_scalar_phi): Use tree_operand_hash as the first 
>>> template
>>> parameter to phi_arg_map.
>>> * tree-inline.h (dependence_hasher): Delete.
>>> (copy_body_data::dependence_map): Use dependence_hash as the 
>>> first
>>> template parameter.
>>> * tree-inline.c (remap_dependence_clique): Update accordingly.
>>> * tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
>>> (decl_to_stridxlist_htab): Use tree_decl_hash as the first 
>>> template
>>> parameter.
>>> (addr_stridxptr): Update accordingly.
>>> * value-prof.c (profile_id_traits): Delete.
>>> (cgraph_node_map): Use profile_id_hash as the first template
>>> parameter.
>>> (init_node_map): Update accordingly.
>>> * config/alpha/alpha.c (string_traits): Delete.
>>> (machine_function::links): Use nofree_string_hash as the first
>>> template parameter.
>>> (alpha_use_linkage, alpha_write_linkage): Update accordingly.
>>> * config/m32c/m32c.c (pragma_traits): Delete.
>>> (pragma_htab): Use nofree_string_hash as the first template 
>>> parameter.
>>> (m32c_note_pragma_address): Update accordingly.
>>> * config/mep/mep.c (pragma_traits): Delete.
>>> (pragma_htab): Use nofree_string_hash as the first template 
>>> parameter.
>>> (mep_note_pragma_fl

Re: [Patch SRA] Fix PR66119 by calling get_move_ratio in SRA

2015-06-26 Thread James Greenhalgh

On Thu, Jun 25, 2015 at 05:05:22AM +0100, Jeff Law wrote:
> On 06/23/2015 09:42 AM, James Greenhalgh wrote:
> >
> > On Tue, Jun 23, 2015 at 09:52:01AM +0100, Jakub Jelinek wrote:
> >> On Tue, Jun 23, 2015 at 09:18:52AM +0100, James Greenhalgh wrote:
> >>> This patch fixes the issue by always calling get_move_ratio in the SRA
> >>> code, ensuring that an up-to-date value is used.
> >>>
> >>> Unfortunately, this means we have to use 0 as a sentinel value for
> >>> the parameter - indicating no user override of the feature - and
> >>> therefore cannot use it to disable scalarization. However, there
> >>> are other ways to disable scalarazation (-fno-tree-sra) so this is not
> >>> a great loss.
> >>
> >> You can handle even that.
> >>
> >
> > 
> >
> >>enum compiler_param param
> >>  = optimize_function_for_size_p (cfun)
> >>? PARAM_SRA_MAX_SCALARIZATION_SIZE_SIZE
> >>: PARAM_SRA_MAX_SCALARIZATION_SIZE_SPEED;
> >>unsigned max_scalarization_size = PARAM_VALUE (param) * BITS_PER_UNIT;
> >>if (!max_scalarization_size && 
> >> !global_options_set.x_param_values[param])
> >>
> >> Then it will handle explicit --param sra-max-scalarization-size-Os*=0
> >> differently from implicit 0.
> >
> > Ah hah! OK, I've respun the patch removing this extra justification in
> > the documentation and reshuffling the logic a little.
> >
> >> OT, shouldn't max_scalarization_size be at least unsigned HOST_WIDE_INT,
> >> so that it doesn't overflow for larger values (0x4000 etc.)?
> >> Probably need some cast in the multiplication to avoid UB in the compiler.
> >
> > I've increased the size of max_scalarization_size to a UHWI in this spin.
> >
> > Bootstrapped and tested on AArch64 and x86-64 with no issues and checked
> > to see the PR is fixed.
> >
> > OK for trunk, and gcc-5 in a few days?
> >
> > Thanks,
> > James
> >
> > ---
> > gcc/
> >
> > 2015-06-23  James Greenhalgh  
> >
> > PR tree-optimization/66119
> > * toplev.c (process_options): Don't set up default values for
> > the sra_max_scalarization_size_{speed,size} parameters.
> > * tree-sra (analyze_all_variable_accesses): If no values
> > have been set for the sra_max_scalarization_size_{speed,size}
> > parameters, call get_move_ratio to get target defaults.
> Any testcase for this change?
>
> OK with a testcase.
>
> jeff

Thanks Jeff,

I'm not really up to scratch on the gotchas for the dg directives
targetting avx on x86, does the testcase in this patch (taken from
the PR) look OK?

Cheers,
James

diff --git a/gcc/testsuite/g++.dg/pr66119.C b/gcc/testsuite/g++.dg/pr66119.C
new file mode 100644
index 000..9979e91
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr66119.C
@@ -0,0 +1,69 @@
+/* PR66119 - MOVE_RATIO is not constant in a compiler run, so Scalar
+   Reduction of Aggregates must ask the back-end more than once what
+   the value of MOVE_RATIO now is.  */
+
+/* { dg-do compile  { target i?86-*-* x86_64-*-* } }  */
+/* { dg-options "-std=c++11 -O3 -mavx -fdump-tree-sra -march=slm" { target avx_runtime } } */
+
+#include 
+
+class MyAVX
+{
+  __m256d data;
+public:
+  MyAVX () = default;
+  MyAVX (const MyAVX &) = default;
+  MyAVX (__m256d _data) : data(_data) { ; }
+
+  MyAVX & operator= (const MyAVX &) = default;
+
+  operator __m256d () const { return data; }
+  MyAVX operator+ (MyAVX s2) { return data+s2.data; }
+};
+
+template  class AVX_trait { ; };
+
+template <> class AVX_trait {
+public:
+  typedef __m256d TSIMD;
+};
+
+
+template 
+class MyTSIMD
+{
+  typename AVX_trait::TSIMD data;
+
+public:
+  MyTSIMD () = default;
+  MyTSIMD (const MyTSIMD &) = default;
+  // MyTSIMD (const MyTSIMD & s2) : data(s2.data) { ; }
+  MyTSIMD (typename AVX_trait::TSIMD _data) : data(_data) { ; }
+
+  operator typename AVX_trait::TSIMD() const { return data; }
+  MyTSIMD operator+ (MyTSIMD s2) { return data+s2.data; }
+};
+
+// using MyVec = MyAVX;
+using MyVec = MyTSIMD;
+
+class Vec2
+{
+  MyVec a, b;
+public:
+  Vec2 (MyVec aa, MyVec ab) : a(aa), b(ab) { ; }
+  Vec2 operator+ (Vec2 v2) { return Vec2(a+v2.a, b+v2.b); }
+};
+
+inline __attribute__ ((__always_inline__))
+Vec2 ComputeSomething (Vec2 a, Vec2 b)
+{
+  return a+b;
+}
+
+Vec2 TestFunction (Vec2 a, Vec2 b)
+{
+  return ComputeSomething (a,b);
+}
+
+/* { dg-final { scan-tree-dump "Created a replacement for b" "sra" } } */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 2f43a89..902bfc7 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1301,20 +1301,6 @@ process_options (void)
  so we can correctly initialize debug output.  */
   no_backend = lang_hooks.post_options (&main_input_filename);
 
-  /* Set default values for parameters relation to the Scalar Reduction
- of Aggregates passes (SRA and IP-SRA).  We must do this here, rather
- than in opts.c:default_options_optimization as historically these
- tuning heuristics have been based on MOVE_RATIO, which on some
- targets requires other symbols from the backend.  */
-  maybe_set_param_value
- 

Re: [Patch SRA] Fix PR66119 by calling get_move_ratio in SRA

2015-06-26 Thread Jakub Jelinek
On Fri, Jun 26, 2015 at 06:03:34PM +0100, James Greenhalgh wrote:
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pr66119.C

I think generally testcases shouldn't be added into g++.dg/ directly,
but subdirectories.  So g++.dg/opt/ ?

> @@ -0,0 +1,69 @@
> +/* PR66119 - MOVE_RATIO is not constant in a compiler run, so Scalar
> +   Reduction of Aggregates must ask the back-end more than once what
> +   the value of MOVE_RATIO now is.  */
> +
> +/* { dg-do compile  { target i?86-*-* x86_64-*-* } }  */

In g++.dg/, dejagnu cycles through all 3 major -std=c* versions,
thus using -std=c++11 is inappropriate.
If the test requires c++11, instead you do
// { dg-do compile { target { { i?86-*-* x86_64-*-* } && c++11 } } }

> +/* { dg-options "-std=c++11 -O3 -mavx -fdump-tree-sra -march=slm" { target 
> avx_runtime } } */

and remove -std=c++11 here.  I don't see any point in guarding it with
avx_runtime, after all, if not avx_runtime, the test will be compiled with
-O0 and thus very likely fail the scan-tree-dump test.
As it is dg-do compile test only, you have no dependency on assembler nor
linker nor runtime.
But I'd add -mtune=slm too.

Jakub


Re: C PATCH to use VECTOR_TYPE_P

2015-06-26 Thread Marek Polacek
On Fri, Jun 26, 2015 at 06:02:22PM +0200, Marc Glisse wrote:
> On Fri, 26 Jun 2015, Marek Polacek wrote:
> 
> >-  if (TREE_CODE (TREE_TYPE (mask)) != VECTOR_TYPE
> >+  if (!VECTOR_TYPE_P (TREE_TYPE (mask))
> >  || TREE_CODE (TREE_TYPE (TREE_TYPE (mask))) != INTEGER_TYPE)
> 
> This one looks like !VECTOR_INTEGER_TYPE_P

Fixed, thanks.

Bootstrapped/regtested on x86_64-linux.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2015-06-26  Marek Polacek  

* c-common.c (check_main_parameter_types): Use VECTOR_TYPE_P
or VECTOR_INTEGER_TYPE_P throughout.
* c-gimplify.c: Likewise.

* c-typeck.c: Use VECTOR_TYPE_P throughout.

diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index b11a756..b308b09 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -2412,7 +2412,7 @@ check_main_parameter_types (tree decl)
 bool
 vector_targets_convertible_p (const_tree t1, const_tree t2)
 {
-  if (TREE_CODE (t1) == VECTOR_TYPE && TREE_CODE (t2) == VECTOR_TYPE
+  if (VECTOR_TYPE_P (t1) && VECTOR_TYPE_P (t2)
   && (TYPE_VECTOR_OPAQUE (t1) || TYPE_VECTOR_OPAQUE (t2))
   && tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2)))
 return true;
@@ -2500,8 +2500,7 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, 
tree mask,
   || mask == error_mark_node)
 return error_mark_node;
 
-  if (TREE_CODE (TREE_TYPE (mask)) != VECTOR_TYPE
-  || TREE_CODE (TREE_TYPE (TREE_TYPE (mask))) != INTEGER_TYPE)
+  if (!VECTOR_INTEGER_TYPE_P (TREE_TYPE (mask)))
 {
   if (complain)
error_at (loc, "__builtin_shuffle last argument must "
@@ -2509,8 +2508,8 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, 
tree mask,
   return error_mark_node;
 }
 
-  if (TREE_CODE (TREE_TYPE (v0)) != VECTOR_TYPE
-  || TREE_CODE (TREE_TYPE (v1)) != VECTOR_TYPE)
+  if (!VECTOR_TYPE_P (TREE_TYPE (v0))
+  || !VECTOR_TYPE_P (TREE_TYPE (v1)))
 {
   if (complain)
error_at (loc, "__builtin_shuffle arguments must be vectors");
@@ -12482,7 +12481,7 @@ convert_vector_to_pointer_for_subscript (location_t loc,
 tree *vecp, tree index)
 {
   bool ret = false;
-  if (TREE_CODE (TREE_TYPE (*vecp)) == VECTOR_TYPE)
+  if (VECTOR_TYPE_P (TREE_TYPE (*vecp)))
 {
   tree type = TREE_TYPE (*vecp);
   tree type1;
@@ -12548,8 +12547,7 @@ scalar_to_vector (location_t loc, enum tree_code code, 
tree op0, tree op1,
   bool integer_only_op = false;
   enum stv_conv ret = stv_firstarg;
 
-  gcc_assert (TREE_CODE (type0) == VECTOR_TYPE
- || TREE_CODE (type1) == VECTOR_TYPE);
+  gcc_assert (VECTOR_TYPE_P (type0) || VECTOR_TYPE_P (type1));
   switch (code)
 {
   /* Most GENERIC binary expressions require homogeneous arguments.
@@ -12599,7 +12597,7 @@ scalar_to_vector (location_t loc, enum tree_code code, 
tree op0, tree op1,
   case LT_EXPR:
   case GT_EXPR:
   /* What about UNLT_EXPR?  */
-   if (TREE_CODE (type0) == VECTOR_TYPE)
+   if (VECTOR_TYPE_P (type0))
  {
ret = stv_secondarg;
std::swap (type0, type1);
diff --git gcc/c-family/c-gimplify.c gcc/c-family/c-gimplify.c
index 317891f..98a6d53 100644
--- gcc/c-family/c-gimplify.c
+++ gcc/c-family/c-gimplify.c
@@ -248,7 +248,7 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p 
ATTRIBUTE_UNUSED,
   We should get rid of this conversion when we have a proper
   type demotion/promotion pass.  */
tree *op1_p = &TREE_OPERAND (*expr_p, 1);
-   if (TREE_CODE (TREE_TYPE (*op1_p)) != VECTOR_TYPE
+   if (!VECTOR_TYPE_P (TREE_TYPE (*op1_p))
&& !types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (*op1_p)),
unsigned_type_node)
&& !types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (*op1_p)),
diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index 9caf028..9982d61 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -2457,7 +2457,7 @@ build_array_ref (location_t loc, tree array, tree index)
   if (TREE_CODE (TREE_TYPE (array)) != ARRAY_TYPE
   && TREE_CODE (TREE_TYPE (array)) != POINTER_TYPE
   /* Allow vector[index] but not index[vector].  */
-  && TREE_CODE (TREE_TYPE (array)) != VECTOR_TYPE)
+  && !VECTOR_TYPE_P (TREE_TYPE (array)))
 {
   if (TREE_CODE (TREE_TYPE (index)) != ARRAY_TYPE
  && TREE_CODE (TREE_TYPE (index)) != POINTER_TYPE)
@@ -6730,7 +6730,7 @@ digest_init (location_t init_loc, tree type, tree init, 
tree origtype,
  vector constructor is not constant (e.g. {1,2,3,foo()}) then punt
  below and handle as a constructor.  */
   if (code == VECTOR_TYPE
-  && TREE_CODE (TREE_TYPE (inside_init)) == VECTOR_TYPE
+  && VECTOR_TYPE_P (TREE_TYPE (inside_init))
   && vector_types_convertible_p (TREE_TYPE (inside_init), type, true)
   && TREE_CONSTANT (inside_init))
 {
@@ -7181,7 +7181,7 @@ really_start_incremental_init (tree type)
   if (type == 0)
  

Re: [patch] Remove fold-const.h as a dependency for gimple.h

2015-06-26 Thread Andrew MacLeod

On 06/26/2015 05:40 AM, Richard Biener wrote:

On Thu, Jun 25, 2015 at 10:57 PM, Jeff Law  wrote:

On 06/25/2015 02:31 PM, Andrew MacLeod wrote:

I proposed including fold-const.h into gimple.h, but didn't notice that
its actually only needed by one inline function. Moving that function to
gimple.c means its no longer required.


OK.

Well, it's also just lazy in using build_fold_addr_expr_loc because it
doesn't want to spell out the all-tree.h

build1_loc (gimple_location (gs), ADDR_EXPR, build_pointer_type
(decl), decl);

there is nothing to be simplified (setting a location here is also a waste).

Richard.



Easy enough... how about this for trunk?

bootstraps on x86_64-unknown-linux-gnu with no new regressions.
Andrew
2015-06-26  Andrew MacLeod  

	* gimple.c (gimple_call_set_fndecl): Remove.
	* gimple.h (gimple_call_set_fndecl): Relocate to gimple.h and call
	build1_loc directly instead of build_fold_addr_expr_loc.

Index: gimple.c
===
*** gimple.c	(revision 225011)
--- gimple.c	(working copy)
*** gimple_build_return (tree retval)
*** 199,214 
return s;
  }
  
- /* Set FNDECL to be the function called by call statement GS.  */
- 
- void
- gimple_call_set_fndecl (gimple gs, tree decl)
- {
-   GIMPLE_CHECK (gs, GIMPLE_CALL);
-   gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
-   gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
- }
- 
  /* Reset alias information on call S.  */
  
  void
--- 199,204 
Index: gimple.h
===
*** gimple.h	(revision 225011)
--- gimple.h	(working copy)
*** extern gimple currently_expanding_gimple
*** 1296,1302 
  #define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
  gimple gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
  greturn *gimple_build_return (tree);
- void gimple_call_set_fndecl (gimple, tree);
  void gimple_call_reset_alias_info (gcall *);
  gcall *gimple_build_call_vec (tree, vec );
  gcall *gimple_build_call (tree, unsigned, ...);
--- 1296,1301 
*** gimple_call_set_fn (gcall *gs, tree fn)
*** 2760,2765 
--- 2759,2777 
  }
  
  
+ /* Set FNDECL to be the function called by call statement GS.  */
+ 
+ static inline void
+ gimple_call_set_fndecl (gimple gs, tree decl)
+ {
+   GIMPLE_CHECK (gs, GIMPLE_CALL);
+   gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
+   gimple_set_op (gs, 1, build1_loc (gimple_location (gs), ADDR_EXPR,
+  build_pointer_type (TREE_TYPE (decl)),
+  decl));
+ }
+ 
+ 
  /* Set internal function FN to be the function called by call statement CALL_STMT.  */
  
  static inline void


Managing ABI compatibility (was Re: [PATCH 2/2] jit: add switch statements)

2015-06-26 Thread David Malcolm
On Thu, 2015-06-25 at 13:16 -0600, Jeff Law wrote:
> On 06/25/2015 01:13 PM, David Malcolm wrote:
> >
> >* It extends the libgccjit API.  It's not clear to me yet how to
> >  manage extensions of the libgccjit API: should I use symbol maps
> >  and versioning, or bump the SONAME?  I'm thinking of providing
> >  precanned feature macros within libgccjit.h e.g:
> >
> >#define LIBGCCJIT_HAVE_SWITCH_STATEMENT
> Seems to me you should use a symbol map and bump the version.

Thanks.  By "the version", do you mean the version within the symbol
map?

I've read Uli Drepper's "How To Write Shared Libraries" guide:
  http://www.akkadia.org/drepper/dsohowto.pdf
and in particular section 3: "Maintaining APIs and ABIs", which suggests
versioned DSOs (though this presumably implies the use of GNU ld).

I attempted to use the symbol map to segregate the new symbols into
their own version; attached is a patch which does that (on top of the
"add switch statements" patch).

Is that the kind of thing you had in mind?

My first attempt was to keep the existing syms in an anonymous tag but I
got:
  /usr/bin/ld: anonymous version tag cannot be combined with other
version tags
(which comes from binutils ld/ldlang.c:lang_register_vers_node)

Hence I put the existing symbols into a LIBGCCJIT_ABI_1 version.

With the above change, using "eu-readelf -s" I see a client program
linked against libgccjit goes from having e.g.:

GLOBAL DEFAULTUNDEF gcc_jit_context_compile

to having:

GLOBAL DEFAULTUNDEF gcc_jit_context_compile@@LIBGCCJIT_ABI_1

and one using the new symbols has:

GLOBAL DEFAULTUNDEF gcc_jit_context_compile@LIBGCCJIT_ABI_1 (2)
GLOBAL DEFAULTUNDEF gcc_jit_block_end_with_switch@LIBGCCJIT_ABI_2 (4)


Presumably I'd need to bump the SONAME to accommodate the introduction
of using symbol versioning?  Am I right in hoping that with the
introduction to using symbol versioning that I'd never need to bump the
SONAME again?

Running:

  objdump -p client-binary-using-just-old-symbols

gives (amongst other output):

  Version References:
required from libc.so.6:
  0x09691a75 0x00 03 GLIBC_2.2.5
required from libgccjit.so.0:
  0x00824161 0x00 02 LIBGCCJIT_ABI_1

whereas:

  objdump -p client-binary-using-some-new-symbols

gives:

  Version References:
required from libc.so.6:
  0x09691a75 0x00 03 GLIBC_2.2.5
required from libgccjit.so.0:
  0x00824162 0x00 04 LIBGCCJIT_ABI_2
  0x00824161 0x00 02 LIBGCCJIT_ABI_1

FWIW objdump -p is used by /usr/lib/rpm/find-requires, so presumably
these entries would show up in rpm metadata, so that binaries using the
new symbols get flagged at the RPM level as needing a more up-to-date
libgccjit rpm.

Hopefully other packaging systems handle symbol versioning in similar
ways.

Does this approach look sane?

I'd probably add a page about ABI to the docs, and list the ABIs there.

This doesn't cover the addition of new values to the various options
enums; I'm not sure how to handle capturing *that* within the binary
metadata without bumping the SONAME.  Maybe bump the
gcc_jit_context_set_FOO_option entrypoints into new version tags each
time we add a new value to the corresponding option enum?

Would it be sane to go to a feature-based naming scheme for tags, rather
than pure numbers?
e.g.
  LIBGCCJIT_ABI_INITIAL
  LIBGCCJIT_ABI_WITH_SWITCH_STATEMENTS
  LIGCCCJIT_ABI_WITH_BOOL_OPTION_ERROR_ON_UNREACHABLE_BLOCKS
etc (how long can they be, and is there a cost? can they include lower
case?)

Dave
diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map
index 93b19e8..7bf89f2 100644
--- a/gcc/jit/libgccjit.map
+++ b/gcc/jit/libgccjit.map
@@ -17,6 +17,9 @@
 # You should have received a copy of the GNU General Public License
 # along with GCC; see the file COPYING3.  If not see
 # .  */
+
+# The initial release of the library.
+LIBGCCJIT_ABI_1
 {
   global:
 # Keep this list sorted alphabetically:
@@ -29,9 +32,7 @@
 gcc_jit_block_end_with_jump;
 gcc_jit_block_end_with_return;
 gcc_jit_block_end_with_void_return;
-gcc_jit_block_end_with_switch;
 gcc_jit_block_get_function;
-gcc_jit_case_as_object;
 gcc_jit_context_acquire;
 gcc_jit_context_add_option;
 gcc_jit_context_compile;
@@ -49,7 +50,6 @@
 gcc_jit_context_new_binary_op;
 gcc_jit_context_new_call;
 gcc_jit_context_new_call_through_ptr;
-gcc_jit_context_new_case;
 gcc_jit_context_new_cast;
 gcc_jit_context_new_child_context;
 gcc_jit_context_new_comparison;
@@ -109,4 +109,12 @@
 gcc_jit_type_get_volatile;
 
   local: *;
-};
\ No newline at end of file
+};
+
+# Add support for switch statements.
+LIBGCCJIT_ABI_2 {
+  global:
+gcc_jit_block_end_with_switch;
+gcc_jit_case_as_object;
+gcc_jit_context_new_case;
+} LIBGCCJIT_ABI_1;


Re: Managing ABI compatibility (was Re: [PATCH 2/2] jit: add switch statements)

2015-06-26 Thread David Malcolm
On Fri, 2015-06-26 at 13:57 -0400, David Malcolm wrote:
> On Thu, 2015-06-25 at 13:16 -0600, Jeff Law wrote:
> > On 06/25/2015 01:13 PM, David Malcolm wrote:
> > >
> > >* It extends the libgccjit API.  It's not clear to me yet how to
> > >  manage extensions of the libgccjit API: should I use symbol maps
> > >  and versioning, or bump the SONAME?  I'm thinking of providing
> > >  precanned feature macros within libgccjit.h e.g:
> > >
> > >#define LIBGCCJIT_HAVE_SWITCH_STATEMENT
> > Seems to me you should use a symbol map and bump the version.
> 
> Thanks.  By "the version", do you mean the version within the symbol
> map?
> 
> I've read Uli Drepper's "How To Write Shared Libraries" guide:
>   http://www.akkadia.org/drepper/dsohowto.pdf
> and in particular section 3: "Maintaining APIs and ABIs", which suggests
> versioned DSOs (though this presumably implies the use of GNU ld).
> 
> I attempted to use the symbol map to segregate the new symbols into
> their own version; attached is a patch which does that (on top of the
> "add switch statements" patch).
> 
> Is that the kind of thing you had in mind?
> 
> My first attempt was to keep the existing syms in an anonymous tag but I
> got:
>   /usr/bin/ld: anonymous version tag cannot be combined with other
> version tags
> (which comes from binutils ld/ldlang.c:lang_register_vers_node)
> 
> Hence I put the existing symbols into a LIBGCCJIT_ABI_1 version.
> 
> With the above change, using "eu-readelf -s" I see a client program
> linked against libgccjit goes from having e.g.:
> 
> GLOBAL DEFAULTUNDEF gcc_jit_context_compile
> 
> to having:
> 
> GLOBAL DEFAULTUNDEF gcc_jit_context_compile@@LIBGCCJIT_ABI_1
> 
> and one using the new symbols has:
> 
> GLOBAL DEFAULTUNDEF gcc_jit_context_compile@LIBGCCJIT_ABI_1 (2)
> GLOBAL DEFAULTUNDEF gcc_jit_block_end_with_switch@LIBGCCJIT_ABI_2 (4)
> 
> 
> Presumably I'd need to bump the SONAME to accommodate the introduction
> of using symbol versioning?  Am I right in hoping that with the
> introduction to using symbol versioning that I'd never need to bump the
> SONAME again?
> 
> Running:
> 
>   objdump -p client-binary-using-just-old-symbols
> 
> gives (amongst other output):
> 
>   Version References:
> required from libc.so.6:
>   0x09691a75 0x00 03 GLIBC_2.2.5
> required from libgccjit.so.0:
>   0x00824161 0x00 02 LIBGCCJIT_ABI_1
> 
> whereas:
> 
>   objdump -p client-binary-using-some-new-symbols
> 
> gives:
> 
>   Version References:
> required from libc.so.6:
>   0x09691a75 0x00 03 GLIBC_2.2.5
> required from libgccjit.so.0:
>   0x00824162 0x00 04 LIBGCCJIT_ABI_2
>   0x00824161 0x00 02 LIBGCCJIT_ABI_1
> 
> FWIW objdump -p is used by /usr/lib/rpm/find-requires, so presumably
> these entries would show up in rpm metadata, so that binaries using the
> new symbols get flagged at the RPM level as needing a more up-to-date
> libgccjit rpm.
> 
> Hopefully other packaging systems handle symbol versioning in similar
> ways.
> 
> Does this approach look sane?
> 
> I'd probably add a page about ABI to the docs, and list the ABIs there.
> 
> This doesn't cover the addition of new values to the various options
> enums; I'm not sure how to handle capturing *that* within the binary
> metadata without bumping the SONAME.  Maybe bump the
> gcc_jit_context_set_FOO_option entrypoints into new version tags each
> time we add a new value to the corresponding option enum?

Maybe having public enums for the options was a mistake; perhaps
additional options should get their own API entrypoints:

e.g.
  gcc_jit_context_set_bool_option_name_of_option
  gcc_jit_context_set_int_option_name_of_option
  gcc_jit_context_set_str_option_name_of_option

so perhaps:

  extern void
  gcc_jit_context_set_bool_option_allow_unreachable_blocks (gcc_jit_context 
*ctxt,
 int value);

Quite a mouthful, but it means we can precisely identify client binaries
using it via metadata.  (perhaps lose the "bool_", "option_" or
bool_option_" part?)

[...snip...]



Re: C PATCH to use INDIRECT_REF_P

2015-06-26 Thread Joseph Myers
On Fri, 26 Jun 2015, Marek Polacek wrote:

> We have INDIRECT_REF_P macro, so let's use it to make the code a bit
> more clear.
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

OK.

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


[v3 patch] Implement N4258: Cleaning-up noexcept in the library

2015-06-26 Thread Jonathan Wakely

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4258.pdf

This implements N4258 except for the basic_string parts, which I'm
still working on (because I forgot to do allocator propagation
properly in the new string).

Since the new is_always_equal trait is inspired by the
_S_always_equal() member of our __alloc_traits the changes are not
very large, because we are already doing the right thing in the
containers.

I couldn't see a way to add is_always_equal only for C++17 without
introducing ODR violations. I tried adding an __is_always_equal trait
for internal use in C++11-and-later modes, and only define
is_always_equal for C++17, but in order to do the right thing it has
to check for A::is_always_equal in user-defined allocators, so that
already breaks if users #define is_always_equal as a macro. So I
decided to just go ahead and define is_always_equal even in C++11, on
the basis that it fixes LWG DR 2108 and it's better to have the trait
give the same result in C++11 and C++17 modes.

Tested powerpc64le-linux, committed to trunk.
commit 39e685e9b5773a821858c8f1ffba512d26c8
Author: Jonathan Wakely 
Date:   Fri Jun 26 02:42:58 2015 +0100

Implement N4258 (Cleaning-up noexcept in the Library rev 3)

	* doc/xml/manual/intro.xml: Document LWG 2108 status.
	* include/bits/alloc_traits.h (allocator_traits::is_always_equal):
	Define.
	* include/bits/allocator.h (allocator::is_always_equal): Likewise.
	* include/bits/forward_list.h
	(forward_list::operator=(forward_list&&)): Use __bool_constant.
	(forward_list::swap(forward_list&)): Add noexcept.
	* include/bits/hashtable.h (_Hashtable::operator=(_Hashtable&&)):
	Likewise.
	(_Hashtable::swap(_Hashtable&)): Likewise.
	* include/bits/stl_deque.h (_Deque_base::_Deque_base(_Deque_base&&)):
	Use _Alloc_traits::is_always_equal.
	(deque::operator=(deque&&)): Likewise.
	(deque::_M_move_assign1(deque&&, false_type)): Add comment and use
	__bool_constant.
	(swap(deque&, deque&)): Add noexcept.
	* include/bits/stl_list.h (list::operator=(list&&)): Use
	__bool_constant.
	(swap(list&, list&)): Add noexcept.
	* include/bits/stl_map.h (map::swap(map&)): Include _Compare in
	noexcept.
	(swap(map&, map&)): Add noexcept.
	* include/bits/stl_multimap.h (multimap::swap(multimap&)): Include
	_Compare in noexcept.
	(swap(multimap&, multimap&)): Add noexcept.
	* include/bits/stl_multiset.h (multiset::swap(multiset&)): Include
	_Compare in noexcept.
	(swap(multiset&, multiset&)): Add noexcept.
	* include/bits/stl_set.h (set::swap(set&)): Include _Compare in
	noexcept.
	(swap(set&, set&)): Add noexcept.
	* include/bits/stl_tree.h (_Rb_tree::operator=(_Rb_tree&&)): Include
	_Compare in noexcept.
	(_Rb_tree::_Rb_tree(_Rb_tree&&, _Node_alloc_type&&)): Use
	is_always_equal.
	* include/bits/stl_vector.h (vector::operator=(vector&&)): Use
	__bool_constant.
	(swap(vector&, vector&)): Add noexcept.
	* include/bits/unordered_map.h (swap(unordered_map&, unordered_map&),
	swap(unordered_multimap& unordered_multimap&)): Add noexcept.
	* include/bits/unordered_set.h (swap(unordered_set&, unordered_set&),
	swap(unordered_multiset& unordered_multiset&)): Add noexcept.
	* include/ext/alloc_traits.h (__allocator_always_compares_equal):
	Remove.
	(__alloc_traits::_S_always_equal()): Use is_always_equal instead of
	__allocator_always_compares_equal.
	* include/ext/array_allocator.h (array_allocator::is_always_equal):
	Define.
	* include/std/scoped_allocator (__any_of, __propagate_on_copy,
	__propagate_on_move, __propagate_on_swap): Remove.
	(scoped_allocator_adaptor::propagate_on_container_copy_assignment,
	scoped_allocator_adaptor::propagate_on_container_move_assignment,
	scoped_allocator_adaptor::propagate_on_container_swap): Define with
	__and_ instead of __any_of.
	(scoped_allocator_adaptor::is_always_equal): Define.
	* testsuite/20_util/allocator_traits/members/is_always_equal.cc: New.
	* testsuite/20_util/scoped_allocator/propagation.cc: Make traits
	derive from true_type or false_type.
	* testsuite/23_containers/deque/allocator/move_assign-2.cc: Add
	is_always_equal member and remove the trait specialization.
	* testsuite/23_containers/vector/52591.cc: Likewise.
	* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
	Adjust dg-error line number.
	* testsuite/23_containers/deque/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/deque/requirements/dr438/
	constructor_2_neg.cc: Likewise.
	* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
	Likewise.
	* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
	Likewise.
	* testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc:
	Likewise.
	* testsuite/23_containers

C++ PATCH for c++/66067 (ICE with alias of typename)

2015-06-26 Thread Jason Merrill

This bug was caused by a combination of bugs:

1) An alias template where the expansion is a typename template-id, used 
as a template template argument, was being mangled with the template 
arguments tacked on.


2) Trying to mangle a zero-length explicit template argument list was 
causing a crash.


Tested x86_64-pc-linux-gnu, applying to trunk.  Applying only the second 
fix to the 5 branch.
commit 5d28afd97b7afdb4769c2473f985ccb6849fb469
Author: Jason Merrill 
Date:   Thu Jun 25 07:45:03 2015 -0400

	PR c++/66067
	* mangle.c (write_nested_name): Limit TYPENAME_TYPE handling to
	TYPE_DECLs.
	* mangle.c (write_template_args): Handle 0 length TREE_VEC.

diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index c1a81fc..f4947c4 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -984,7 +984,8 @@ write_nested_name (const tree decl)
   write_template_prefix (decl);
   write_template_args (TI_ARGS (template_info));
 }
-  else if (TREE_CODE (TREE_TYPE (decl)) == TYPENAME_TYPE)
+  else if ((!abi_version_at_least (9) || TREE_CODE (decl) == TYPE_DECL)
+	   && TREE_CODE (TREE_TYPE (decl)) == TYPENAME_TYPE)
 {
   tree name = TYPENAME_TYPE_FULLNAME (TREE_TYPE (decl));
   if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
@@ -2621,7 +2622,7 @@ write_template_args (tree args)
   if (args)
 length = TREE_VEC_LENGTH (args);
 
-  if (args && TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_VEC)
+  if (args && length && TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_VEC)
 {
   /* We have nested template args.  We want the innermost template
 	 argument list.  */
diff --git a/gcc/testsuite/g++.dg/abi/mangle66.C b/gcc/testsuite/g++.dg/abi/mangle66.C
new file mode 100644
index 000..94ac08e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/mangle66.C
@@ -0,0 +1,10 @@
+// { dg-do compile { target c++11 } }
+
+namespace N {
+  template  using A = typename T::template X;
+}
+
+template class TT> struct B { };
+
+// { dg-final { scan-assembler "_Z1f1BIN1N1AEE" } }
+void f(B) {}
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-50.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-50.C
new file mode 100644
index 000..6839d34
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-50.C
@@ -0,0 +1,225 @@
+// PR c++/66067
+// { dg-do compile { target c++11 } }
+
+namespace std
+{
+  typedef int size_t;
+template < typename _Tp, _Tp > struct integral_constant
+  {
+static constexpr _Tp value = 0;
+typedef integral_constant type;
+  };
+  typedef integral_constant < int, 0 > true_type;
+  typedef integral_constant < int, 0 > false_type;
+template < typename _Tp > struct enable_if
+  {
+typedef _Tp type;
+  };
+}
+namespace meta
+{
+  inline namespace v1
+  {
+template < template < typename ... >class, typename ... >struct defer;
+  template < typename T > T * _nullptr_v (  );
+  template < int N > using size_t = std::integral_constant < int, N >;
+  template < int B > using bool_ = std::integral_constant < int, B >;
+  template < typename T > using dec =
+  std::integral_constant < decltype ( T::value ), 0 >;
+  template < typename T > using eval = typename T::type;
+  template < typename F, typename ... Args > using apply =
+  typename F::template apply < Args ... >;
+namespace detail
+{
+  template < typename > struct has_type_;
+}
+template < typename T > using has_type = eval < detail::has_type_ < T >>;
+  template < typename T > struct id
+{
+  using type = T;
+};
+  template < template < typename ... >class > struct quote;
+  template < typename > struct Trans_NS_extension_apply_list;
+  template < typename, typename List > using apply_list =
+  eval < Trans_NS_extension_apply_list < List >>;
+namespace detail
+{
+  template < typename ... >struct _if_;
+template < typename If, typename Then > struct _if_ :std::enable_if < Then >
+  {
+  };
+}
+template < typename ... Args > using if_ =
+  eval < detail::_if_ < Args ... >>;
+  template < int If, typename ... Args > using if_c =
+  eval < detail::_if_ < bool_ < If >, Args ... >>;
+namespace detail
+{
+  template < typename ... >struct _and_:std::true_type
+  {
+  };
+template < typename ... >struct _or_:std::false_type
+  {
+  };
+}
+template < int >using not_c = bool_ < 0 >;
+  template < typename Bool > using not_ = not_c < Bool::value >;
+  template < typename ... >using and_ = eval < detail::_and_ <>>;
+  template < typename > using or_ = eval < detail::_or_ <>>;
+namespace lazy
+{
+  template < typename ... Bools > using and_ = defer < and_, Bools ... >;
+}
+template < typename ... Ts > struct list
+{
+  static constexpr std::size_t size (  )
+  {
+	return sizeof ... ( Ts );
+  }
+};
+  template < typename List > using size = size_t < List::size (  ) >;
+namespace detail
+{
+  templat

C++ PATCH for c++/66255 (ICE with non-type template parameter of typedef type)

2015-06-26 Thread Jason Merrill
My checking code to make sure that we've stripped all appropriate 
typedefs wasn't considering that the parameter might have a typedef 
type, requiring the argument to match.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 63f562788d442b1139d1158a26129b781c16b07a
Author: Jason Merrill 
Date:   Thu Jun 25 12:13:16 2015 -0400

	PR c++/66255
	* pt.c (check_unstripped_args): Split out from...
	(retrieve_specialization): ...here.  Allow typedefs in the type of
	a non-type argument.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index fe5fc14..082e04c 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1019,6 +1019,35 @@ optimize_specialization_lookup_p (tree tmpl)
 	  && !DECL_FRIEND_P (DECL_TEMPLATE_RESULT (tmpl)));
 }
 
+/* Make sure ARGS doesn't use any inappropriate typedefs; we should have
+   gone through coerce_template_parms by now.  */
+
+static void
+check_unstripped_args (tree args)
+{
+#ifdef ENABLE_CHECKING
+  ++processing_template_decl;
+  if (!any_dependent_template_arguments_p (args))
+{
+  tree inner = INNERMOST_TEMPLATE_ARGS (args);
+  for (int i = 0; i < TREE_VEC_LENGTH (inner); ++i)
+	{
+	  tree arg = TREE_VEC_ELT (inner, i);
+	  if (TREE_CODE (arg) == TEMPLATE_DECL)
+	/* OK */;
+	  else if (TYPE_P (arg))
+	gcc_assert (strip_typedefs (arg, NULL) == arg);
+	  else if (strip_typedefs (TREE_TYPE (arg), NULL) != TREE_TYPE (arg))
+	/* Allow typedefs on the type of a non-type argument, since a
+	   parameter can have them.  */;
+	  else
+	gcc_assert (strip_typedefs_expr (arg, NULL) == arg);
+	}
+}
+  --processing_template_decl;
+#endif
+}
+
 /* Retrieve the specialization (in the sense of [temp.spec] - a
specialization is either an instantiation or an explicit
specialization) of TMPL for the given template ARGS.  If there is
@@ -1052,13 +1081,7 @@ retrieve_specialization (tree tmpl, tree args, hashval_t hash)
 		  ? TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (tmpl))
 		  : template_class_depth (DECL_CONTEXT (tmpl;
 
-#ifdef ENABLE_CHECKING
-  /* We should have gone through coerce_template_parms by now.  */
-  ++processing_template_decl;
-  if (!any_dependent_template_arguments_p (args))
-gcc_assert (strip_typedefs_expr (args, NULL) == args);
-  --processing_template_decl;
-#endif
+  check_unstripped_args (args);
 
   if (optimize_specialization_lookup_p (tmpl))
 {
diff --git a/gcc/testsuite/g++.dg/template/nontype27.C b/gcc/testsuite/g++.dg/template/nontype27.C
new file mode 100644
index 000..956e5e4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/nontype27.C
@@ -0,0 +1,9 @@
+// PR c++/66255
+
+typedef int int_t;
+
+template 
+struct S { };
+
+int_t a;
+S  b;


C++ PATCH for c++/66654 (ICE with copying NSDMI)

2015-06-26 Thread Jason Merrill
My recently added checking code to make sure that we didn't miss calling 
reshape_init for an aggregate initializer wasn't limiting itself to 
aggregate classes.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit bb4c1b72737952ae714f1586c0577f62b39337bc
Author: Jason Merrill 
Date:   Wed Jun 24 16:31:13 2015 -0400

	PR c++/66654
	* typeck2.c (digest_init_r): Only expect reshaping if the class is
	aggregate.

diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 30d93ed..7597de1 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1095,7 +1095,8 @@ digest_init_r (tree type, tree init, bool nested, int flags,
   if (cxx_dialect >= cxx11
   && BRACE_ENCLOSED_INITIALIZER_P (init)
   && CONSTRUCTOR_NELTS (init) == 1
-  && (CLASS_TYPE_P (type) || VECTOR_TYPE_P (type)))
+  && ((CLASS_TYPE_P (type) && !CLASSTYPE_NON_AGGREGATE (type))
+	  || VECTOR_TYPE_P (type)))
 {
   tree elt = CONSTRUCTOR_ELT (init, 0)->value;
   if (reference_related_p (type, TREE_TYPE (elt)))
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-list4.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list4.C
new file mode 100644
index 000..fe5be07
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list4.C
@@ -0,0 +1,9 @@
+// PR c++/66654
+// { dg-do compile { target c++11 } }
+
+class A {
+  A();
+};
+class B {
+  A r{r};
+};


Re: C PATCH to use VECTOR_TYPE_P

2015-06-26 Thread Joseph Myers
On Fri, 26 Jun 2015, Marek Polacek wrote:

> On Fri, Jun 26, 2015 at 06:02:22PM +0200, Marc Glisse wrote:
> > On Fri, 26 Jun 2015, Marek Polacek wrote:
> > 
> > >-  if (TREE_CODE (TREE_TYPE (mask)) != VECTOR_TYPE
> > >+  if (!VECTOR_TYPE_P (TREE_TYPE (mask))
> > >  || TREE_CODE (TREE_TYPE (TREE_TYPE (mask))) != INTEGER_TYPE)
> > 
> > This one looks like !VECTOR_INTEGER_TYPE_P
> 
> Fixed, thanks.
> 
> Bootstrapped/regtested on x86_64-linux.
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> 2015-06-26  Marek Polacek  
> 
>   * c-common.c (check_main_parameter_types): Use VECTOR_TYPE_P
>   or VECTOR_INTEGER_TYPE_P throughout.
>   * c-gimplify.c: Likewise.
> 
>   * c-typeck.c: Use VECTOR_TYPE_P throughout.

OK.

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


Re: C++ PATCH to use VAR_P

2015-06-26 Thread Jason Merrill

OK.

Jason


  1   2   >