Re: [patch,avr] Use avr-passes.def to register passes.

2016-10-11 Thread Denis Chertykov
2016-10-10 16:36 GMT+03:00 Georg-Johann Lay :
> This is a code clean-up using the new -passes.def feature in order
> to register avr target passes and to get -fdump-xxx etc. to work for such
> passes.
>
> Ok for trunk?
>
> Johann
>
> * config/avr/avr-passes.def: New file.
> * config/avr/t-avr (PASSES_EXTRA): Add avr-passes.def.
> * config/avr/avr-protos.h (gcc::context, rtl_opt_pass): Declare.
> (make_avr_pass_recompute_note): New proto.
> * config/avr/avr.c (make_avr_pass_recompute_notes): New function.
> (avr_pass_recompute_notes): Use anonymous namespace.
> (avr_register_passes): Remove function...
> (avr_option_override): ...and its call.

Please, apply.

Denis.


Re: [patch] Fix ICE on ACATS test for Aarch64 at -O

2016-10-11 Thread Eric Botcazou
Ping^2: https://gcc.gnu.org/ml/gcc-patches/2016-09/msg01781.html

> 2016-09-26  Eric Botcazou  
> 
>   * expmed.c (expand_shift_1): Add MAY_FAIL parameter and do not assert
>   that the result is non-zero if it is true.
>   (maybe_expand_shift): New wrapper around expand_shift_1.
>   (emit_store_flag): Call maybe_expand_shift in lieu of expand_shift.

-- 
Eric Botcazou


RE: [PATCH] Disable -mbranch-likely for -Os when targetting generic architecture

2016-10-11 Thread Robert Suchanek
Hi,

> > I'm happy to include this.  Ok to commit with this change?
> 
> This looks like it got lost at some point. I think this is a reasonable
> change for safety.
> 
> Go ahead and commit.
> 
> Thanks,
> Matthew

Committed as r240965.

Regards,
Robert


Re: [patch] Fix GC issue triggered by arithmetic overflow checking

2016-10-11 Thread Eric Botcazou
> I think only the calls in build_common_tree_nodes -- those are the ones
> built early and that survive GC.  The patch is ok if it passes testing
> with that.

Here's what I have installed, after bootstrap/regtesting on x86-64/Linux and 
SPARC/Solaris (with the upcoming overflow checking support).  I'll try and dig 
deeper into the var-tracking instability.


2016-10-11  Eric Botcazou  

* tree.h (build_complex_type): Add second parameter with default.
* tree.c (build_complex_type): Add NAMED second parameter and adjust
recursive call.  Create a TYPE_DECL only if NAMED is true.
(build_common_tree_nodes): Pass true in calls to build_complex_type.

-- 
Eric BotcazouIndex: tree.c
===
--- tree.c	(revision 240962)
+++ tree.c	(working copy)
@@ -8752,10 +8752,15 @@ build_offset_type (tree basetype, tree t
   return t;
 }
 
-/* Create a complex type whose components are COMPONENT_TYPE.  */
+/* Create a complex type whose components are COMPONENT_TYPE.
+
+   If NAMED is true, the type is given a TYPE_NAME.  We do not always
+   do so because this creates a DECL node and thus make the DECL_UIDs
+   dependent on the type canonicalization hashtable, which is GC-ed,
+   so the DECL_UIDs would not be stable wrt garbage collection.  */
 
 tree
-build_complex_type (tree component_type)
+build_complex_type (tree component_type, bool named)
 {
   tree t;
   inchash::hash hstate;
@@ -8782,11 +8787,11 @@ build_complex_type (tree component_type)
 	SET_TYPE_STRUCTURAL_EQUALITY (t);
   else if (TYPE_CANONICAL (component_type) != component_type)
 	TYPE_CANONICAL (t)
-	  = build_complex_type (TYPE_CANONICAL (component_type));
+	  = build_complex_type (TYPE_CANONICAL (component_type), named);
 }
 
   /* We need to create a name, since complex is a fundamental type.  */
-  if (! TYPE_NAME (t))
+  if (!TYPE_NAME (t) && named)
 {
   const char *name;
   if (component_type == char_type_node)
@@ -10372,10 +10377,11 @@ build_common_tree_nodes (bool signed_cha
   SET_TYPE_MODE (dfloat128_type_node, TDmode);
   dfloat128_ptr_type_node = build_pointer_type (dfloat128_type_node);
 
-  complex_integer_type_node = build_complex_type (integer_type_node);
-  complex_float_type_node = build_complex_type (float_type_node);
-  complex_double_type_node = build_complex_type (double_type_node);
-  complex_long_double_type_node = build_complex_type (long_double_type_node);
+  complex_integer_type_node = build_complex_type (integer_type_node, true);
+  complex_float_type_node = build_complex_type (float_type_node, true);
+  complex_double_type_node = build_complex_type (double_type_node, true);
+  complex_long_double_type_node = build_complex_type (long_double_type_node,
+		  true);
 
   for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
 {
Index: tree.h
===
--- tree.h	(revision 240962)
+++ tree.h	(working copy)
@@ -4042,7 +4042,7 @@ extern tree build_varargs_function_type_
 extern tree build_method_type_directly (tree, tree, tree);
 extern tree build_method_type (tree, tree);
 extern tree build_offset_type (tree, tree);
-extern tree build_complex_type (tree);
+extern tree build_complex_type (tree, bool named = false);
 extern tree array_type_nelts (const_tree);
 
 extern tree value_member (tree, tree);


[Visium] Tidy up Condition Code support

2016-10-11 Thread Eric Botcazou
This is in preparation for the overflow checking support: it untangles CCCmode 
and CC_NOOVmode, renaming the latter CCNZmode in the process.

Tested on visium-elf, applied on the mainline.


2016-10-11  Eric Botcazou  

* config/visium/visium-modes.def (CC_NOOV): Rename into...
(CCNZ): ...this.
(CC_BTST): Rename into...
(CCC): ...this.
* config/visium/predicates.md (real_add_operand): New.
(visium_btst_operator): Rename into...
(visium_equality_comparison_operator): ...this.
(visium_noov_operator): Rename into...
(visium_nz_comparison_operator): ...this.
(visium_c_comparison_operator): New.
(visium_branch_operator): Adjust and deal with all CC modes.
* config/visium/visium.c (visium_adjust_cost): Adjust.
(visium_split_double_add): Use the *_set_carry patterns.
(visium_select_cc_mode): Add support for CCC mode and adjust.
(output_cbranch): Adjust and use the carry-based operators for
floating-point comparisons.
* config/visium/visium.md (flags_subst_arith): Adjust.
(addsi3_insn_set_carry): New instruction.
(subsi3_insn_set_carry): Likewise.
(negsi2_insn_set_carry): Likewise.
(btst): Adjust.
(cmp_sne): Likewise.
(cbranch4): Use ordered_comparison_operator.
(cbranch4_insn): Likewise.
(cbranchsi4_btst_insn): Adjust.

-- 
Eric BotcazouIndex: config/visium/predicates.md
===
--- config/visium/predicates.md	(revision 240962)
+++ config/visium/predicates.md	(working copy)
@@ -112,6 +112,13 @@ (define_predicate "add_operand"
(and (match_code "const_int")
 (match_test ("INTVAL (op) >= -65535 && INTVAL (op) <= 65535")
 
+;; Return true if OP can be used as the second operand in a 32-bit or 64-bit
+;; add or subtract instruction directly, i.e. without the reverse trick.
+(define_predicate "real_add_operand"
+  (ior (match_operand 0 "gpc_reg_operand")
+   (and (match_code "const_int")
+(match_test ("INTVAL (op) >= 0 && INTVAL (op) <= 65535")
+
 ;; Return true if OP is (or could be) outside the range 0 .. 65535, which is
 ;; the range of the immediate operands, but accept -1 for NOT.
 (define_predicate "large_immediate_operand"
@@ -119,33 +126,41 @@ (define_predicate "large_immediate_opera
(and (match_code "const_int")
 (match_test ("INTVAL (op) < -1 || INTVAL (op) > 65535")
 
+;; Return true if OP is an equality comparison operator.
+(define_predicate "visium_equality_comparison_operator"
+  (match_code "eq,ne"))
+
+;; Return true if OP is a valid comparison operator for CCNZmode.
+(define_special_predicate "visium_nz_comparison_operator"
+  (match_code "eq,ne,lt,ge"))
+
+;; Return true if OP is a valid comparison operator for CCCmode.
+(define_special_predicate "visium_c_comparison_operator"
+  (match_code "eq,ne,ltu,geu"))
+
 ;; Return true if OP is a valid FP comparison operator.
 (define_predicate "visium_fp_comparison_operator"
   (match_code "eq,ne,ordered,unordered,unlt,unle,ungt,unge,lt,le,gt,ge"))
 
-;; Return true if OP is a valid comparison operator for CC_BTSTmode.
-(define_special_predicate "visium_btst_operator"
-  (match_code "eq,ne"))
-
-;; Return true if OP is a valid comparison operator for CC_NOOVmode.
-(define_special_predicate "visium_noov_operator"
-  (match_code "eq,ne,ge,lt"))
-
 ;; Return true if OP is a valid comparison operator for a branch.  This allows
 ;; the use of MATCH_OPERATOR to recognize all the branch insns.
 (define_predicate "visium_branch_operator"
   (match_operand 0 "comparison_operator")
 {
-  enum rtx_code code = GET_CODE (op);
-  /* These 2 comparison codes are not supported.  */
-  if (code == UNEQ || code == LTGT)
-return false;
-  enum machine_mode cc_mode = GET_MODE (XEXP (op, 0));
-  if (cc_mode == CC_NOOVmode)
-return visium_noov_operator (op, mode);
-  if (cc_mode == CC_BTSTmode)
-return visium_btst_operator (op, mode);
-  return true;
+  switch (GET_MODE (XEXP (op, 0)))
+{
+case CCmode:
+  return ordered_comparison_operator (op, mode);
+case CCNZmode:
+  return visium_nz_comparison_operator (op, mode);
+case CCCmode:
+  return visium_c_comparison_operator (op, mode);
+case CCFPmode:
+case CCFPEmode:
+  return visium_fp_comparison_operator (op, mode);
+default:
+  return false;
+}
 })
 
 ;; Return true if OP is a valid comparison operator for an integer cstore.
Index: config/visium/visium-modes.def
===
--- config/visium/visium-modes.def	(revision 240962)
+++ config/visium/visium-modes.def	(working copy)
@@ -19,19 +19,22 @@ along with GCC; see the file COPYING3.
 
 /* Add any extra modes needed to represent the condition code.
 
-   On the Visium, we have a "no-overflow" mode which is used when arithmetic
-   instruct

Re: [PING][PATCH 1/4][Ada,DJGPP] Ada support for DJGPP

2016-10-11 Thread Arnaud Charlet
> I'd like to ping this patch.
> 
> Last version of the patch together with Changelog entry can be found in
> mailing list archive:
> 
> https://gcc.gnu.org/ml/gcc-patches/2016-08/msg01229.html

This patch isn't OK, we don't want to add such special case in s-os_lib.adb

Arno


Re: [PING][PATCH 3/4][Ada,DJGPP] Ada support for DJGPP

2016-10-11 Thread Arnaud Charlet
> I'd like to ping patch
> 
> https://gcc.gnu.org/ml/gcc-patches/2016-09/msg00164.html
> 
> Additional comments about using ZCX_By_Default := true are in
> https://gcc.gnu.org/ml/gcc-patches/2016-09/msg00845.html

Well this patch doesn't inspire lots of confidence since the initial
version had the wrong setting and this got unnoticed.

It's OK on principle, but really shows that beyond building the compiler,
this port hasn't been used in practice.

Arno


[SPARC] Tidy up Condition Code support and more

2016-10-11 Thread Eric Botcazou
This was initially in preparation for the overflow checking support and aimed 
at untangling CCCmode and CC_NOOVmode, but ends up doing a little more:

 - add TARGET_FIXED_CONDITION_CODE_REGS hook to eliminate more explicitly 
redundant comparisons and, on V9, to generate more movcc instructions.

 - enable elimination of implicitly redundant comparisons with movcc on V9:

add %o0, 1, %o0
cmp %o0, 0
jmp %o7+8
 move   %icc, 1, %o0

   is changed into:

addcc   %o0, 1, %o0
jmp %o7+8
 move   %icc, 1, %o0

 - add support for the new "subxc" instruction introduced in Niagara-7:

cmp %o0, %o1
mov 0, %o0
jmp %o7+8
 movgeu %xcc, 1, %o0

   is changed into:

cmp %o0, %o1
jmp %o7+8
 subxc  %g0, -1, %o0

   if -msubxc is specified on the command line.

 - fix a buglet with -mvis3 whereby "addc" and "subc" were not used in 32-bit 
mode for some setcc operations.

 - add a couple of testcases for the new Compare-and-Branch instructions.


Tested on SPARC/Solaris, applied on the mainline.


2016-10-11  Eric Botcazou  

* config/sparc/sparc.opt (msubxc): New option.
* doc/invoke.texi (SPARC options): Document it and tidy up.
* doc/tm.texi.in (Condition Codes): Adjust SPARC example.
* doc/tm.texi: Regenerate.
* config/sparc/sparc-modes.def (CC_NOOV): Rename into...
(CCNZ): ...this.
(CCX_NOOV): Rename into...
(CCXNZ): ...this.
(CCC): New.
(CCXC): Likewise.
* config/sparc/predicates.m (fcc_register_operand): Simplify.
(fcc0_register_operand): Likewise.
(icc_register_operand): New.
(icc_or_fcc_register_operand): Simplify.
(nz_comparison_operator): New.
(c_comparison_operator): Likewise.
(noov_compare_operator): Rename into...
(icc_comparison_operator): ...this.  Use above predicates.
(noov_compare64_operator): Rename into...
(v9_comparison_operator): ...this and tidy up.
(fcc_comparison_operator): New.
(icc_or_fcc_comparison_operator): Likewise.
(v9_register_compare_operator): Rename info...
(v9_register_comparison_operator): ...this.
* config/sparc/sparc.c (TARGET_FIXED_CONDITION_CODE_REGS): Define.
(sparc_option_override): Remove redundant VIS masks and add MASK_SUBXC
for Niagara-7.
(sparc_fixed_condition_code_regs): New function.
(select_cc_mode): Remove ATTRIBUTE_UNUSED.  Adjust for CCNZ/CCXNZ
renaming and add support for CCC/CCXC.
(output_cbranch): Likewise.
(sparc_print_operand): Likewise.
(gen_v9_scc): Remove obsolete assertion.
(emit_scc_insn): Emit RTL directly for EQ and NE.  Add direct support
for EQ in DImode if TARGET_SUBXC.  Remove test on TARGET_VIS3 for GEU.
(output_cbcond): Remove bogus handling of CC modes.
(sparc_register_move_cost): Return 100 for NO_REGS.
* config/sparc/sparc.md (W): New mode iterator.
(length): Adjust for noov_compare64_operator renaming.
(cmpsi_sne): New instruction.
(cmpdi_sne): Likewise.
(seqdi_special): Delete.
(seqdi_special): Likewise.
(snesi_special): Likewise.
(snedi_special): Likewise.
(snedi_special_vis3): Likewise.
(snesi patterns): Use W iterator.
(snedi patterns): Likewise.  Add TARGET_SUBXC patterns.
(sltu patterns): Likewise.
(sgeu patterns): Likewise.
(scc splitter): Do not split GEU in DImode if TARGET_SUBXC.
(normal_branch): Use icc_comparison_operator predicate.
(inverted_branch): Likewise.
(cbcond_sp32): Use comparison_operator predicate.
(cbcond_sp64): Likewise.
(normal_int_branch_sp64): Adjust for renaming
(inverted_int_branch_sp64): Likewise.
(mov_cc_reg_sp64): Likewise.
(movsf_cc_reg_sp6): Likewise.
(movdf_cc_reg_sp64): Likewise.
(movtf_cc_reg_hq_sp64): Likewise.
(movtf_cc_reg_sp64): Likewise.
(mov_cc_v9): Use icc_or_fcc_comparison_operator predicate.
(movsf_cc_v9): Likewise.
(movdf_cc_v9): Likewise.
(movtf_cc_hq_v9): Likewise.
(movtf_cc_v9): Likewise.
(adddi3): Call gen_adddi3_sp32.
(adddi3_insn_sp32): Rename to...
(adddi3_sp32): ...this.  Accept only register_operand as operand #1
and use CCCmode for the carry.
(addx_extend_sp32): Use CCCmode for the carry.
(addx_extend_sp64): Delete.
(adddi3_extend_sp32): Use CCCmode for the carry.
(cmp_plus patterns): Use CCNZ/CCXNZ mode and add C variants.
(subdi3): Call gen_subdi3_sp32.
(subdi3_insn_sp32): Rename to...
(subdi3_sp32): ...this and use CCmode for the carry.
(subx_extend_sp32): Use CCCmode for the carry.
(subx_extend_sp64): Delete.
  

Re: [PATCH] Fix PR77826

2016-10-11 Thread Richard Biener
On Mon, 10 Oct 2016, Marc Glisse wrote:

> On Fri, 7 Oct 2016, Richard Biener wrote:
> 
> > On Thu, 6 Oct 2016, Marc Glisse wrote:
> > 
> > > On Wed, 5 Oct 2016, Richard Biener wrote:
> > > 
> > > > > The following will fix PR77826, the issue that in match.pd matching
> > > > > up two things uses operand_equal_p which is too lax about the type
> > > > > of the toplevel entity (at least for integer constants).
> > > > > 
> > > > > Bootstrap / regtest pending on x86_64-unknown-linux-gnu.
> > > > 
> > > > The following is what I have applied.
> > > > 
> > > > Richard.
> > > > 
> > > > 2016-10-05  Richard Biener  
> > > > 
> > > > PR middle-end/77826
> > > > * genmatch.c (dt_operand::gen_match_op): Amend operand_equal_p
> > > > with types_match for GIMPLE code gen to handle type mismatched
> > > > constants properly.
> > > 
> > > I don't understand the disparity between generic and gimple here. Why let
> > > (char)1 and (long)1 match in generic but not in gimple? And there are
> > > probably
> > > several transformations in match.pd that could do with an update if
> > > constants
> > > don't match anymore. Or did I misunderstand what the patch does?
> > 
> > The disparity is mostly that with GENERIC unfolded trees such as (char)1
> > are a bug while in GIMPLE the fact that the match.pd machinery does
> > valueization makes those a "feature" we have to deal with.  Originally
> > I've restricted GENERIC as well but with its types_match_p implementation
> > it resulted in too many missed matches.
> 
> I shouldn't have written (long)1, I meant the fact that 1 (as a char constant)
> and 1 (as a long constant) will now be matching captures in generic and not in
> gimple. If we are going in the direction of not matching constants of
> different types, I'd rather do it consistently and update the patterns as
> needed to avoid the missed optimizations. The missed matches exist in gimple
> as well, and generic optimization seems less important than gimple to me.

Yes, I agree.  I'll see on looking at the GENERIC fallout in more detail
(fixing patterns).

> An example that regressed at -O (looking at the .optimized dump)
> 
> int f(int a, unsigned b){
>   a &= 1;
>   b &= 1;
>   return a&b;
> }

Yeah, but it usually also shows a badly written pattern:

/* (X & Y) & (X & Z) -> (X & Y) & Z
   (X | Y) | (X | Z) -> (X | Y) | Z  */
(for op (bit_and bit_ior)
 (simplify
  (op:c (convert1?@3 (op:c@4 @0 @1)) (convert2?@5 (op:c@6 @0 @2)))
  (if (tree_nop_conversion_p (type, TREE_TYPE (@1))
   && tree_nop_conversion_p (type, TREE_TYPE (@2)))

so how could we ever match the @0s when we have either of the two 
conversions not present?  We could only do this then facing constants
(due to using operand_equal_p).  We for example fail to handle

 (X & Y) & (unsigned) ((singed)X & Z)

> If we stick to the old behavior, maybe we could have some genmatch magic to
> help with the constant capture weirdness. With matching captures, we could
> select which operand (among those supposed to be equivalent) is actually
> captured more cleverly, either with an explicit marker, or by giving priority
> to the one that is not immediatly below convert? in the pattern.

This route is a difficult one to take -- what would be possible is to
capture a specific operand.  Like allow one to write

 (op (op @0@4 @1) (op @0@3 @2))

and thus actually have three "names" for @0.  We have this internally
already when you write

 (convert?@0 @1)

for the case where there is no conversion.  @0 and @1 are the same
in this case.

Not sure if this helps enough cases.

I still think that having two things matched that are not really
the same is werid (and a possible source of errors as in, ICEs,
rather than missed optimizations).

> And if we move to stricter matching, maybe genmatch could be updated so
> convert could also match integer constants in some cases.

You mean when trying to match @0 ... (convert @0) and @0 is an INTEGER_CST
allow then (convert ...) case to match an INTEGER_CST of different type?
That's an interesting idea (not sure how to implement that though).

> > I agree that some transforms would need updates - I've actually tried
> > to implement a warning for genmatch whenever seeing a match with
> > (T)@0 but there isn't any good existing place to sneak that in.
> 
> 
> > > > * match.pd ((X /[ex] A) * A -> X): Properly handle converted
> > > > and constant A.
> > > 
> > > This regressed
> > > int f(int*a,int*b){return 4*(int)(b-a);}
> > 
> > This is because (int)(b-a) could be a truncation in which case
> > multiplying with 4 might not result in the same value as
> > b-a truncated(?).  The comment before the unpatched patterns
> > said "sign-changing conversions" but nothign actually verified this.
> > Might be that truncations are indeed ok now that I think about it.
> 
> 2015-05-22  Marc Glisse  
> 
> PR tree-optimization/63387
> * match.pd ((X /[ex] A) * A -> X): Remove unnecessar

[Ada] Remove system-linux-ppc64.ads

2016-10-11 Thread Eric Botcazou
This removes system-linux-ppc64.ads and makes system-linux-ppc.ads support 
both 32-bit and 64-bit modes.

Tested on PowerPC/Linux and PowerPC64/Linux, applied on the mainline.


2016-10-11  Eric Botcazou  
Tristan Gingold  

* system-linux-ppc64.ads: Delete.
* system-linux-ppc.ads: Make 32-bit/64-bit neutral.
* gcc-interface/Makefile.in (PowerPC/Linux): Simplify.

-- 
Eric BotcazouIndex: gcc-interface/Makefile.in
===
--- gcc-interface/Makefile.in	(revision 240962)
+++ gcc-interface/Makefile.in	(working copy)
@@ -1947,41 +1947,26 @@ ifeq ($(strip $(filter-out powerpc% linu
   s-tpopsp.adbhttp://www.gnu.org/licenses/>.  --
---  --
--- GNAT was originally developed  by the GNAT team at  New York University. --
--- Extensive contributions were provided by Ada Core Technologies Inc.  --
---  --
---
-
-package System is
-   pragma Pure;
-   --  Note that we take advantage of the implementation permission to make
-   --  this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
-   --  2005, this is Pure in any case (AI-362).
-
-   pragma No_Elaboration_Code_All;
-   --  Allow the use of that restriction in units that WITH this unit
-
-   type Name is (SYSTEM_NAME_GNAT);
-   System_Name : constant Name := SYSTEM_NAME_GNAT;
-
-   --  System-Dependent Named Numbers
-
-   Min_Int   : constant := Long_Long_Integer'First;
-   Max_Int   : constant := Long_Long_Integer'Last;
-
-   Max_Binary_Modulus: constant := 2 ** Long_Long_Integer'Size;
-   Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
-
-   Max_Base_Digits   : constant := Long_Long_Float'Digits;
-   Max_Digits: constant := Long_Long_Float'Digits;
-
-   Max_Mantissa  : constant := 63;
-   Fine_Delta: constant := 2.0 ** (-Max_Mantissa);
-
-   Tick  : constant := 0.000_001;
-
-   --  Storage-related Declarations
-
-   type Address is private;
-   pragma Preelaborable_Initialization (Address);
-   Null_Address : constant Address;
-
-   Storage_Unit : constant := 8;
-   Word_Size: constant := 64;
-   Memory_Size  : constant := 2 ** 64;
-
-   --  Address comparison
-
-   function "<"  (Left, Right : Address) return Boolean;
-   function "<=" (Left, Right : Address) return Boolean;
-   function ">"  (Left, Right : Address) return Boolean;
-   function ">=" (Left, Right : Address) return Boolean;
-   function "="  (Left, Right : Address) return Boolean;
-
-   pragma Import (Intrinsic, "<");
-   pragma Import (Intrinsic, "<=");
-   pragma Import (Intrinsic, ">");
-   pragma Import (Intrinsic, ">=");
-   pragma Import (Intrinsic, "=");
-
-   --  Other System-Dependent Declarations
-
-   type Bit_Order is (High_Order_First, Low_Order_First);
-   Default_Bit_Order : constant Bit_Order := High_Order_First;
-   pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
-
-   --  Priority-related Declarations (RM D.1)
-
-   --  0 .. 98 corresponds to the system priority range 1 .. 99.
-   --
-   --  If the scheduling policy is SCHED_FIFO or SCHED_RR the runtime makes use
-   --  of the entire range provided by the system.
-   --
-   --  If the scheduling policy is SCHED_OTHER the only valid system priority
-   --  is 1 and other values are simply ignored.
-
-   Max_Priority   : constant Positive := 97;
-   Max_Interrupt_Priority : constant Positive := 98;
-
-   subtype Any_Priority   is Integer  range  0 .. 98;
-   subtype Priority   is Any_Priority range  0 .. 97;
-   subtype Interrupt_Priority is Any_Priority range 98 .. 98;
-
-   Default_Priority : constant Priority := 48;
-
-private
-
-   type Address is mod Memory_Size;
-   Null_Address : constant Address := 0;
-
-   --
-   -- System Implementation Parameters --
-   --
-
-   --  These parameters provide information about the target that is used
-   --  by the compiler. They are in the private part of System, where they
-   --  can be accessed using the special circuitry in the Targparm unit
-   --  whose source should be consulted for more detailed descriptions
-   --  of the individual switch values.
-
-   Backend_Divide_Checks : constant Boolean := False;
-   Backend_Overflow_Checks   : constant Boolean := False;
-   Command_Line_Args : constant Boolean := True;
-   Configurable_Run_Time : constant Boolean := False;
-   Denorm: constant Boolean := True;
-   Duration_32_Bits  : constant Boolean := False;
-   Exit_Status_Supported : constant Boolean := True;
-   Fractional_Fixed_Ops  : constant Boole

Re: [PATCH 1/3] Fold __builtin_str{n}{case}cmp functions (version 2)

2016-10-11 Thread Martin Liška
On 10/07/2016 12:50 PM, Richard Biener wrote:
> On Fri, Oct 7, 2016 at 10:39 AM, Martin Liška  wrote:
>> I'm resending the patch, where I implemented all builtins mentions in subject
>> in gimp-fold.c.
>>
>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>
>> Ready to be installed?
> 
> +   case BUILT_IN_STRNCASECMP:
> + {
> +   r = strncmp (p1, p2, length);
> +   if (r == 0)
> + known_result = true;
> 
> length might be -1 here -- I think you need to guard against that (but you can
> handle BUILT_IN_STRCASECMP which you miss?).  Likewise for the strncmp case.

Fixed, I've added comment to STRCASECMP case.

> 
> Also do we know whether the c_getstr () result is '\0'-terminated?  AFAICS 
> these
> constant foldings were not implemented in builtins.c, I see a STRCMP one in
> fold-const-call.c though.  I believe the STRING_CST string is not guaranteed 
> to
> be '\0' terminated (STRING_CST comes with explicit length).

You are absolutely right that we do not have always '\0'-terminated string 
constants.
Thus I'll send a patch that would return a string from c_getstr just in case
string[string_length] == 0 (separate email with patch will be sent).

> 
> +  tree temp = fold_build2_loc (loc, MEM_REF, cst_uchar_node, str1,
> +  off0);
> +  temp = gimple_build (&stmts, loc, NOP_EXPR, cst_uchar_node, temp);
> 
> please don't use gimple_build here, there is nothing to simplify for it.  
> Using
> a NOP_EXPR is also confusing (to match the API...).  Just do
> gimple_build_assign (make_ssa_name (...), ..) like other folders do.
> 
> +  replace_call_with_value (gsi, fold_convert_loc (loc, type, temp));
> 
> and you'd want to replace the call with the MEM_REF stmt using
> gsi_replace_with_seq_vops as you fail to set virtual operands properly
> above (thus you'll get ICEs when this only matches during GIMPLE opts).
> 
> +  location_t loc = gimple_location (stmt);
> +  tree cst_uchar_node = build_type_variant (unsigned_char_type_node, 1, 0);
> +  tree cst_uchar_ptr_node
> += build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true);
> +  tree off0 = build_int_cst (cst_uchar_ptr_node, 0);
> 
> it would be nice to not do this tree building if nothign is folded.
> 
> +case BUILT_IN_STRCMP:
> +  return gimple_fold_builtin_string_compare (gsi);
> +case BUILT_IN_STRCASECMP:
> +  return gimple_fold_builtin_string_compare (gsi);
> +case BUILT_IN_STRNCMP:
> +  return gimple_fold_builtin_string_compare (gsi);
> +case BUILT_IN_STRNCASECMP:
> +  return gimple_fold_builtin_string_compare (gsi);
> 
> please do
> 
> +case BUILT_IN_STRCMP:
> +case BUILT_IN_STRCASECMP:
> ...
> +  return gimple_fold_builtin_string_compare (gsi);
> 
> Thanks,
> Richard.

Sure, all notes will be fixed in an email which reply to this one.

Martin

> 
>> Martin



[PATCH] Check \0-termination of string in c_getstr

2016-10-11 Thread Martin Liška
As mentioned in the email that I reply to, c_getstr should check
null termination of string constants.

Tests of the whole series have been running.

Thanks,
Martin
>From b446c659e839caa5ea5f36b06ec9110fe69f6e38 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Mon, 10 Oct 2016 12:13:12 +0200
Subject: [PATCH 1/5] Check \0-termination of string in c_getstr

gcc/ChangeLog:

2016-10-10  Martin Liska  

	* fold-const.c (c_getstr): Guard string termination.
---
 gcc/fold-const.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 02aa484..a9e8650 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -14451,13 +14451,20 @@ c_getstr (tree src)
   if (src == 0)
 return 0;
 
+  unsigned HOST_WIDE_INT string_length = TREE_STRING_LENGTH (src) - 1;
+  const char *string = TREE_STRING_POINTER (src);
+
+  /* If the string is not properly terminated, return 0.  */
+  if (string[string_length] != 0)
+return 0;
+
   if (offset_node == 0)
-return TREE_STRING_POINTER (src);
+return string;
   else if (!tree_fits_uhwi_p (offset_node)
-	   || compare_tree_int (offset_node, TREE_STRING_LENGTH (src) - 1) > 0)
+	   || compare_tree_int (offset_node, string_length) > 0)
 return 0;
 
-  return TREE_STRING_POINTER (src) + tree_to_uhwi (offset_node);
+  return string + tree_to_uhwi (offset_node);
 }
 
 #if CHECKING_P
-- 
2.9.2



[PATCH] Add a helper function: create_tmp

2016-10-11 Thread Martin Liška
Following patch is a small infrastructure enhancement
in gimple-fold.c.

Tests of the whole series have been running.

Thanks,
Martin
>From cf5983472b8482734393680493293811e5400d6e Mon Sep 17 00:00:00 2001
From: marxin 
Date: Tue, 11 Oct 2016 11:20:33 +0200
Subject: [PATCH 2/5] Add a helper function: create_tmp

gcc/ChangeLog:

2016-10-11  Martin Liska  

	* gimple-fold.c (create_tmp): New function.
	(gimple_fold_builtin_memory_op): Use the function.
	(gimple_fold_builtin_strchr): Likewise.
	(gimple_fold_builtin_strcat): Likewise.
	(gimple_build): Likewise.
---
 gcc/gimple-fold.c | 64 ---
 1 file changed, 23 insertions(+), 41 deletions(-)

diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 3aaa09c..348f331 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -171,6 +171,19 @@ can_refer_decl_in_current_unit_p (tree decl, tree from_decl)
   return !node || !node->global.inlined_to;
 }
 
+/* Create a temporary for TYPE for a statement STMT.  If the current function
+   is in SSA form, a SSA name is created.  Otherwise a temporary register
+   is made.  */
+
+static tree
+create_tmp (tree type, gimple *stmt = NULL)
+{
+  if (gimple_in_ssa_p (cfun))
+return make_ssa_name (type, stmt);
+  else
+return create_tmp_reg (type);
+}
+
 /* CVAL is value taken from DECL_INITIAL of variable.  Try to transform it into
acceptable form for is_gimple_min_invariant.
FROM_DECL (if non-NULL) specify variable whose constructor contains CVAL.  */
@@ -747,11 +760,7 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
 		  if (is_gimple_reg_type (TREE_TYPE (srcmem)))
 			{
 			  new_stmt = gimple_build_assign (NULL_TREE, srcmem);
-			  if (gimple_in_ssa_p (cfun))
-			srcmem = make_ssa_name (TREE_TYPE (srcmem),
-		new_stmt);
-			  else
-			srcmem = create_tmp_reg (TREE_TYPE (srcmem));
+			  srcmem = create_tmp (TREE_TYPE (srcmem), new_stmt);
 			  gimple_assign_set_lhs (new_stmt, srcmem);
 			  gimple_set_vuse (new_stmt, gimple_vuse (stmt));
 			  gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT);
@@ -1038,10 +1047,7 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
 	  if (! is_gimple_min_invariant (srcvar))
 	{
 	  new_stmt = gimple_build_assign (NULL_TREE, srcvar);
-	  if (gimple_in_ssa_p (cfun))
-		srcvar = make_ssa_name (TREE_TYPE (srcvar), new_stmt);
-	  else
-		srcvar = create_tmp_reg (TREE_TYPE (srcvar));
+	  srcvar = create_tmp (TREE_TYPE (srcvar), new_stmt);
 	  gimple_assign_set_lhs (new_stmt, srcvar);
 	  gimple_set_vuse (new_stmt, gimple_vuse (stmt));
 	  gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT);
@@ -1535,10 +1541,7 @@ gimple_fold_builtin_strchr (gimple_stmt_iterator *gsi, bool is_strrchr)
   gimple_seq stmts = NULL;
   gimple *new_stmt = gimple_build_call (strlen_fn, 1, str);
   gimple_set_location (new_stmt, loc);
-  if (gimple_in_ssa_p (cfun))
-len = make_ssa_name (size_type_node);
-  else
-len = create_tmp_reg (size_type_node);
+  len = create_tmp (size_type_node);
   gimple_call_set_lhs (new_stmt, len);
   gimple_seq_add_stmt_without_update (&stmts, new_stmt);
 
@@ -1611,10 +1614,7 @@ gimple_fold_builtin_strcat (gimple_stmt_iterator *gsi, tree dst, tree src)
   gimple_seq stmts = NULL, stmts2;
   gimple *repl = gimple_build_call (strlen_fn, 1, dst);
   gimple_set_location (repl, loc);
-  if (gimple_in_ssa_p (cfun))
-newdst = make_ssa_name (size_type_node);
-  else
-newdst = create_tmp_reg (size_type_node);
+  newdst = create_tmp (size_type_node);
   gimple_call_set_lhs (repl, newdst);
   gimple_seq_add_stmt_without_update (&stmts, repl);
 
@@ -6376,10 +6376,7 @@ gimple_build (gimple_seq *seq, location_t loc,
   tree res = gimple_simplify (code, type, op0, seq, gimple_build_valueize);
   if (!res)
 {
-  if (gimple_in_ssa_p (cfun))
-	res = make_ssa_name (type);
-  else
-	res = create_tmp_reg (type);
+  res = create_tmp (type);
   gimple *stmt;
   if (code == REALPART_EXPR
 	  || code == IMAGPART_EXPR
@@ -6405,10 +6402,7 @@ gimple_build (gimple_seq *seq, location_t loc,
   tree res = gimple_simplify (code, type, op0, op1, seq, gimple_build_valueize);
   if (!res)
 {
-  if (gimple_in_ssa_p (cfun))
-	res = make_ssa_name (type);
-  else
-	res = create_tmp_reg (type);
+  res = create_tmp (type);
   gimple *stmt = gimple_build_assign (res, code, op0, op1);
   gimple_set_location (stmt, loc);
   gimple_seq_add_stmt_without_update (seq, stmt);
@@ -6429,10 +6423,7 @@ gimple_build (gimple_seq *seq, location_t loc,
 			  seq, gimple_build_valueize);
   if (!res)
 {
-  if (gimple_in_ssa_p (cfun))
-	res = make_ssa_name (type);
-  else
-	res = create_tmp_reg (type);
+  res = create_tmp (type);
   gimple *stmt;
   if (code == BIT_FIELD_REF)
 	stmt = gimple_build_assign (res, code,
@@ -6462,10 +6453,7 @@ gimple_build (gimple_seq *seq, location_t loc,
   gimple *stmt = gimple_build

[committed] Use bool as return type

2016-10-11 Thread Marek Polacek
These two routines should have used bool as the return type.

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

2016-10-11  Marek Polacek  

* c-common.c (warning_candidate_p): Change the return type to bool
and return true/false instead of 1/0.
(vector_mode_valid_p): Likewise.

diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index 4437ffb..c4a0ce8 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -1881,7 +1881,7 @@ static struct tlist_cache *save_expr_cache;
 static void add_tlist (struct tlist **, struct tlist *, tree, int);
 static void merge_tlist (struct tlist **, struct tlist *, int);
 static void verify_tree (tree, struct tlist **, struct tlist **, tree);
-static int warning_candidate_p (tree);
+static bool warning_candidate_p (tree);
 static bool candidate_equal_p (const_tree, const_tree);
 static void warn_for_collisions (struct tlist *);
 static void warn_for_collisions_1 (tree, tree, struct tlist *, int);
@@ -2000,32 +2000,33 @@ warn_for_collisions (struct tlist *list)
 
 /* Return nonzero if X is a tree that can be verified by the sequence point
warnings.  */
-static int
+
+static bool
 warning_candidate_p (tree x)
 {
   if (DECL_P (x) && DECL_ARTIFICIAL (x))
-return 0;
+return false;
 
   if (TREE_CODE (x) == BLOCK)
-return 0;
+return false;
 
   /* VOID_TYPE_P (TREE_TYPE (x)) is workaround for cp/tree.c
  (lvalue_p) crash on TRY/CATCH. */
   if (TREE_TYPE (x) == NULL_TREE || VOID_TYPE_P (TREE_TYPE (x)))
-return 0;
+return false;
 
   if (!lvalue_p (x))
-return 0;
+return false;
 
   /* No point to track non-const calls, they will never satisfy
  operand_equal_p.  */
   if (TREE_CODE (x) == CALL_EXPR && (call_expr_flags (x) & ECF_CONST) == 0)
-return 0;
+return false;
 
   if (TREE_CODE (x) == STRING_CST)
-return 0;
+return false;
 
-  return 1;
+  return true;
 }
 
 /* Return nonzero if X and Y appear to be the same candidate (or NULL) */
@@ -6315,7 +6316,7 @@ handle_destructor_attribute (tree *node, tree name, tree 
args,
This returns nonzero even if there is no hardware support for the
vector mode, but we can emulate with narrower modes.  */
 
-static int
+static bool
 vector_mode_valid_p (machine_mode mode)
 {
   enum mode_class mclass = GET_MODE_CLASS (mode);
@@ -6328,11 +6329,11 @@ vector_mode_valid_p (machine_mode mode)
   && mclass != MODE_VECTOR_UFRACT
   && mclass != MODE_VECTOR_ACCUM
   && mclass != MODE_VECTOR_UACCUM)
-return 0;
+return false;
 
   /* Hardware support.  Woo hoo!  */
   if (targetm.vector_mode_supported_p (mode))
-return 1;
+return true;
 
   innermode = GET_MODE_INNER (mode);
 

Marek


[PATCH] Fold __builtin_str{n}{case}cmp functions (version 3)

2016-10-11 Thread Martin Liška
Changes from the previous version:

1) Handle BUILT_IN_STRNCMP with length == -1.
2) Direct gimple stmts creation and usage gsi_replace_with_seq_vops.
(hope using of replace_call_with_value is fine if replacing with a cst?)
3) lhs == NULL cases are handled (Or is it fine to replace with a nop in 
general?
Can change a semantic as it may touch a memory.)
4) CFN_BUILT_IN_STRNCMP can handle strncmp (x, y, 0).
5) Handling of CFN_BUILT_IN_STRNCASECMP is added.

Testing of the whole series has been running.

Martin
>From 925a998bacf2fffb811f1bb655674c869aa45a32 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Wed, 5 Oct 2016 13:18:35 +0200
Subject: [PATCH 3/5] Fold __builtin_str{n}{case}cmp functions

gcc/ChangeLog:

2016-10-06  Martin Liska  

	* builtins.c (fold_builtin_strcmp): Remove function.
	(fold_builtin_strncmp): Likewise.
	(fold_builtin_2): Do not call fold_builtin_strcmp.
	(fold_builtin_3): Do not call fold_builtin_strncmp.
	* fold-const-call.c: Make build_cmp_result global fn.
	* fold-const-call.h: Likewise.
	* gimple-fold.c (gimple_fold_builtin_string_compare): New
	function.
	(gimple_fold_builtin): Call the function.
	* fold-const-call.c (fold_const_call): Handle
	CFN_BUILT_IN_STRCASECMP, CFN_BUILT_IN_STRNCMP and
	CFN_BUILT_IN_STRNCASECMP.
---
 gcc/builtins.c| 138 -
 gcc/fold-const-call.c |  43 +---
 gcc/fold-const-call.h |   1 +
 gcc/gimple-fold.c | 187 +-
 4 files changed, 222 insertions(+), 147 deletions(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 6c68198..6696f28 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -150,8 +150,6 @@ static rtx expand_builtin_fabs (tree, rtx, rtx);
 static rtx expand_builtin_signbit (tree, rtx);
 static tree fold_builtin_memchr (location_t, tree, tree, tree, tree);
 static tree fold_builtin_memcmp (location_t, tree, tree, tree);
-static tree fold_builtin_strcmp (location_t, tree, tree);
-static tree fold_builtin_strncmp (location_t, tree, tree, tree);
 static tree fold_builtin_isascii (location_t, tree);
 static tree fold_builtin_toascii (location_t, tree);
 static tree fold_builtin_isdigit (location_t, tree);
@@ -7333,136 +7331,6 @@ fold_builtin_memcmp (location_t loc, tree arg1, tree arg2, tree len)
   return NULL_TREE;
 }
 
-/* Fold function call to builtin strcmp with arguments ARG1 and ARG2.
-   Return NULL_TREE if no simplification can be made.  */
-
-static tree
-fold_builtin_strcmp (location_t loc, tree arg1, tree arg2)
-{
-  if (!validate_arg (arg1, POINTER_TYPE)
-  || !validate_arg (arg2, POINTER_TYPE))
-return NULL_TREE;
-
-  /* If ARG1 and ARG2 are the same (and not volatile), return zero.  */
-  if (operand_equal_p (arg1, arg2, 0))
-return integer_zero_node;
-
-  /* If the second arg is "", return *(const unsigned char*)arg1.  */
-  const char *p2 = c_getstr (arg2);
-  if (p2 && *p2 == '\0')
-{
-  tree cst_uchar_node = build_type_variant (unsigned_char_type_node, 1, 0);
-  tree cst_uchar_ptr_node
-	= build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true);
-
-  return fold_convert_loc (loc, integer_type_node,
-			   build1 (INDIRECT_REF, cst_uchar_node,
-   fold_convert_loc (loc,
-			 cst_uchar_ptr_node,
-			 arg1)));
-}
-
-  /* If the first arg is "", return -*(const unsigned char*)arg2.  */
-  const char *p1 = c_getstr (arg1);
-  if (p1 && *p1 == '\0')
-{
-  tree cst_uchar_node = build_type_variant (unsigned_char_type_node, 1, 0);
-  tree cst_uchar_ptr_node
-	= build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true);
-
-  tree temp
-	= fold_convert_loc (loc, integer_type_node,
-			build1 (INDIRECT_REF, cst_uchar_node,
-fold_convert_loc (loc,
-		  cst_uchar_ptr_node,
-		  arg2)));
-  return fold_build1_loc (loc, NEGATE_EXPR, integer_type_node, temp);
-}
-
-  return NULL_TREE;
-}
-
-/* Fold function call to builtin strncmp with arguments ARG1, ARG2, and LEN.
-   Return NULL_TREE if no simplification can be made.  */
-
-static tree
-fold_builtin_strncmp (location_t loc, tree arg1, tree arg2, tree len)
-{
-  if (!validate_arg (arg1, POINTER_TYPE)
-  || !validate_arg (arg2, POINTER_TYPE)
-  || !validate_arg (len, INTEGER_TYPE))
-return NULL_TREE;
-
-  /* If the LEN parameter is zero, return zero.  */
-  if (integer_zerop (len))
-return omit_two_operands_loc (loc, integer_type_node, integer_zero_node,
-			  arg1, arg2);
-
-  /* If ARG1 and ARG2 are the same (and not volatile), return zero.  */
-  if (operand_equal_p (arg1, arg2, 0))
-return omit_one_operand_loc (loc, integer_type_node, integer_zero_node, len);
-
-  /* If the second arg is "", and the length is greater than zero,
- return *(const unsigned char*)arg1.  */
-  const char *p2 = c_getstr (arg2);
-  if (p2 && *p2 == '\0'
-  && TREE_CODE (len) == INTEGER_CST
-  && tree_int_cst_sgn (len) == 1)
-{
-  tree cst_uchar_node = build_type_v

[PATCH] Fold __builtin_memchr (version 3)

2016-10-11 Thread Martin Liška
On 10/07/2016 01:01 PM, Richard Biener wrote:
> On Fri, Oct 7, 2016 at 10:41 AM, Martin Liška  wrote:
>> Resending the patch, where I implemented folding in gimple-fold.c
>>
>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
> 
> +/* Fold a call to the str{n}{case}cmp builtin pointed by GSI iterator.
> +   FCODE is the name of the builtin.  */
> 
> wrong comment

Fixed.

> 
> +static bool
> +gimple_fold_builtin_memchr (gimple_stmt_iterator *gsi)
> 
> +   {
> + replace_call_with_value (gsi, build_int_cst (type, 0));
> 
> use ptr_type_node (void *) instead of type here and below.

Done.

> 
> + HOST_WIDE_INT offset = r - p1;
> + if (compare_tree_int (len, offset) <= 0)
> +   {
> 
> == 0 can occur in which case we have to return a pointer to the
> first char.  I think len < offset can't happen with memchr?

Here I reworked the patch as it's not desired to trigger an undefined behavior
in a host compiler for cases like: memchr ("", 'x', 5). Thus I switched to 
strchr
and aforementioned hunk would make sense.

> 
> + replace_call_with_value (gsi, build_int_cst (type, 0));
> + return true;
> +   }
> + else
> +   {
> + tree temp = fold_build_pointer_plus_hwi_loc (loc, arg1, offset);
> + replace_call_with_value (gsi, temp);
> 
> That yields valid GIMPLE by chance, I'd prefer if you'd built that to a
> stmt and use the replace-with-vops.

Done.

Apart from that I added handling of lhs and the patch supports folding
of CFN_BUILT_IN_MEMCHR.

One question that comes to my mind is whether there's a possibility
to fully test gimple folding of all cases if some of them are already
eaten by generic folding?

Tests of the series have been running.

Martin

> 
> + return true;
> +   }
> 
> 
>> Ready to be installed?
>> Martin

>From 37133bb09ddb23c87bb41ea6fffd5eba5af528fd Mon Sep 17 00:00:00 2001
From: marxin 
Date: Thu, 6 Oct 2016 17:52:45 +0200
Subject: [PATCH 4/5] Fold __builtin_memchr function

gcc/ChangeLog:

2016-10-06  Martin Liska  

	* builtins.h(target_char_cst_p): Declare the function.
	* builtins.c (fold_builtin_memchr): Remove.
	(target_char_cst_p): Move the function from gimple-fold.c.
	(fold_builtin_3): Do not call the function.
	* gimple-fold.c (gimple_fold_builtin_memchr): New function.
	(gimple_fold_builtin): Call the function.
	* fold-const-call.c (fold_const_call_1): Handle CFN_BUILT_IN_MEMCHR.
---
 gcc/builtins.c| 59 +---
 gcc/builtins.h|  1 +
 gcc/fold-const-call.c | 30 ++
 gcc/gimple-fold.c | 84 ++-
 4 files changed, 115 insertions(+), 59 deletions(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 6696f28..385e78e0 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -148,7 +148,6 @@ static tree rewrite_call_expr (location_t, tree, int, tree, int, ...);
 static bool validate_arg (const_tree, enum tree_code code);
 static rtx expand_builtin_fabs (tree, rtx, rtx);
 static rtx expand_builtin_signbit (tree, rtx);
-static tree fold_builtin_memchr (location_t, tree, tree, tree, tree);
 static tree fold_builtin_memcmp (location_t, tree, tree, tree);
 static tree fold_builtin_isascii (location_t, tree);
 static tree fold_builtin_toascii (location_t, tree);
@@ -7244,47 +7243,6 @@ fold_builtin_sincos (location_t loc,
 			 fold_build1_loc (loc, REALPART_EXPR, type, call)));
 }
 
-/* Fold function call to builtin memchr.  ARG1, ARG2 and LEN are the
-   arguments to the call, and TYPE is its return type.
-   Return NULL_TREE if no simplification can be made.  */
-
-static tree
-fold_builtin_memchr (location_t loc, tree arg1, tree arg2, tree len, tree type)
-{
-  if (!validate_arg (arg1, POINTER_TYPE)
-  || !validate_arg (arg2, INTEGER_TYPE)
-  || !validate_arg (len, INTEGER_TYPE))
-return NULL_TREE;
-  else
-{
-  const char *p1;
-
-  if (TREE_CODE (arg2) != INTEGER_CST
-	  || !tree_fits_uhwi_p (len))
-	return NULL_TREE;
-
-  p1 = c_getstr (arg1);
-  if (p1 && compare_tree_int (len, strlen (p1) + 1) <= 0)
-	{
-	  char c;
-	  const char *r;
-	  tree tem;
-
-	  if (target_char_cast (arg2, &c))
-	return NULL_TREE;
-
-	  r = (const char *) memchr (p1, c, tree_to_uhwi (len));
-
-	  if (r == NULL)
-	return build_int_cst (TREE_TYPE (arg1), 0);
-
-	  tem = fold_build_pointer_plus_hwi_loc (loc, arg1, r - p1);
-	  return fold_convert_loc (loc, type, tem);
-	}
-  return NULL_TREE;
-}
-}
-
 /* Fold function call to builtin memcmp with arguments ARG1 and ARG2.
Return NULL_TREE if no simplification can be made.  */
 
@@ -8340,9 +8298,6 @@ fold_builtin_3 (location_t loc, tree fndecl,
 	return do_mpfr_remquo (arg0, arg1, arg2);
 break;
 
-case BUILT_IN_MEMCHR:
-  return fold_builtin_memchr (loc, arg0, arg1, arg2, type);
-
 case BUILT_IN_BCMP:
 case BUILT_IN_MEMCMP:
   return fold_built

[PATCH] Test folding of str{n}{case}cmp and memchr (version 3)

2016-10-11 Thread Martin Liška
Third iteration of tests, where I added both GENERIC and GIMPLE folding
tests.

Martin
>From ac9020c31a6f5291c896a90aae594dd564420d95 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Tue, 16 Aug 2016 15:56:01 +0200
Subject: [PATCH 5/5] Test folding of str{n}{case}cmp and memchr

gcc/testsuite/ChangeLog:

2016-08-16  Martin Liska  

	* gcc.dg/tree-ssa/builtins-folding-generic.c: New test.
	* gcc.dg/tree-ssa/builtins-folding-gimple.c: New test.
---
 .../gcc.dg/tree-ssa/builtins-folding-generic.c |  76 +
 .../gcc.dg/tree-ssa/builtins-folding-gimple.c  | 126 +
 2 files changed, 202 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/builtins-folding-generic.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/builtins-folding-gimple.c

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtins-folding-generic.c b/gcc/testsuite/gcc.dg/tree-ssa/builtins-folding-generic.c
new file mode 100644
index 000..387be83
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtins-folding-generic.c
@@ -0,0 +1,76 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fdump-tree-original" } */
+
+char *buffer1;
+char *buffer2;
+
+#define SIZE 1000
+
+int
+main (void)
+{
+  const char* const foo1 = "hello world";
+
+  buffer1 = __builtin_malloc (SIZE);
+  __builtin_strcpy (buffer1, foo1);
+  buffer2 = __builtin_malloc (SIZE);
+  __builtin_strcpy (buffer2, foo1);
+
+  /* MEMCHR.  */
+  if (__builtin_memchr ("hello world", 'x', 11))
+__builtin_abort ();
+  if (__builtin_memchr ("hello world", 'x', 0) != 0)
+__builtin_abort ();
+  if (__builtin_memchr ("hello world", 'w', 2))
+__builtin_abort ();
+  if (__builtin_memchr ("hello world", 'd', 10))
+__builtin_abort ();
+  if (__builtin_memchr ("hello world", '\0', 11))
+__builtin_abort ();
+
+  /* STRCMP.  */
+  if (__builtin_strcmp ("hello", "a") <= 0)
+__builtin_abort ();
+  if (__builtin_strcmp ("a", "a") != 0)
+__builtin_abort ();
+  if (__builtin_strcmp ("a", "") <= 0)
+__builtin_abort ();
+  if (__builtin_strcmp ("", "a") >= 0)
+__builtin_abort ();
+  if (__builtin_strcmp ("ab", "ba") >= 0)
+__builtin_abort ();
+
+  /* STRNCMP.  */
+  if (__builtin_strncmp ("hello", "a", 0) != 0)
+__builtin_abort ();
+  if (__builtin_strncmp ("a", "a", 100) != 0)
+__builtin_abort ();
+  if (__builtin_strncmp ("a", "", 100) <= 0)
+__builtin_abort ();
+  if (__builtin_strncmp ("", "a", 100) >= 0)
+__builtin_abort ();
+  if (__builtin_strncmp ("ab", "ba", 1) >= 0)
+__builtin_abort ();
+  if (__builtin_strncmp ("aab", "aac", 2) != 0)
+__builtin_abort ();
+
+  /* STRCASECMP.  */
+  if (__builtin_strcasecmp ("a", "a") != 0)
+__builtin_abort ();
+
+  /* STRNCASECMP.  */
+  if (__builtin_strncasecmp ("hello", "a", 0) != 0)
+__builtin_abort ();
+  if (__builtin_strncasecmp ("a", "a", 100) != 0)
+__builtin_abort ();
+  if (__builtin_strncasecmp ("aab", "aac", 2) != 0)
+__builtin_abort ();
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-not "__builtin_strcmp" "original" } } */
+/* { dg-final { scan-tree-dump-not "__builtin_strcasecmp" "original" } } */
+/* { dg-final { scan-tree-dump-not "__builtin_strncmp" "original" } } */
+/* { dg-final { scan-tree-dump-not "__builtin_strncasecmp" "original" } } */
+/* { dg-final { scan-tree-dump-not "__builtin_memchr" "original" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtins-folding-gimple.c b/gcc/testsuite/gcc.dg/tree-ssa/builtins-folding-gimple.c
new file mode 100644
index 000..8a917bf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtins-folding-gimple.c
@@ -0,0 +1,126 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+char *buffer1;
+char *buffer2;
+
+#define SIZE 1000
+
+int
+main (void)
+{
+  const char* const foo1 = "hello world";
+
+  buffer1 = __builtin_malloc (SIZE);
+  __builtin_strcpy (buffer1, foo1);
+  buffer2 = __builtin_malloc (SIZE);
+  __builtin_strcpy (buffer2, foo1);
+
+  /* MEMCHR.  */
+  if (__builtin_memchr ("", 'x', 1000))
+__builtin_abort ();
+  if (__builtin_memchr (foo1, 'x', 1000))
+__builtin_abort ();
+  if (__builtin_memchr (foo1, 'x', 11))
+__builtin_abort ();
+  if (__builtin_memchr (buffer1, 'x', 0) != 0)
+__builtin_abort ();
+  if (__builtin_memchr (foo1, 'o', 11) != foo1 + 4)
+__builtin_abort ();
+  if (__builtin_memchr (foo1, 'w', 2))
+__builtin_abort ();
+  if (__builtin_memchr (foo1 + 5, 'o', 6) != foo1 + 7)
+__builtin_abort ();
+  if (__builtin_memchr (foo1, 'd', 11) != foo1 + 10)
+__builtin_abort ();
+  if (__builtin_memchr (foo1, 'd', 10))
+__builtin_abort ();
+  if (__builtin_memchr (foo1, '\0', 11))
+__builtin_abort ();
+  if (__builtin_memchr (foo1, '\0', 12) != foo1 + 11)
+__builtin_abort ();
+
+  __builtin_memchr (foo1, 'x', 11);
+  __builtin_memchr (buffer1, 'x', 0);
+  __builtin_memchr (foo1, 'w', 2);
+  __builtin_memchr (foo1, 'e', 5);
+
+  /* STRCMP.  *

[Ada] Fix wrong code for Unchecked_Conversion

2016-10-11 Thread Eric Botcazou
This fixes a wrong code regression present on the mainline, when an unsigned 
subtype of a signed base type is involved.

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


2016-10-11  Eric Botcazou  

* gcc-interface/utils.c (type_unsigned_for_rm): New predicate.
(make_type_from_size): Use it.
(unchecked_convert): Likewise.  Do not skip the extension step if the
source type is not integral.


2016-10-11  Eric Botcazou  

* gnat.dg/unchecked_convert10.adb: New test.
* gnat.dg/unchecked_convert11.adb: Likewise.
* gnat.dg/unchecked_convert12.adb: Likewise.

-- 
Eric BotcazouIndex: gcc-interface/utils.c
===
--- gcc-interface/utils.c	(revision 240962)
+++ gcc-interface/utils.c	(working copy)
@@ -1070,6 +1070,25 @@ make_packable_type (tree type, bool in_r
   return new_type;
 }
 
+/* Return true if TYPE has an unsigned representation.  This needs to be used
+   when the representation of types whose precision is not equal to their size
+   is manipulated based on the RM size.  */
+
+static inline bool
+type_unsigned_for_rm (tree type)
+{
+  /* This is the common case.  */
+  if (TYPE_UNSIGNED (type))
+return true;
+
+  /* See the E_Signed_Integer_Subtype case of gnat_to_gnu_entity.  */
+  if (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
+  && tree_int_cst_sgn (TYPE_MIN_VALUE (type)) >= 0)
+return true;
+
+  return false;
+}
+
 /* Given a type TYPE, return a new type whose size is appropriate for SIZE.
If TYPE is the best type, return it.  Otherwise, make a new type.  We
only support new integral and pointer types.  FOR_BIASED is true if
@@ -1113,10 +1132,7 @@ make_type_from_size (tree type, tree siz
   /* The type should be an unsigned type if the original type is unsigned
 	 or if the lower bound is constant and non-negative or if the type is
 	 biased, see E_Signed_Integer_Subtype case of gnat_to_gnu_entity.  */
-  if (TYPE_UNSIGNED (type)
-	  || (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
-	  && tree_int_cst_sgn (TYPE_MIN_VALUE (type)) >= 0)
-	  || biased_p)
+  if (type_unsigned_for_rm (type) || biased_p)
 	new_type = make_unsigned_type (size);
   else
 	new_type = make_signed_type (size);
@@ -4913,7 +4929,12 @@ can_fold_for_view_convert_p (tree expr)
 
we expect the 8 bits at Vbits'Address to always contain Value, while
their original location depends on the endianness, at Value'Address
-   on a little-endian architecture but not on a big-endian one.  */
+   on a little-endian architecture but not on a big-endian one.
+
+   One pitfall is that we cannot use TYPE_UNSIGNED directly to decide how
+   the bits between the precision and the size are filled, because of the
+   trick used in the E_Signed_Integer_Subtype case of gnat_to_gnu_entity.
+   So we use the special predicate type_unsigned_for_rm above.  */
 
 tree
 unchecked_convert (tree type, tree expr, bool notrunc_p)
@@ -4991,7 +5012,7 @@ unchecked_convert (tree type, tree expr,
 	TYPE_REVERSE_STORAGE_ORDER (rec_type)
 	  = TYPE_REVERSE_STORAGE_ORDER (etype);
 
-  if (TYPE_UNSIGNED (type))
+  if (type_unsigned_for_rm (type))
 	field_type = make_unsigned_type (prec);
   else
 	field_type = make_signed_type (prec);
@@ -5030,7 +5051,7 @@ unchecked_convert (tree type, tree expr,
 	TYPE_REVERSE_STORAGE_ORDER (rec_type)
 	  = TYPE_REVERSE_STORAGE_ORDER (type);
 
-  if (TYPE_UNSIGNED (etype))
+  if (type_unsigned_for_rm (etype))
 	field_type = make_unsigned_type (prec);
   else
 	field_type = make_signed_type (prec);
@@ -5131,31 +5152,26 @@ unchecked_convert (tree type, tree expr,
 	expr = build1 (VIEW_CONVERT_EXPR, type, expr);
 }
 
-  /* If the result is an integral type whose precision is not equal to its
- size, sign- or zero-extend the result.  We need not do this if the input
- is an integral type of the same precision and signedness or if the output
- is a biased type or if both the input and output are unsigned, or if the
- lower bound is constant and non-negative, see E_Signed_Integer_Subtype
- case of gnat_to_gnu_entity.  */
+  /* If the result is a non-biased integral type whose precision is not equal
+ to its size, sign- or zero-extend the result.  But we need not do this
+ if the input is also an integral type and both are unsigned or both are
+ signed and have the same precision.  */
   if (!notrunc_p
   && INTEGRAL_TYPE_P (type)
+  && !(code == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (type))
   && TYPE_RM_SIZE (type)
   && tree_int_cst_compare (TYPE_RM_SIZE (type), TYPE_SIZE (type)) < 0
   && !(INTEGRAL_TYPE_P (etype)
-	   && TYPE_UNSIGNED (type) == TYPE_UNSIGNED (etype)
-	   && tree_int_cst_compare (TYPE_RM_SIZE (type),
-TYPE_RM_SIZE (etype)
-? TYPE_RM_SIZE (etype)
-: TYPE_SIZE (etype)) == 0)
-  && !(code == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P 

[Ada] Adjust code generated for overflow checking

2016-10-11 Thread Eric Botcazou
This generates an explicit comparison against 0, which yields slightly better 
code than testing directly the value.


2016-10-11  Eric Botcazou  

* gcc-interface/trans.c (gnat_to_gnu) : Adjust comment.
: Add comment and missing guard.
* gcc-interface/trans.c (build_binary_op_trapv): Use an explicit test.

-- 
Eric BotcazouIndex: gcc-interface/trans.c
===
--- gcc-interface/trans.c	(revision 240962)
+++ gcc-interface/trans.c	(working copy)
@@ -6680,10 +6680,7 @@ gnat_to_gnu (Node_Id gnat_node)
 
 	/* Instead of expanding overflow checks for addition, subtraction
 	   and multiplication itself, the front end will leave this to
-	   the back end when Backend_Overflow_Checks_On_Target is set.
-	   As the back end itself does not know yet how to properly
-	   do overflow checking, do it here.  The goal is to push
-	   the expansions further into the back end over time.  */
+	   the back end when Backend_Overflow_Checks_On_Target is set.  */
 	if (Do_Overflow_Check (gnat_node)
 	&& Backend_Overflow_Checks_On_Target
 	&& (code == PLUS_EXPR || code == MINUS_EXPR || code == MULT_EXPR)
@@ -6754,7 +6751,11 @@ gnat_to_gnu (Node_Id gnat_node)
   gnu_expr = gnat_to_gnu (Right_Opnd (gnat_node));
   gnu_result_type = get_unpadded_type (Etype (gnat_node));
 
+  /* Instead of expanding overflow checks for negation and absolute
+	 value itself, the front end will leave this to the back end
+	 when Backend_Overflow_Checks_On_Target is set.  */
   if (Do_Overflow_Check (gnat_node)
+	  && Backend_Overflow_Checks_On_Target
 	  && !TYPE_UNSIGNED (gnu_result_type)
 	  && !FLOAT_TYPE_P (gnu_result_type))
 	gnu_result
@@ -8937,8 +8938,9 @@ build_binary_op_trapv (enum tree_code co
 	lhs, rhs);
   tree tgt = save_expr (call);
   gnu_expr = build1 (REALPART_EXPR, gnu_type, tgt);
-  check
-	= convert (boolean_type_node, build1 (IMAGPART_EXPR, gnu_type, tgt));
+  check = fold_build2 (NE_EXPR, boolean_type_node,
+			   build1 (IMAGPART_EXPR, gnu_type, tgt),
+			   build_int_cst (gnu_type, 0));
   return
 	emit_check (check, gnu_expr, CE_Overflow_Check_Failed, gnat_node);
}


[Ada] Improve quality of generated code for address clauses

2016-10-11 Thread Eric Botcazou
Tested on x86_64-suse-linux, applied on the mainline.


2016-10-11  Tristan Gingold  

* fe.h (Constant_Value): Declare.
* gcc-interface/decl.c (compile_time_known_address_p): Also consider
references to constants.

-- 
Eric BotcazouIndex: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 323965)
+++ gcc-interface/decl.c	(revision 323966)
@@ -6332,6 +6332,15 @@ array_type_has_nonaliased_component (tre
 static bool
 compile_time_known_address_p (Node_Id gnat_address)
 {
+  /* Handle reference to a constant.  */
+  if (Is_Entity_Name (gnat_address)
+  && Ekind (Entity (gnat_address)) == E_Constant)
+{
+  gnat_address = Constant_Value (Entity (gnat_address));
+  if (No (gnat_address))
+	return false;
+}
+
   /* Catch System'To_Address.  */
   if (Nkind (gnat_address) == N_Unchecked_Type_Conversion)
 gnat_address = Expression (gnat_address);
Index: fe.h
===
--- fe.h	(revision 323963)
+++ fe.h	(revision 323964)
@@ -6,7 +6,7 @@
  *  *
  *  C Header File   *
  *  *
- *  Copyright (C) 1992-2015, Free Software Foundation, Inc. *
+ *  Copyright (C) 1992-2016, Free Software Foundation, Inc. *
  *  *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -226,6 +226,7 @@ extern Boolean Is_Others_Aggregate (Node
 /* sem_aux:  */
 
 #define Ancestor_Subtype   sem_aux__ancestor_subtype
+#define Constant_Value sem_aux__constant_value
 #define First_Discriminant sem_aux__first_discriminant
 #define First_Stored_Discriminant  sem_aux__first_stored_discriminant
 #define First_Subtype  sem_aux__first_subtype
@@ -233,6 +234,7 @@ extern Boolean Is_Others_Aggregate (Node
 #define Is_Derived_Typesem_aux__is_derived_type
 
 extern Entity_Id  Ancestor_Subtype (Entity_Id);
+extern Node_IdConstant_Value   (Entity_Id);
 extern Entity_Id  First_Discriminant   (Entity_Id);
 extern Entity_Id  First_Stored_Discriminant(Entity_Id);
 extern Entity_Id  First_Subtype(Entity_Id);


[Ada] Fix missing debug info for variant record

2016-10-11 Thread Eric Botcazou
The problem is the early folding applied to the expressions based on the 
discriminant selecting the variant.

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


2016-10-11  Pierre-Marie de Rodat  

* gcc-interface/utils2.c (build_binary_op): Add a NO_FOLD
argument.  Disable folding when true.
* gcc-interface/gigi.h (choices_to_gnu): Remove declaration.
(build_binary_op): Update signature and comment.
* gcc-interface/decl.c (choices_to_gnu): Make static.  Disable
folding for all calls to build_binary_op.

-- 
Eric BotcazouIndex: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 240977)
+++ gcc-interface/decl.c	(working copy)
@@ -6832,7 +6832,7 @@ elaborate_reference (tree ref, Entity_Id
 /* Given a GNU tree and a GNAT list of choices, generate an expression to test
the value passed against the list of choices.  */
 
-tree
+static tree
 choices_to_gnu (tree operand, Node_Id choices)
 {
   Node_Id choice;
@@ -6851,9 +6851,10 @@ choices_to_gnu (tree operand, Node_Id ch
 	  this_test
 	= build_binary_op (TRUTH_ANDIF_EXPR, boolean_type_node,
 			   build_binary_op (GE_EXPR, boolean_type_node,
-		operand, low),
+		operand, low, true),
 			   build_binary_op (LE_EXPR, boolean_type_node,
-		operand, high));
+		operand, high, true),
+			   true);
 
 	  break;
 
@@ -6865,9 +6866,10 @@ choices_to_gnu (tree operand, Node_Id ch
 	  this_test
 	= build_binary_op (TRUTH_ANDIF_EXPR, boolean_type_node,
 			   build_binary_op (GE_EXPR, boolean_type_node,
-		operand, low),
+		operand, low, true),
 			   build_binary_op (LE_EXPR, boolean_type_node,
-		operand, high));
+		operand, high, true),
+			   true);
 	  break;
 
 	case N_Identifier:
@@ -6886,9 +6888,10 @@ choices_to_gnu (tree operand, Node_Id ch
 	  this_test
 		= build_binary_op (TRUTH_ANDIF_EXPR, boolean_type_node,
    build_binary_op (GE_EXPR, boolean_type_node,
-		operand, low),
+		operand, low, true),
    build_binary_op (LE_EXPR, boolean_type_node,
-		operand, high));
+		operand, high, true),
+   true);
 	  break;
 	}
 
@@ -6898,7 +6901,7 @@ choices_to_gnu (tree operand, Node_Id ch
 	case N_Integer_Literal:
 	  single = gnat_to_gnu (choice);
 	  this_test = build_binary_op (EQ_EXPR, boolean_type_node, operand,
-   single);
+   single, true);
 	  break;
 
 	case N_Others_Choice:
@@ -6909,8 +6912,11 @@ choices_to_gnu (tree operand, Node_Id ch
 	  gcc_unreachable ();
 	}
 
-  result = build_binary_op (TRUTH_ORIF_EXPR, boolean_type_node, result,
-this_test);
+  if (result == boolean_false_node)
+	result = this_test;
+  else
+	result = build_binary_op (TRUTH_ORIF_EXPR, boolean_type_node, result,
+  this_test, true);
 }
 
   return result;
Index: gcc-interface/gigi.h
===
--- gcc-interface/gigi.h	(revision 240962)
+++ gcc-interface/gigi.h	(working copy)
@@ -174,10 +174,6 @@ enum alias_set_op
 extern void relate_alias_sets (tree gnu_new_type, tree gnu_old_type,
 			   enum alias_set_op op);
 
-/* Given a GNU tree and a GNAT list of choices, generate an expression to test
-   the value passed against the list of choices.  */
-extern tree choices_to_gnu (tree operand, Node_Id choices);
-
 /* Given GNAT_ENTITY, an object (constant, variable, parameter, exception)
and GNU_TYPE, its corresponding GCC type, set Esize and Alignment to the
size and alignment used by Gigi.  Prefer SIZE over TYPE_SIZE if non-null.
@@ -860,9 +856,11 @@ extern tree build_load_modify_store (tre
 /* Make a binary operation of kind OP_CODE.  RESULT_TYPE is the type
desired for the result.  Usually the operation is to be performed
in that type.  For MODIFY_EXPR and ARRAY_REF, RESULT_TYPE may be 0
-   in which case the type to be used will be derived from the operands.  */
+   in which case the type to be used will be derived from the operands.
+   Don't fold the result if NO_FOLD is true.  */
 extern tree build_binary_op (enum tree_code op_code, tree result_type,
- tree left_operand, tree right_operand);
+			 tree left_operand, tree right_operand,
+			 bool no_fold=false);
 
 /* Similar, but make unary operation.  */
 extern tree build_unary_op (enum tree_code op_code, tree result_type,
Index: gcc-interface/utils2.c
===
--- gcc-interface/utils2.c	(revision 240962)
+++ gcc-interface/utils2.c	(working copy)
@@ -834,6 +834,7 @@ build_load_modify_store (tree dest, tree
in that type.  For INIT_EXPR and MODIFY_EXPR, RESULT_TYPE must be
NULL_TREE.  For ARRAY_REF, RESULT_TYPE may be NULL_TREE, in which
case the type to be used will be derived from the operands.
+   Don't fold the result if NO_FOLD is true.
 
This function is very

[PATCH, testsuite] Fix PR77710: incorrect wildchar target triplet

2016-10-11 Thread Thomas Preudhomme
I've applied the following commit as obvious to fix builtin-sprintf-warn-4.c 
excess error failure on arm-none-eabi due to incorrect wildchar target triplet.


ChangeLog entry is as follows:

*** gcc/testsuite/ChangeLog ***

2016-10-11  Thomas Preud'homme  

PR testsuite/PR77710
* gcc.dg/tree-ssa/builtin-sprintf-warn-4.c: Use *-*-* as catch-all
target triplet instead of *-*-*-*.


diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-4.c 
b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-4.c
index 
9fff2acb16764067029a61c305371fe2d38a3d9c..4b40336127e990d97a9c685ef1e25b2ae52063a6 
100644

--- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-4.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-4.c
@@ -8,8 +8,8 @@ char dst [8];
 void test (void)
 {
   sprintf (dst + 7, "%-s", "1");
-  /* { dg-warning "writing a terminating nul past the end of the destination" 
"" { target *-*-*-* } 10 }
- { dg-message "format output 2 bytes into a destination of size 1" "" { 
target *-*-*-* } 10 }
+  /* { dg-warning "writing a terminating nul past the end of the destination" 
"" { target *-*-* } 10 }
+ { dg-message "format output 2 bytes into a destination of size 1" "" { 
target *-*-* } 10 }

  { dg-begin-multiline-output "" }
sprintf (dst + 7, "%-s", "1");
   ~~^~
@@ -20,8 +20,8 @@ void test (void)
{ dg-end-multiline-output "" } */

   sprintf (dst + 7, "%-s", "abcd");
-  /* { dg-warning ".%-s. directive writing 4 bytes into a region of size 1" "" 
{ target *-*-*-* } 22 }
- { dg-message "format output 5 bytes into a destination of size 1" "" { 
target *-*-*-* } 22 }
+  /* { dg-warning ".%-s. directive writing 4 bytes into a region of size 1" "" 
{ target *-*-* } 22 }
+ { dg-message "format output 5 bytes into a destination of size 1" "" { 
target *-*-* } 22 }

  { dg-begin-multiline-output "" }
sprintf (dst + 7, "%-s", "abcd");
   ^~~   ~~


Best regards,

Thomas


Re: [PATCH 1/3] Fold __builtin_str{n}{case}cmp functions (version 2)

2016-10-11 Thread Richard Biener
On Tue, Oct 11, 2016 at 11:26 AM, Martin Liška  wrote:
> On 10/07/2016 12:50 PM, Richard Biener wrote:
>> On Fri, Oct 7, 2016 at 10:39 AM, Martin Liška  wrote:
>>> I'm resending the patch, where I implemented all builtins mentions in 
>>> subject
>>> in gimp-fold.c.
>>>
>>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>>
>>> Ready to be installed?
>>
>> +   case BUILT_IN_STRNCASECMP:
>> + {
>> +   r = strncmp (p1, p2, length);
>> +   if (r == 0)
>> + known_result = true;
>>
>> length might be -1 here -- I think you need to guard against that (but you 
>> can
>> handle BUILT_IN_STRCASECMP which you miss?).  Likewise for the strncmp case.
>
> Fixed, I've added comment to STRCASECMP case.
>
>>
>> Also do we know whether the c_getstr () result is '\0'-terminated?  AFAICS 
>> these
>> constant foldings were not implemented in builtins.c, I see a STRCMP one in
>> fold-const-call.c though.  I believe the STRING_CST string is not guaranteed 
>> to
>> be '\0' terminated (STRING_CST comes with explicit length).
>
> You are absolutely right that we do not have always '\0'-terminated string 
> constants.
> Thus I'll send a patch that would return a string from c_getstr just in case
> string[string_length] == 0 (separate email with patch will be sent).

Maybe add a second output to c_getstr to pass down the string length
in case it is known?

In this case you could use strN* () variants for constant folding.
"not found" would need
to be folded conditional on null termination to avoid folding
undefined behavior.

Richard.

>>
>> +  tree temp = fold_build2_loc (loc, MEM_REF, cst_uchar_node, str1,
>> +  off0);
>> +  temp = gimple_build (&stmts, loc, NOP_EXPR, cst_uchar_node, temp);
>>
>> please don't use gimple_build here, there is nothing to simplify for it.  
>> Using
>> a NOP_EXPR is also confusing (to match the API...).  Just do
>> gimple_build_assign (make_ssa_name (...), ..) like other folders do.
>>
>> +  replace_call_with_value (gsi, fold_convert_loc (loc, type, temp));
>>
>> and you'd want to replace the call with the MEM_REF stmt using
>> gsi_replace_with_seq_vops as you fail to set virtual operands properly
>> above (thus you'll get ICEs when this only matches during GIMPLE opts).
>>
>> +  location_t loc = gimple_location (stmt);
>> +  tree cst_uchar_node = build_type_variant (unsigned_char_type_node, 1, 0);
>> +  tree cst_uchar_ptr_node
>> += build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true);
>> +  tree off0 = build_int_cst (cst_uchar_ptr_node, 0);
>>
>> it would be nice to not do this tree building if nothign is folded.
>>
>> +case BUILT_IN_STRCMP:
>> +  return gimple_fold_builtin_string_compare (gsi);
>> +case BUILT_IN_STRCASECMP:
>> +  return gimple_fold_builtin_string_compare (gsi);
>> +case BUILT_IN_STRNCMP:
>> +  return gimple_fold_builtin_string_compare (gsi);
>> +case BUILT_IN_STRNCASECMP:
>> +  return gimple_fold_builtin_string_compare (gsi);
>>
>> please do
>>
>> +case BUILT_IN_STRCMP:
>> +case BUILT_IN_STRCASECMP:
>> ...
>> +  return gimple_fold_builtin_string_compare (gsi);
>>
>> Thanks,
>> Richard.
>
> Sure, all notes will be fixed in an email which reply to this one.
>
> Martin
>
>>
>>> Martin
>


Re: [PATCH] Check \0-termination of string in c_getstr

2016-10-11 Thread Richard Biener
On Tue, Oct 11, 2016 at 11:27 AM, Martin Liška  wrote:
> As mentioned in the email that I reply to, c_getstr should check
> null termination of string constants.
>
> Tests of the whole series have been running.

Looks ok to me (if testing passes).

Thanks,
Richard.

> Thanks,
> Martin


Re: [PATCH] Add a helper function: create_tmp

2016-10-11 Thread Richard Biener
On Tue, Oct 11, 2016 at 11:28 AM, Martin Liška  wrote:
> Following patch is a small infrastructure enhancement
> in gimple-fold.c.
>
> Tests of the whole series have been running.

Sorry to be picky, but can you rename it to create_reg_tmp?

Ok with that change.

RIchard.

> Thanks,
> Martin


Re: [PATCH] Add a helper function: create_tmp

2016-10-11 Thread Richard Biener
On Tue, Oct 11, 2016 at 12:29 PM, Richard Biener
 wrote:
> On Tue, Oct 11, 2016 at 11:28 AM, Martin Liška  wrote:
>> Following patch is a small infrastructure enhancement
>> in gimple-fold.c.
>>
>> Tests of the whole series have been running.
>
> Sorry to be picky, but can you rename it to create_reg_tmp?

Hrm.  Too easy to confuse with create_tmp_reg ... so maybe
create_tmp_reg_or_ssa_name?

> Ok with that change.
>
> RIchard.
>
>> Thanks,
>> Martin


Re: Compile-time improvement for if conversion.

2016-10-11 Thread Richard Biener
On Mon, Oct 10, 2016 at 4:17 PM, Yuri Rumyantsev  wrote:
> Richard,
>
> If "fake" exit or entry block is created in dominance how we can
> determine what is its the only  predecessor or successor without using
> a notion of loop?

The caller passes in an entry and exit edge instead of a block or loop.

Richard.

> 2016-10-10 15:00 GMT+03:00 Richard Biener :
>> On Mon, Oct 10, 2016 at 1:42 PM, Yuri Rumyantsev  wrote:
>>> Thanks Richard for your comments.
>>> I'd like to answer on your last comment regarding use split_edge()
>>> instead of creating fake post-header. I started with this splitting
>>> but it requires to fix-up closed ssa form by creating additional phi
>>> nodes, so I decided to use only cfg change without updating ssa form.
>>> Other changes look reasonable and will fix them.
>>
>> Ah.  In this case can you investigate what it takes to make the entry/exit
>> edges rather than BBs?  That is, introduce those "fakes" only internally
>> in dominance.c?
>>
>>> 2016-10-10 12:52 GMT+03:00 Richard Biener :
 On Wed, Oct 5, 2016 at 3:22 PM, Yuri Rumyantsev  wrote:
> Hi All,
>
> Here is implementation of Richard proposal:
>
> < For general infrastructure it would be nice to expose a (post-)dominator
> < compute for MESE (post-dominators) / SEME (dominators) regions.  I 
> believe
> < what makes if-conversion expensive is the post-dom compute which happens
> < for each loop for the whole function.  It shouldn't be very difficult
> < to write this,
> < sharing as much as possible code with the current DOM code might need
> < quite some refactoring though.
>
> I implemented this proposal by adding calculation of dominance info
> for SESE regions and incorporate this change to if conversion pass.
> SESE region is built by adding loop pre-header and possibly fake
> post-header blocks to loop body. Fake post-header is deleted after
> predication completion.
>
> Bootstrapping and regression testing did not show any new failures.
>
> Is it OK for trunk?

 It's mostly reasonable but I have a few comments.  First, re-using
 bb->dom[] for the dominator info is somewhat fragile but indeed
 a requirement to make the patch reasonably small.  Please,
 in calculate_dominance_info_for_region, make sure that
 !dom_info_available_p (dir).

 You pass loop * everywhere but require ->aux to be set up as
 an array of BBs forming the region with special BBs at array ends.

 Please instead pass in a vec which avoids using ->aux
 and also allows other non-loop-based SESE regions to be used
 (I couldn't spot anything that relies on this being a loop).

 Adding a convenience wrapper for loop  * would be of course nice,
 to cover the special pre/post-header code in tree-if-conv.c.

 In theory a SESE region is fully specified by its entry end exit _edge_,
 so you might want to see if it's possible to use such a pair of edges
 to guard the dfs/idom walks to avoid the need to create fake blocks.

 Btw, instead of using create_empty_bb, unchecked_make_edge, etc.
 please use split_edge() of the entry/exit edges.

 Richard.

> ChangeLog:
> 2016-10-05  Yuri Rumyantsev  
>
> * dominance.c : Include cfgloop.h for loop recognition.
> (dom_info): Add new functions and add boolean argument to recognize
> computation for loop region.
> (dom_info::dom_info): New function.
> (dom_info::calc_dfs_tree): Add boolean argument IN_REGION to not
> handle unvisited blocks.
> (dom_info::calc_idoms): Likewise.
> (compute_dom_fast_query_in_region): New function.
> (calculate_dominance_info): Invoke calc_dfs_tree and calc_idoms with
> false argument.
> (calculate_dominance_info_for_region): New function.
> (free_dominance_info_for_region): Likewise.
> (verify_dominators): Invoke calc_dfs_tree and calc_idoms with false
> argument.
> * dominance.h: Add prototype for introduced functions
> calculate_dominance_info_for_region and
> free_dominance_info_for_region.
> tree-if-conv.c: Add to local variables ifc_sese_bbs & fake_postheader.
> (build_sese_region): New function.
> (if_convertible_loop_p_1): Invoke local version of post-dominators
> calculation, free it after basic block predication and delete created
> fake post-header block if any.
> (tree_if_conversion): Delete call of free_dominance_info for
> post-dominators, free ifc_sese_bbs which represents SESE region.
> (pass_if_conversion::execute): Delete detection of infinite loops
> and fake edges to exit block since post-dominator calculation is
> performed per if-converted loop only.


fix -fmax-errors & notes

2016-10-11 Thread Nathan Sidwell

Hi,
Jonathan & I were chatting at the cauldron about how -fmax-errors kills any 
notes about the final error.  That's because we bail out just after emitting the 
final error.  This patch fixes the problem by bailing out just before emitting 
the error or warning after that.


Sure, we'll do slightly more compilation than asked for, but this is the fatal 
error path, so who cares how long it takes.  Better to get notes to the user.


I augmented the fmax-errors testcase so that the final emitted error has a 
trailing note (which we now emit), and is followed by a warning (which causes us 
to bail).


The same logic applies to -Wfatal-errors handling.

ok?

nathan
2016-10-11  Nathan Sidwell  

	* diagnostic.c (diagnostic_action_after_output): Remove fatal
	and max error handling here 
	(diagnostic_report_diagnostic): ... do it here instead.

	testsuite/
	* c-c++-common/fmax-errors.c: Add error with note.

Index: diagnostic.c
===
--- diagnostic.c	(revision 240920)
+++ diagnostic.c	(working copy)
@@ -464,24 +464,6 @@ diagnostic_action_after_output (diagnost
 case DK_SORRY:
   if (context->abort_on_error)
 	real_abort ();
-  if (context->fatal_errors)
-	{
-	  fnotice (stderr, "compilation terminated due to -Wfatal-errors.\n");
-	  diagnostic_finish (context);
-	  exit (FATAL_EXIT_CODE);
-	}
-  if (context->max_errors != 0
-	  && ((unsigned) (diagnostic_kind_count (context, DK_ERROR)
-			  + diagnostic_kind_count (context, DK_SORRY)
-			  + diagnostic_kind_count (context, DK_WERROR))
-	  >= context->max_errors))
-	{
-	  fnotice (stderr,
-		   "compilation terminated due to -fmax-errors=%u.\n",
-		   context->max_errors);
-	  diagnostic_finish (context);
-	  exit (FATAL_EXIT_CODE);
-	}
   break;
 
 case DK_ICE:
@@ -890,6 +872,25 @@ diagnostic_report_diagnostic (diagnostic
 	return false;
 }
 
+  if (diagnostic->kind != DK_NOTE
+  && (unsigned)(diagnostic_kind_count (context, DK_ERROR)
+		+ diagnostic_kind_count (context, DK_SORRY)
+		+ diagnostic_kind_count (context, DK_WERROR))
+  >= (context->fatal_errors ? 1
+	  : context->max_errors ? context->max_errors : ~0u))
+{
+  /* Check before emitting the diagnostic that would exceed the
+	 limit.  This way we will emit notes relevant to the final
+	 emitted error.  */
+  fnotice (stderr,
+	   context->fatal_errors
+	   ? "compilation terminated due to -Wfatal-errors.\n"
+	   : "compilation terminated due to -fmax-errors=%u.\n",
+	   context->max_errors);
+  diagnostic_finish (context);
+  exit (FATAL_EXIT_CODE);
+}
+
   context->lock++;
 
   if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
Index: testsuite/c-c++-common/fmax-errors.c
===
--- testsuite/c-c++-common/fmax-errors.c	(revision 240920)
+++ testsuite/c-c++-common/fmax-errors.c	(working copy)
@@ -1,11 +1,13 @@
 /* PR c/44782 */
 /* { dg-do compile } */
-/* { dg-options "-fmax-errors=3" } */
+/* { dg-options "-fmax-errors=3 -Wall" } */
 
 void foo (unsigned int i, unsigned int j)
 {
   (i) ();			/* { dg-error "" } */
   (j) ();			/* { dg-error "" } */
-  (i+j) ();			/* { dg-error "" } */
+  (k) ();			/* { dg-error "" } */
+  /* { dg-message "identifier" "" { target c } 9 } */
+  i + j; /* no warning.  */
   (i*j) ();			/* no error here due to -fmax-errors */
 } /* { dg-prune-output "compilation terminated" } */


[PATCH] More noexcept for standard mutex types and locks

2016-10-11 Thread Jonathan Wakely

These functions can all be noexcept (if we ever wanted to check the
mutex is owned by the calling thread in the adopt_lock ctors we'd
abort, not throw).

* include/bits/std_mutex.h (mutex::native_handle)
(lock_guard(mutex_type&, adopt_lock_t)
(unique_lock(mutex_type&, adopt_lock_t): Add noexcept.
* include/std/mutex (recursive_mutex, timed_mutex)
(recursive_timed_mutex): Likewise.

Tested powerpc64le-linux, committed to trunk.

commit 65e13b82ae0dac570b2e558d302bffa791d94375
Author: redi 
Date:   Tue Oct 11 10:33:16 2016 +

More noexcept for standard mutex types and locks

* include/bits/std_mutex.h (mutex::native_handle)
(lock_guard(mutex_type&, adopt_lock_t)
(unique_lock(mutex_type&, adopt_lock_t): Add noexcept.
* include/std/mutex (recursive_mutex, timed_mutex)
(recursive_timed_mutex): Likewise.

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

diff --git a/libstdc++-v3/include/bits/std_mutex.h 
b/libstdc++-v3/include/bits/std_mutex.h
index 49ef752..ad43841 100644
--- a/libstdc++-v3/include/bits/std_mutex.h
+++ b/libstdc++-v3/include/bits/std_mutex.h
@@ -122,7 +122,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 }
 
 native_handle_type
-native_handle()
+native_handle() noexcept
 { return &_M_mutex; }
   };
 
@@ -161,7 +161,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   explicit lock_guard(mutex_type& __m) : _M_device(__m)
   { _M_device.lock(); }
 
-  lock_guard(mutex_type& __m, adopt_lock_t) : _M_device(__m)
+  lock_guard(mutex_type& __m, adopt_lock_t) noexcept : _M_device(__m)
   { } // calling thread owns mutex
 
   ~lock_guard()
@@ -206,7 +206,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   : _M_device(std::__addressof(__m)), _M_owns(_M_device->try_lock())
   { }
 
-  unique_lock(mutex_type& __m, adopt_lock_t)
+  unique_lock(mutex_type& __m, adopt_lock_t) noexcept
   : _M_device(std::__addressof(__m)), _M_owns(true)
   {
// XXX calling thread owns mutex
diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex
index 1f4da57..7a7bd2e 100644
--- a/libstdc++-v3/include/std/mutex
+++ b/libstdc++-v3/include/std/mutex
@@ -124,7 +124,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 }
 
 native_handle_type
-native_handle()
+native_handle() noexcept
 { return &_M_mutex; }
   };
 
@@ -219,7 +219,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 }
 
 native_handle_type
-native_handle()
+native_handle() noexcept
 { return &_M_mutex; }
 
 private:
@@ -279,7 +279,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 }
 
 native_handle_type
-native_handle()
+native_handle() noexcept
 { return &_M_mutex; }
 
 private:


MAINTAINERS

2016-10-11 Thread Nathan Sidwell

Update my email address

nathan
2016-10-10  Nathan Sidwell  

	* MAINTAINERS: Update email address.

Index: MAINTAINERS
===
--- MAINTAINERS	(revision 240920)
+++ MAINTAINERS	(working copy)
@@ -86,7 +86,7 @@ nds32 port		Shiva Chen		
 nios2 port		Sandra Loosemore	
 nvptx port		Bernd Schmidt		
-nvptx port		Nathan Sidwell		
+nvptx port		Nathan Sidwell		
 pdp11 port		Paul Koning		
 picochip port		Daniel Towner		
 rl78 port		DJ Delorie		
@@ -134,7 +134,7 @@ RTEMS Ports		Ralf Corsepius		
 VMS			Douglas Rupp		
 VMS			Tristan Gingold		
-VxWorks ports		Nathan Sidwell		
+VxWorks ports		Nathan Sidwell		
 VxWorks ports		Olivier Hainque		
 cygwin, mingw-w64	Jonathan Yong		<10wa...@gmail.com>
 
@@ -145,7 +145,7 @@ C front end/ISO C99	Richard Henderson	
 Ada front end		Eric Botcazou		
 c++			Jason Merrill		
-c++			Nathan Sidwell		
+c++			Nathan Sidwell		
 go			Ian Lance Taylor	
 objective-c/c++		Mike Stump		
 objective-c/c++		Iain Sandoe		
@@ -216,7 +216,7 @@ docstring relicensing	Gerald Pfeifer		
 predict.def		Jan Hubicka		
 gcov			Jan Hubicka		
-gcov			Nathan Sidwell		
+gcov			Nathan Sidwell		
 option handling		Neil Booth		
 option handling		Joseph Myers		
 middle-end		Jeff Law		
@@ -226,7 +226,6 @@ tree-ssa		Andrew MacLeod		
 scev, data dependence	Sebastian Pop		
 profile feedback	Jan Hubicka		
-type-safe vectors	Nathan Sidwell		
 reload			Ulrich Weigand		
 reload			Bernd Schmidt		
 dfp.c, related		Ben Elliston		


[PATCH] Remove redundant const qualifliers from string_view

2016-10-11 Thread Jonathan Wakely

These return types cause "type qualifiers ignored on function return
type" warnings with -Wsystem-headers.

* include/experimental/string_view (basic_string_view::_S_compare):
Remove redundant const from return type.
* include/std/string_view (basic_string_view:_S_compare): Likewise.

Tested powerpc64le-linux, committed to trunk.

commit 18f41619e2e59ccbd0653f39bc1c983c225fe561
Author: redi 
Date:   Tue Oct 11 10:33:24 2016 +

Remove redundant const qualifliers from string_view

* include/experimental/string_view (basic_string_view::_S_compare):
Remove redundant const from return type.
* include/std/string_view (basic_string_view:_S_compare): Likewise.

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

diff --git a/libstdc++-v3/include/experimental/string_view 
b/libstdc++-v3/include/experimental/string_view
index 8cb8c1f..c1dfef0 100644
--- a/libstdc++-v3/include/experimental/string_view
+++ b/libstdc++-v3/include/experimental/string_view
@@ -420,7 +420,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 private:
 
-  static constexpr const int
+  static constexpr int
   _S_compare(size_type __n1, size_type __n2) noexcept
   {
return difference_type{__n1 - __n2} > std::numeric_limits::max()
diff --git a/libstdc++-v3/include/std/string_view 
b/libstdc++-v3/include/std/string_view
index 14bfcd0..b2d2a29 100644
--- a/libstdc++-v3/include/std/string_view
+++ b/libstdc++-v3/include/std/string_view
@@ -414,7 +414,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   
 private:
 
-  static constexpr const int
+  static constexpr int
   _S_compare(size_type __n1, size_type __n2) noexcept
   {
return difference_type{__n1 - __n2} > std::numeric_limits::max()


[PATCH] Enable printers and xmethods for std::__cxx11::list

2016-10-11 Thread Jonathan Wakely

This makes the python utils work for the new ABI list (they still need
to work with the new string as well).

* python/libstdcxx/v6/printers.py (build_libstdcxx_dictionary):
Register printer for std::__cxx11::list.
* python/libstdcxx/v6/xmethods.py (ListMethodsMatcher.match): Match
std::__cxx11::list as well as std::list.

Tested powerpc64le-linux, committed to trunk.

commit 0a9343a8b97b381d02576afa20702aa5536ae751
Author: redi 
Date:   Tue Oct 11 10:33:29 2016 +

Enable printers and xmethods for std::__cxx11::list

* python/libstdcxx/v6/printers.py (build_libstdcxx_dictionary):
Register printer for std::__cxx11::list.
* python/libstdcxx/v6/xmethods.py (ListMethodsMatcher.match): Match
std::__cxx11::list as well as std::list.

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

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py 
b/libstdc++-v3/python/libstdcxx/v6/printers.py
index b5fc2a0..714e1b8 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -1445,6 +1445,7 @@ def build_libstdcxx_dictionary ():
 libstdcxx_printer.add_container('std::', 'bitset', StdBitsetPrinter)
 libstdcxx_printer.add_container('std::', 'deque', StdDequePrinter)
 libstdcxx_printer.add_container('std::', 'list', StdListPrinter)
+libstdcxx_printer.add_container('std::__cxx11::', 'list', StdListPrinter)
 libstdcxx_printer.add_container('std::', 'map', StdMapPrinter)
 libstdcxx_printer.add_container('std::', 'multimap', StdMapPrinter)
 libstdcxx_printer.add_container('std::', 'multiset', StdSetPrinter)
diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py 
b/libstdc++-v3/python/libstdcxx/v6/xmethods.py
index eb0dd79..605cda1 100644
--- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py
+++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py
@@ -390,7 +390,7 @@ class ListMethodsMatcher(gdb.xmethod.XMethodMatcher):
 self.methods = [self._method_dict[m] for m in self._method_dict]
 
 def match(self, class_type, method_name):
-if not re.match('^std::list<.*>$', class_type.tag):
+if not re.match('^std::(__cxx11::)?list<.*>$', class_type.tag):
 return None
 method = self._method_dict.get(method_name)
 if method is None or not method.enabled:
diff --git a/libstdc++-v3/testsuite/libstdc++-xmethods/list.cc 
b/libstdc++-v3/testsuite/libstdc++-xmethods/list.cc
index ba20404..8fe0ad7 100644
--- a/libstdc++-v3/testsuite/libstdc++-xmethods/list.cc
+++ b/libstdc++-v3/testsuite/libstdc++-xmethods/list.cc
@@ -18,9 +18,6 @@
 // with this library; see the file COPYING3.  If not see
 // .
 
-// List xmethods only recognize the non cxx11 std::list for now.
-#define _GLIBCXX_USE_CXX11_ABI 0
-
 #include 
 
 int


[Ada] Fix various debug info issues with renaming

2016-10-11 Thread Eric Botcazou
GNAT encodings for object renamings that involve packed private types were not 
generated.  This is because we were not using Underlying_Type to analyze types 
involved.  This patch introduces Underlying_Type calls where necessary.  It 
also generates GNAT encodings renamings for byte unaligned objects, because 
gigi will not be able to materialize renamings when the object is not aligned 
on byte boundaries, so for the moment the only option to make it available in 
the debugger is to use GNAT encodings.  The rest is the materialization of 
renamings at -O0 in gigi.

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


2016-10-11  Pierre-Marie de Rodat  

* exp_dbug.adb (Debug_Renaming_Declaration): Process underlying types.
Emit GNAT encodings for object renamings involving record components
whose normalized bit offset is not null.
* uintp.h (UI_No_Uint): Declare.
* gcc-interface/gigi.h (can_materialize_object_renaming_p): New.
* gcc-interface/utils.c (can_materialize_object_renaming_p): New
function.
* gcc-interface/trans.c (gnat_to_gnu)
: In code generation mode,
materialize all renamings as long as they need debug info and we
are not optimizing.

-- 
Eric BotcazouIndex: exp_dbug.adb
===
--- exp_dbug.adb	(revision 240962)
+++ exp_dbug.adb	(working copy)
@@ -333,7 +333,7 @@ package body Exp_Dbug is
   
 
   procedure Enable_If_Packed_Array (N : Node_Id) is
- T : constant Entity_Id := Etype (N);
+ T : constant Entity_Id := Underlying_Type (Etype (N));
   begin
  Enable :=
Enable or else (Ekind (T) in Array_Kind
@@ -390,7 +390,16 @@ package body Exp_Dbug is
exit;
 
 when N_Selected_Component =>
-   Enable := Enable or else Is_Packed (Etype (Prefix (Ren)));
+   declare
+  First_Bit : constant Uint :=
+ Normalized_First_Bit (Entity (Selector_Name (Ren)));
+   begin
+  Enable :=
+(Enable
+ or else Is_Packed (Underlying_Type (Etype (Prefix (Ren
+ or else (First_Bit /= No_Uint
+  and then First_Bit /= Uint_0));
+   end;
Prepend_String_To_Buffer
  (Get_Name_String (Chars (Selector_Name (Ren;
Prepend_String_To_Buffer ("XR");
Index: gcc-interface/gigi.h
===
--- gcc-interface/gigi.h	(revision 240978)
+++ gcc-interface/gigi.h	(working copy)
@@ -1014,6 +1014,11 @@ extern void process_deferred_decl_contex
IS_SUBPROGRAM to whether the returned entity is a subprogram.  */
 extern Entity_Id get_debug_scope (Node_Id gnat_node, bool *is_subprogram);
 
+/* Return whether EXPR, which is the renamed object in an object renaming
+   declaration, can be materialized as a reference (REFERENCE_TYPE).  This
+   should be synchronized with Exp_Dbug.Debug_Renaming_Declaration.  */
+extern bool can_materialize_object_renaming_p (Node_Id expr);
+
 #ifdef __cplusplus
 extern "C" {
 #endif
Index: gcc-interface/trans.c
===
--- gcc-interface/trans.c	(revision 240976)
+++ gcc-interface/trans.c	(working copy)
@@ -6084,10 +6084,18 @@ gnat_to_gnu (Node_Id gnat_node)
   gnat_temp = Defining_Entity (gnat_node);
   gnu_result = alloc_stmt_list ();
 
-  /* Don't do anything if this renaming is handled by the front end or if
-	 we are just annotating types and this object has a composite or task
-	 type, don't elaborate it.  */
-  if (!Is_Renaming_Of_Object (gnat_temp)
+  /* Don't do anything if this renaming is handled by the front end and it
+	 does not need debug info.  Note that we consider renamings don't need
+	 debug info when optimizing: our way to describe them has a
+	 memory/elaboration footprint.
+
+	 Don't do anything neither if we are just annotating types and this
+	 object has a composite or task type, don't elaborate it.  */
+  if ((!Is_Renaming_Of_Object (gnat_temp)
+	   || (Needs_Debug_Info (gnat_temp)
+	   && !optimize
+	   && can_materialize_object_renaming_p
+		(Renamed_Object (gnat_temp
 	  && ! (type_annotate_only
 		&& (Is_Array_Type (Etype (gnat_temp))
 		|| Is_Record_Type (Etype (gnat_temp))
Index: gcc-interface/utils.c
===
--- gcc-interface/utils.c	(revision 240975)
+++ gcc-interface/utils.c	(working copy)
@@ -6185,6 +6185,58 @@ handle_vector_type_attribute (tree *node
   return NULL_TREE;
 }
 
+/* Return whether EXPR, which is the renamed object in an object renaming
+   declaration, can be materialized as a reference (REFERENCE_TYPE).  This
+   should be synchronized with Exp_Dbug.Debug_R

Re: [PATCH][AArch64] Add spellchecking hints for -march,-mcpu,-mtune and their attributes

2016-10-11 Thread James Greenhalgh
On Fri, Oct 07, 2016 at 01:34:37PM -0700, Andrew Pinski wrote:
> On Fri, Oct 7, 2016 at 7:52 AM, Kyrill Tkachov
>  wrote:
> > Hi all,
> >
> > This patch uses the spellcheck API from David and Jakub [1] to implement
> > hints for the
> > march, mcpu and mtune options to suggest appropriate architectures and CPU
> > names
> > for users.  It also adds such hints for the equivalent arch, cpu, tune
> > attributes.
> > Architecture extensions like 'crc', 'crypto' are not handled in this patch
> > as they
> > can be combined and modified with '+no' so it would be quite tricky. But if
> > a user
> > misspells those we just give a proper "unknown modifier" error. The hints
> > appear
> > only when the actual CPU or architecture name is misspelled.
> >
> > Bootstrapped and tested on aarch64-none-linux-gnu.
> >
> > Ok for trunk?
> 
> 
> I like this idea.  Though I need to check how it will interact with my
> patch set which I am doing right now to support some more of Cavium's
> SOCs.

I also like it. OK from me, but give Andrew another day to come back with
any objections.

Thanks,
James

> 
> Thanks,
> Andrew Pinski
> 
> >
> > Thanks,
> > Kyrill
> >
> > [1] https://gcc.gnu.org/ml/gcc-patches/2016-09/msg00339.html
> >
> > 2016-10-07  Kyrylo Tkachov  
> >
> > * config/aarch64/aarch64.c (aarch64_print_hint_for_core_or_arch):
> > New function.
> > (aarch64_print_hint_for_core): Likewise.
> > (aarch64_print_hint_for_arch): Likewise.
> > (aarch64_validate_march): Use it.  Fix indentation in type signature.
> > (aarch64_validate_mcpu): Use aarch64_print_hint_for_core_or_arch.
> > (aarch64_validate_mtune): Likewise.
> > (aarch64_handle_attr_arch): Likewise.
> > (aarch64_handle_attr_cpu): Likewise.
> > (aarch64_handle_attr_tune): Likewise.
> >
> > 2016-10-07  Kyrylo Tkachov  
> >
> > * gcc.target/aarch64/spellcheck_1.c: New test.
> > * gcc.target/aarch64/spellcheck_2.c: Likewise.
> > * gcc.target/aarch64/spellcheck_3.c: Likewise.
> > * gcc.target/aarch64/spellcheck_4.c: Likewise.
> > * gcc.target/aarch64/spellcheck_5.c: Likewise.
> > * gcc.target/aarch64/spellcheck_6.c: Likewise.
> 



[Patch, testsuite] Fix gcc.g/tree-ssa/pr59597.c failure for avr

2016-10-11 Thread Senthil Kumar Selvaraj
Hi,

  This patch declares loop index variable j as a 32 bit int instead of
  assuming ints are 32 bits. The smaller int size on the avr makes prior
  passes optimize away the loop exit check (j < 1000), as the constant
  is outside the range of a 16 bit int.

  Committed to trunk, after reg testing with avr and x86_64-pc-linux

Regards
Senthil

gcc/testsuite/ChangeLog

2016-10-11  Senthil Kumar Selvaraj  

* gcc.dg/tree-ssa/pr59597.c: Typedef  __INT32_TYPE__ to i32.
(main): Declare j as i32 instead of int.

Index: gcc/testsuite/gcc.dg/tree-ssa/pr59597.c
===
--- gcc/testsuite/gcc.dg/tree-ssa/pr59597.c (revision 240974)
+++ gcc/testsuite/gcc.dg/tree-ssa/pr59597.c (working copy)
@@ -4,6 +4,8 @@
 typedef unsigned short u16;
 typedef unsigned char u8;
 typedef unsigned int u32;
+__extension__ typedef __INT32_TYPE__ i32;
+
 long int random(int);
 #define NNN 10
 
@@ -37,7 +39,7 @@
 int
 main (int argc, char argv[])
 {
-  int i, j; u16 crc;
+  int i; i32 j; u16 crc;
   for (j = 0; j < 1000; j++)
 {
   for (i = 0; i < NNN; i++)


[PATCH] Simplify std::rethrow_if_nested definition

2016-10-11 Thread Jonathan Wakely

Originally this header didn't use , but we install that
for freestanding builds now, so it's always available. That means we
can simplify things a bit, using remove_reference, enable_if etc.

This also implements the missing part of LWG 2484, so that we don't
try to use dynamic_cast when the static type would make it ill-formed.

* doc/xml/manual/intro.xml: Document LWG 2484 status.
* libsupc++/nested_exception.h (_Throw_with_nested_impl)
(_Throw_with_nested_helper): Remove.
(__throw_with_nested_impl): New overloaded functions to implement
throw_with_nested logic.
(throw_with_nested): Call __throw_with_nested_impl.
(_Rethrow_if_nested_impl): Remove
(__rethrow_if_nested_impl): New overloaded functions to implement
rethrow_if_nested logic.
(rethrow_if_nested): Call __rethrow_if_nested_impl.
* testsuite/18_support/nested_exception/rethrow_if_nested.cc: Test
problem cases from LWG 2484.

Tested powerpc64le-linux, committed to trunk.

commit 06046b8db3d2060cb52a87b6771031e70abfef00
Author: redi 
Date:   Tue Oct 11 10:33:36 2016 +

Simplify std::rethrow_if_nested definition

* doc/xml/manual/intro.xml: Document LWG 2484 status.
* libsupc++/nested_exception.h (_Throw_with_nested_impl)
(_Throw_with_nested_helper): Remove.
(__throw_with_nested_impl): New overloaded functions to implement
throw_with_nested logic.
(throw_with_nested): Call __throw_with_nested_impl.
(_Rethrow_if_nested_impl): Remove
(__rethrow_if_nested_impl): New overloaded functions to implement
rethrow_if_nested logic.
(rethrow_if_nested): Call __rethrow_if_nested_impl.
* testsuite/18_support/nested_exception/rethrow_if_nested.cc: Test
problem cases from LWG 2484.

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

diff --git a/libstdc++-v3/doc/xml/manual/intro.xml 
b/libstdc++-v3/doc/xml/manual/intro.xml
index 265ef67..22b792a 100644
--- a/libstdc++-v3/doc/xml/manual/intro.xml
+++ b/libstdc++-v3/doc/xml/manual/intro.xml
@@ -1078,6 +1078,14 @@ requirements of the license of GCC.
 Divide by the object type.
 
 
+http://www.w3.org/1999/xlink"; 
xlink:href="../ext/lwg-defects.html#2484">2484:
+   rethrow_if_nested()  is doubly unimplementable
+   
+
+Avoid using dynamic_cast when it would be
+ill-formed.
+
+
 http://www.w3.org/1999/xlink"; 
xlink:href="../ext/lwg-defects.html#2583">2583:
There is no way to supply an allocator for  
basic_string(str, pos)

diff --git a/libstdc++-v3/libsupc++/nested_exception.h 
b/libstdc++-v3/libsupc++/nested_exception.h
index 377b803..0c00d74 100644
--- a/libstdc++-v3/libsupc++/nested_exception.h
+++ b/libstdc++-v3/libsupc++/nested_exception.h
@@ -92,41 +92,21 @@ namespace std
   { }
 };
 
-  template
-struct _Throw_with_nested_impl
+  // [except.nested]/8
+  // Throw an exception of unspecified type that is publicly derived from
+  // both remove_reference_t<_Tp> and nested_exception.
+  template
+inline void
+__throw_with_nested_impl(_Tp&& __t, true_type)
 {
-  template
-   static void _S_throw(_Up&& __t)
-   { throw _Nested_exception<_Tp>{static_cast<_Up&&>(__t)}; }
-};
+  using _Up = typename remove_reference<_Tp>::type;
+  throw _Nested_exception<_Up>{std::forward<_Tp>(__t)};
+}
 
   template
-struct _Throw_with_nested_impl<_Tp, false>
-{
-  template
-   static void _S_throw(_Up&& __t)
-   { throw static_cast<_Up&&>(__t); }
-};
-
-  template
-struct _Throw_with_nested_helper : _Throw_with_nested_impl<_Tp>
-{ };
-
-  template
-struct _Throw_with_nested_helper<_Tp, false>
-: _Throw_with_nested_impl<_Tp, false>
-{ };
-
-  template
-struct _Throw_with_nested_helper<_Tp&, false>
-: _Throw_with_nested_helper<_Tp>
-{ };
-
-  template
-struct _Throw_with_nested_helper<_Tp&&, false>
-: _Throw_with_nested_helper<_Tp>
-{ };
+inline void
+__throw_with_nested_impl(_Tp&& __t, false_type)
+{ throw std::forward<_Tp>(__t); }
 
   /// If @p __t is derived from nested_exception, throws @p __t.
   /// Else, throws an implementation-defined object derived from both.
@@ -135,33 +115,43 @@ namespace std
 inline void
 throw_with_nested(_Tp&& __t)
 {
-  _Throw_with_nested_helper<_Tp>::_S_throw(static_cast<_Tp&&>(__t));
+  using _Up = typename remove_reference<_Tp>::type;
+  using _CopyConstructible
+   = __and_, is_move_constructible<_Up>>;
+  static_assert(_CopyConstructible::value,
+ "throw_with_nested argument must be CopyConstructible");
+  using __nest = __and_, __bool_constant,
+   __not_>>;
+  return std::__throw_with_nested_impl(std::forward<_Tp>(__t), __nest{});
 }
 
-  template
-struct _Rethrow_if_nested_impl
-   

[PATCH] Optimise std::list::assign(initializer_list) slightly

2016-10-11 Thread Jonathan Wakely

This is a microoptimisation to call the relevant _M_assign_dispatch
function directly (because we know we have iterators), rather than
calling assign() to do the dispatching.

* include/bits/stl_list.h (assign(initializer_list)): Call
_M_assign_dispatch directly with correct tag.

Tested powerpc64le-linux, committed to trunk.
commit 72d50c42a61a1627d54e0213b5112575950063ba
Author: redi 
Date:   Tue Oct 11 10:33:41 2016 +

Optimise std::list::assign(initializer_list) slightly

* include/bits/stl_list.h (assign(initializer_list)): Call
_M_assign_dispatch directly with correct tag.

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

diff --git a/libstdc++-v3/include/bits/stl_list.h 
b/libstdc++-v3/include/bits/stl_list.h
index 40e2d18..87c8a39 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -830,7 +830,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
*/
   void
   assign(initializer_list __l)
-  { this->assign(__l.begin(), __l.end()); }
+  { this->_M_assign_dispatch(__l.begin(), __l.end(), __false_type()); }
 #endif
 
   /// Get a copy of the memory allocation object.


[PATCH][check_GNU_style.sh] More aggressively ignore dg-xxx directives

2016-10-11 Thread Kyrill Tkachov

Hi all,

check_GNU_style.sh complains a lot about dg-* directives in the testsuite and 
in particular about line lengths.
There's nothing we can do about the directives and sometimes they're supposed 
to be long, in particular the scan-assembler
checks in dg-final.  Currently check_GNU_style.sh has code to avoid warning for 
dg-* directives but it's too weak, it doesn't
catch dg-final or dg-options directives.
This patch makes the code ignore all "{ dg-.*" lines for length purposes.
This eliminates a lot of false positives in my patches and didn't filter any 
legitimate warnings in my patches.

Ok for trunk?

Thanks,
Kyrill

2016-10-11  Kyrylo Tkachov  

* check_GNU_style.sh (col): Ignore dg-XXX directives for line length
complaints.
commit d0685da3487fc4cc614c64851185fed5c350bb7b
Author: Kyrylo Tkachov 
Date:   Tue Oct 11 11:33:50 2016 +0100

[check_GNU_style.sh] More aggressively ignore dg-xxx directives

diff --git a/contrib/check_GNU_style.sh b/contrib/check_GNU_style.sh
index 87a276c..ed4e07f 100755
--- a/contrib/check_GNU_style.sh
+++ b/contrib/check_GNU_style.sh
@@ -178,7 +178,7 @@ col (){
 	cat "$tmp" \
 	| sed 's/^[0-9]*:+//' \
 	| expand \
-	| awk '$0 !~ /{[[:space:]]*dg-(error|warning|message)[[:space:]]/ { \
+	| awk '$0 !~ /{[[:space:]]*dg-[^[:space:]]+[[:space:]]/ { \
 		 if (length($0) > 80) \
 		   printf "%s\033[1;31m%s\033[0m\n", \
 			  substr($0,1,80), \


Re: [PATCH][check_GNU_style.sh] More aggressively ignore dg-xxx directives

2016-10-11 Thread Jakub Jelinek
On Tue, Oct 11, 2016 at 11:47:21AM +0100, Kyrill Tkachov wrote:
> check_GNU_style.sh complains a lot about dg-* directives in the testsuite and 
> in particular about line lengths.
> There's nothing we can do about the directives and sometimes they're supposed 
> to be long, in particular the scan-assembler
> checks in dg-final.  Currently check_GNU_style.sh has code to avoid warning 
> for dg-* directives but it's too weak, it doesn't
> catch dg-final or dg-options directives.
> This patch makes the code ignore all "{ dg-.*" lines for length purposes.
> This eliminates a lot of false positives in my patches and didn't filter any 
> legitimate warnings in my patches.

I wonder if we just shouldn't ignore all line lengths in testcases (or
perhaps any coding style whatsoever).  Some testcases are meant to be
formatted more-less according to our coding style (but, e.g.
/* PR tree-optimization/12345 */
comments never end with . and 2 spaces), except for dg- directives, but
others are entered in whatever form they came from the reporter.

Jakub


Re: [PATCH][check_GNU_style.sh] More aggressively ignore dg-xxx directives

2016-10-11 Thread Bernd Schmidt

On 10/11/2016 12:56 PM, Jakub Jelinek wrote:

On Tue, Oct 11, 2016 at 11:47:21AM +0100, Kyrill Tkachov wrote:

check_GNU_style.sh complains a lot about dg-* directives in the testsuite and 
in particular about line lengths.
There's nothing we can do about the directives and sometimes they're supposed 
to be long, in particular the scan-assembler
checks in dg-final.  Currently check_GNU_style.sh has code to avoid warning for 
dg-* directives but it's too weak, it doesn't
catch dg-final or dg-options directives.
This patch makes the code ignore all "{ dg-.*" lines for length purposes.
This eliminates a lot of false positives in my patches and didn't filter any 
legitimate warnings in my patches.


I wonder if we just shouldn't ignore all line lengths in testcases (or
perhaps any coding style whatsoever).  Some testcases are meant to be
formatted more-less according to our coding style (but, e.g.
/* PR tree-optimization/12345 */
comments never end with . and 2 spaces), except for dg- directives, but
others are entered in whatever form they came from the reporter.


I agree, probably best not to check testcases for style (but then I 
don't trust automatic checkers anyway).



Bernd



Re: [PATCH][check_GNU_style.sh] More aggressively ignore dg-xxx directives

2016-10-11 Thread Kyrill Tkachov


On 11/10/16 11:56, Jakub Jelinek wrote:

On Tue, Oct 11, 2016 at 11:47:21AM +0100, Kyrill Tkachov wrote:

check_GNU_style.sh complains a lot about dg-* directives in the testsuite and 
in particular about line lengths.
There's nothing we can do about the directives and sometimes they're supposed 
to be long, in particular the scan-assembler
checks in dg-final.  Currently check_GNU_style.sh has code to avoid warning for 
dg-* directives but it's too weak, it doesn't
catch dg-final or dg-options directives.
This patch makes the code ignore all "{ dg-.*" lines for length purposes.
This eliminates a lot of false positives in my patches and didn't filter any 
legitimate warnings in my patches.

I wonder if we just shouldn't ignore all line lengths in testcases (or
perhaps any coding style whatsoever).  Some testcases are meant to be
formatted more-less according to our coding style (but, e.g.
/* PR tree-optimization/12345 */
comments never end with . and 2 spaces), except for dg- directives, but
others are entered in whatever form they came from the reporter.


I would be up for ignoring the testsuite altogether in check_GNU_style.sh.
If there's consensus on this I can look into making that change.

Kyrill


Jakub




Re: PING! Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math

2016-10-11 Thread Fritz Reese
On Mon, Oct 10, 2016 at 3:56 PM, Steve Kargl
 wrote:
...
> There are a few small clean-up that can be
> done.  For example,
>
> +static gfc_expr *
> +get_radians (gfc_expr *deg)
> +{
> +  mpfr_t tmp;
...
> the tmp variable is unneeded in the above.  Converting the double
> precision 180.0 to mpfr_t and then dividing is probably slower
> than just dividing by 180.
>
> +  /* Set factor = pi / 180.  */
> +  factor = gfc_get_constant_expr (deg->ts.type, deg->ts.kind, °->where);
> +  mpfr_const_pi (factor->value.real, GFC_RND_MODE);
> +  mpfr_div_ui (factor->value.real, factor->value.real, 180, GFC_RND_MODE);
>
...

Good catch, fixed and committed r240989. Many thanks to you and Jerry.

---
Fritz Reese


Re: [PATCH, PR77558] Remove RECORD_TYPE special-casing in std_canonical_va_list_type

2016-10-11 Thread Christophe Lyon
On 10 October 2016 at 11:53, Richard Biener  wrote:
> On Sun, Sep 25, 2016 at 11:08 AM, Tom de Vries  wrote:
>> Hi,
>>
>> this patch fixes PR77558, an ice-on-invalid-code 6/7 regression.
>>
>> The fix for PR71602 introduced the invalid-code test-case
>> c-c++-common/va-arg-va-list-type.c:
>> ...
>> __builtin_va_list *pap;
>>
>> void
>> fn1 (void)
>> {
>>   __builtin_va_arg (pap, double); /* { dg-error "first argument to 'va_arg'
>> not of type 'va_list'" } */
>> }
>> ...
>>
>> The test-case passes for x86_64, but fails for aarch64 and ICEs for arm.
>>
>> The ICE happens because the patch for PR71602 is incomplete. The patch tries
>> to be more strict about returning a canonical va_list only for actual
>> va_lists, but doesn't implement this for structure va_list types, such as we
>> have for arm, aarch64 and alpha.
>>
>> This patch adds the missing part, and fixes the ICE.
>>
>> OK for trunk, 6-branch?
>
> Ok.
>

Hi Tom,

It seems your patch broke the gcc-6 branch.
I'm seeing build failures (arm*/aarch64* targets):
/tmp/4929309_2.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc2/./gcc/xgcc
-B/tmp/4929309_2.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm
-none-linux-gnueabi/gcc2/./gcc/
-B/tmp/4929309_2.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/bin/
-B/tmp/4929309_2.tmpdir/aci-gcc-fsf/buil
ds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/lib/ -isystem
/tmp/4929309_2.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/include
-isystem /
tmp/4929309_2.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/sys-include
   -g -O2 -O2  -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wal
l -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
-Wold-style-definition  -isystem ./include   -fPIC -fno-inline -g
-DIN_LIBGCC2 -fbuilding-lib
gcc -fno-stack-protector   -fPIC -fno-inline -I. -I. -I../.././gcc
-I/tmp/4929309_2.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libgcc
-I/tmp/4929309_2.tmpdir/aci-gcc
-fsf/sources/gcc-fsf/gccsrc/libgcc/.
-I/tmp/4929309_2.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libgcc/../gcc
-I/tmp/4929309_2.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gc
csrc/libgcc/../include  -DHAVE_CC_TLS  -o _gcov_execlp.o -MT
_gcov_execlp.o -MD -MP -MF _gcov_execlp.dep -DL_gcov_execlp -c
/tmp/4929309_2.tmpdir/aci-gcc-fsf/source
s/gcc-fsf/gccsrc/libgcc/libgcov-interface.c
In file included from
/tmp/4929309_2.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libgcc/../gcc/tsystem.h:84:0,
 from
/tmp/4929309_2.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libgcc/libgcov.h:41,
 from
/tmp/4929309_2.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libgcc/libgcov-interface.c:26:
/tmp/4929309_2.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libgcc/libgcov-interface.c:
In function '__gcov_execl':
/tmp/4929309_2.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libgcc/libgcov-interface.c:204:22:
error: first argument to 'va_arg' not of type 'va_list'
   while (va_arg (ap, char *))
  ^
/tmp/4929309_2.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libgcc/libgcov-interface.c:211:27:
error: first argument to 'va_arg' not of type 'va_list'
 args[i] = va_arg (aq, char *);
   ^
make[2]: *** [_gcov_execl.o] Error 1


Christophe

> Richard.
>
>> Thanks,
>> - Tom


Re: PING! Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math

2016-10-11 Thread Markus Trippelsdorf
On 2016.10.11 at 07:26 -0400, Fritz Reese wrote:
> On Mon, Oct 10, 2016 at 3:56 PM, Steve Kargl
>  wrote:
> ...
> > There are a few small clean-up that can be
> > done.  For example,
> >
> > +static gfc_expr *
> > +get_radians (gfc_expr *deg)
> > +{
> > +  mpfr_t tmp;
> ...
> > the tmp variable is unneeded in the above.  Converting the double
> > precision 180.0 to mpfr_t and then dividing is probably slower
> > than just dividing by 180.
> >
> > +  /* Set factor = pi / 180.  */
> > +  factor = gfc_get_constant_expr (deg->ts.type, deg->ts.kind, °->where);
> > +  mpfr_const_pi (factor->value.real, GFC_RND_MODE);
> > +  mpfr_div_ui (factor->value.real, factor->value.real, 180, GFC_RND_MODE);
> >
> ...
>
> Good catch, fixed and committed r240989. Many thanks to you and Jerry.

This patch breaks bootstrap:

../../gcc/gcc/fortran/iresolve.c: In function ‘gfc_expr* 
get_degrees(gfc_expr*)’:
../../gcc/gcc/fortran/iresolve.c:2728:14: error: ‘tmp’ was not declared in this 
scope   
  mpfr_init (tmp);

Even declaring the variable doesn't help:

../../gcc/gcc/fortran/simplify.c: In function ‘void radians_f(__mpfr_struct*, 
mpfr_rnd_t)’:
../../gcc/gcc/fortran/simplify.c:1775:5: error: ‘mpfr_fmod_d’ was not declared 
in this scope
 mpfr_fmod_d (tmp, x, 360.0, rnd_mode);
 ^~~
--
Markus


[PATCH] Fix PR77931

2016-10-11 Thread Richard Biener

The following fixes PR77931.

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

Richard.

2016-10-11  Richard Biener  

PR debug/77931
* gimple-low.c (lower_gimple_bind): Handle arbitrary common
sub-chains of BLOCK_VARS and gimple_bind_vars.

Index: gcc/gimple-low.c
===
--- gcc/gimple-low.c(revision 240963)
+++ gcc/gimple-low.c(working copy)
@@ -420,18 +420,21 @@ lower_gimple_bind (gimple_stmt_iterator
   /* Scrap DECL_CHAIN up to BLOCK_VARS to ease GC after we no longer
  need gimple_bind_vars.  */
   tree next;
-  tree end = NULL_TREE;
+  /* BLOCK_VARS and gimple_bind_vars share a common sub-chain.  Find
+ it by marking all BLOCK_VARS.  */
   if (gimple_bind_block (stmt))
-end = BLOCK_VARS (gimple_bind_block (stmt));
-  for (tree var = gimple_bind_vars (stmt); var != end; var = next)
+for (tree t = BLOCK_VARS (gimple_bind_block (stmt)); t; t = DECL_CHAIN (t))
+  TREE_VISITED (t) = 1;
+  for (tree var = gimple_bind_vars (stmt);
+   var && ! TREE_VISITED (var); var = next)
 {
-  /* Ugh, something is violating the constraint that BLOCK_VARS
- is a sub-chain of gimple_bind_vars.  */
-  if (! var)
-   break;
   next = DECL_CHAIN (var);
   DECL_CHAIN (var) = NULL_TREE;
 }
+  /* Unmark BLOCK_VARS.  */
+  if (gimple_bind_block (stmt))
+for (tree t = BLOCK_VARS (gimple_bind_block (stmt)); t; t = DECL_CHAIN (t))
+  TREE_VISITED (t) = 0;
 
   lower_sequence (gimple_bind_body_ptr (stmt), data);
 


[PATCH] Tiny dwarf2out bits from early LTO debug

2016-10-11 Thread Richard Biener

This merges a few more tiny pieces, one latent issue with
-gsplit-dwarf and !DWARF2_ASM_LINE_DEBUG_INFO where we'd produce
duplicate labels (happens for darwin and early LTO debug).

I've merged a verify_die routine that helped me spotting invalid
dwarf trees.

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

Richard.

2016-10-11  Richard Biener  

* dwarf2out.c (DEBUG_STR_OFFSETS_SECTION): Remove conditional.
(init_sections_and_labels): Use DEBUG_DWO_STR_OFFSETS_SECTION.
(verify_die): New function.
(dwarf2out_finish): Call it.
(output_line_info): Handle case of -gsplit-dwarf without
DWARF2_ASM_LINE_DEBUG_INFO.

Index: gcc/dwarf2out.c
===
--- gcc/dwarf2out.c (revision 240964)
+++ gcc/dwarf2out.c (working copy)
@@ -3538,12 +3538,11 @@ new_addr_loc_descr (rtx addr, enum dtpre
   ((debug_generate_pub_sections == 2) \
? ".debug_gnu_pubtypes" : ".debug_pubtypes")
 #endif
-#define DEBUG_NORM_STR_OFFSETS_SECTION ".debug_str_offsets"
-#define DEBUG_DWO_STR_OFFSETS_SECTION ".debug_str_offsets.dwo"
 #ifndef DEBUG_STR_OFFSETS_SECTION
-#define DEBUG_STR_OFFSETS_SECTION   \
-  (!dwarf_split_debug_info  \
-   ? (DEBUG_NORM_STR_OFFSETS_SECTION) : (DEBUG_DWO_STR_OFFSETS_SECTION))
+#define DEBUG_STR_OFFSETS_SECTION ".debug_str_offsets"
+#endif
+#ifndef DEBUG_DWO_STR_OFFSETS_SECTION
+#define DEBUG_DWO_STR_OFFSETS_SECTION ".debug_str_offsets.dwo"
 #endif
 #ifndef DEBUG_STR_DWO_SECTION
 #define DEBUG_STR_DWO_SECTION   ".debug_str.dwo"
@@ -5835,6 +5834,41 @@ debug_dwarf (void)
   print_die (comp_unit_die (), stderr);
 }
 
+/* Verify the DIE tree structure.  */
+
+DEBUG_FUNCTION void
+verify_die (dw_die_ref die)
+{
+  gcc_assert (!die->die_mark);
+  if (die->die_parent == NULL
+  && die->die_sib == NULL)
+return;
+  /* Verify the die_sib list is cyclic.  */
+  dw_die_ref x = die;
+  do
+{
+  x->die_mark = 1;
+  x = x->die_sib;
+}
+  while (x && !x->die_mark);
+  gcc_assert (x == die);
+  x = die;
+  do
+{
+  /* Verify all dies have the same parent.  */
+  gcc_assert (x->die_parent == die->die_parent);
+  if (x->die_child)
+   {
+ /* Verify the child has the proper parent and recurse.  */
+ gcc_assert (x->die_child->die_parent == x);
+ verify_die (x->die_child);
+   }
+  x->die_mark = 0;
+  x = x->die_sib;
+}
+  while (x && x->die_mark);
+}
+
 /* Sanity checks on DIEs.  */
 
 static void
@@ -10710,6 +10744,7 @@ output_one_line_info_table (dw_line_info
 static void
 output_line_info (bool prologue_only)
 {
+  static unsigned int generation;
   char l1[MAX_ARTIFICIAL_LABEL_BYTES], l2[MAX_ARTIFICIAL_LABEL_BYTES];
   char p1[MAX_ARTIFICIAL_LABEL_BYTES], p2[MAX_ARTIFICIAL_LABEL_BYTES];
   /* We don't support DWARFv5 line tables yet.  */
@@ -10717,10 +10752,10 @@ output_line_info (bool prologue_only)
   bool saw_one = false;
   int opc;
 
-  ASM_GENERATE_INTERNAL_LABEL (l1, LINE_NUMBER_BEGIN_LABEL, 0);
-  ASM_GENERATE_INTERNAL_LABEL (l2, LINE_NUMBER_END_LABEL, 0);
-  ASM_GENERATE_INTERNAL_LABEL (p1, LN_PROLOG_AS_LABEL, 0);
-  ASM_GENERATE_INTERNAL_LABEL (p2, LN_PROLOG_END_LABEL, 0);
+  ASM_GENERATE_INTERNAL_LABEL (l1, LINE_NUMBER_BEGIN_LABEL, generation);
+  ASM_GENERATE_INTERNAL_LABEL (l2, LINE_NUMBER_END_LABEL, generation);
+  ASM_GENERATE_INTERNAL_LABEL (p1, LN_PROLOG_AS_LABEL, generation);
+  ASM_GENERATE_INTERNAL_LABEL (p2, LN_PROLOG_END_LABEL, generation++);
 
   if (!XCOFF_DEBUGGING_INFO)
 {
@@ -25590,7 +25625,7 @@ init_sections_and_labels (void)
   SECTION_DEBUG | SECTION_EXCLUDE, NULL);
   ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_line_section_label,
DEBUG_SKELETON_LINE_SECTION_LABEL, 0);
-  debug_str_offsets_section = get_section (DEBUG_STR_OFFSETS_SECTION,
+  debug_str_offsets_section = get_section (DEBUG_DWO_STR_OFFSETS_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE,
NULL);
   ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_info_section_label,
@@ -27844,6 +27879,13 @@ dwarf2out_finish (const char *)
   /* Flush out any latecomers to the limbo party.  */
   flush_limbo_die_list ();
 
+  if (flag_checking)
+{
+  verify_die (comp_unit_die ());
+  for (limbo_die_node *node = cu_die_list; node; node = node->next)
+   verify_die (node->die);
+}
+
   /* We shouldn't have any symbols with delayed asm names for
  DIEs generated after early finish.  */
   gcc_assert (deferred_asm_name == NULL);


Re: [libgo] Silence compiler error message

2016-10-11 Thread Ian Lance Taylor
On Mon, Oct 10, 2016 at 12:44 PM, Eric Botcazou  wrote:
>
> on Solaris the configuration of the library yields an ugly:
>
> checking whether linker supports split/non-split linked together... cc1:
> error: '-fsplit-stack' is not supported by this compiler configuration
> xgcc: error: conftest1.o: No such file or directory
> no
>
> Tested on x86-64/Linux and SPARC/Solaris, OK for the mainline?
>
>
> 2016-10-10  Eric Botcazou  
>
> * configure.ac (libgo_cv_c_linker_split_non_split): Redirect compiler
> output to /dev/null.
> * configure: Regenerate.

Thanks.  Committed.

Ian


Re: [RFC][VRP] Improve intersect_ranges

2016-10-11 Thread Richard Biener
On Tue, Oct 11, 2016 at 2:57 AM, kugan
 wrote:
> Hi Richard,
>
>
> On 10/10/16 20:13, Richard Biener wrote:
>>
>> On Sat, Oct 8, 2016 at 9:38 PM, kugan 
>> wrote:
>>>
>>> Hi Richard,
>>>
>>> Thanks for the review.
>>> On 07/10/16 20:11, Richard Biener wrote:


 On Fri, Oct 7, 2016 at 12:00 AM, kugan
  wrote:
>
>
> Hi,
>
> In vrp intersect_ranges, Richard recently changed it to create integer
> value
> ranges when it is integer singleton.
>
> Maybe we should do the same when the other range is a complex ranges
> with
> SSA_NAME (like [x+2, +INF])?
>
> Attached patch tries to do this. There are cases where it will be
> beneficial
> as the  testcase in the patch. (For this testcase to work with Early
> VRP,
> we
> need the patch posted at
> https://gcc.gnu.org/ml/gcc-patches/2016-10/msg00413.html)
>
> Bootstrapped and regression tested on x86_64-linux-gnu with no new
> regressions.



 This is not clearly a win, in fact it can completely lose an ASSERT_EXPR
 because there is no way to add its effect back as an equivalence.  The
 current choice of always using the "left" keeps the ASSERT_EXPR range
 and is able to record the other range via an equivalence.
>>>
>>>
>>>
>>> How about changing the order in Early VRP when we are dealing with the
>>> same
>>> SSA_NAME in inner and outer scope. Here is a patch that does this. Is
>>> this
>>> OK if no new regressions?
>>
>>
>> I'm not sure if this is a good way forward.  The failure with the testcase
>> is
>> that we don't extract a range for k from if (j < k) which I believe
>> another
>> patch from you addresses?
>
>
> Yes,  I have committed that. I am trying to add test cases for this and
> thats when I stumbled on this:
>
> For:
> foo (int k, int j)
> {
>:
>if (j_1(D) > 9)
>  goto ;
>else
>  goto ;
>
>:
>if (j_1(D) < k_2(D))
>  goto ;
>else
>  goto ;
>
>:
>k_3 = k_2(D) + 1;
>if (k_2(D) <= 8)
>  goto ;
>else
>  goto ;
>
>:
>abort ();
>
>:
>return j_1(D);
>
> }
>
> Before we look at - if (j_1(D) < k_2(D))
> j_1 (D) has [10, +INF]  EQUIVALENCES: { j_1(D) } (1 elements)
>
> When we look at  if (j_1(D) < k_2(D))
> The range is [-INF, k_2(D) + -1]  EQUIVALENCES: { j_1(D) } (1 elements)
>
> We intersect:
> [-INF, k_2(D) + -1]  EQUIVALENCES: { j_1(D) } (1 elements)
> and
> [10, +INF]  EQUIVALENCES: { j_1(D) } (1 elements)
>
> to
> [-INF, k_2(D) + -1]  EQUIVALENCES: { j_1(D) } (1 elements)
>
> Due to this, in if (j_1(D) < k_2(D)) , we get pessimistic value range for
> k_2(D)

Ah, but that is because when generating the range for k from j < k we
use the updated range for j.  That obviously doens't make too much sense.

@@ -10650,7 +10661,7 @@ public:
   virtual void after_dom_children (basic_block);
   void push_value_range (const_tree var, value_range *vr);
   value_range *pop_value_range (const_tree var);
-  void try_add_new_range (tree op, tree_code code, tree limit);
+  value_range *try_add_new_range (tree op, tree_code code, tree limit);

   /* Cond_stack holds the old VR.  */
   auto_vec > stack;
@@ -10661,7 +10672,7 @@ public:

 /*  Add new range to OP such that (OP CODE LIMIT) is true.  */

-void
+value_range *
 evrp_dom_walker::try_add_new_range (tree op, tree_code code, tree limit)
 {
   value_range vr = VR_INITIALIZER;
@@ -10678,8 +10689,9 @@ evrp_dom_walker::try_add_new_range (tree
 {
   value_range *new_vr = vrp_value_range_pool.allocate ();
   *new_vr = vr;
-  push_value_range (op, new_vr);
+  return new_vr;
 }
+  return NULL;
 }

 /* See if there is any new scope is entered with new VR and set that VR to
@@ -10715,7 +10727,7 @@ evrp_dom_walker::before_dom_children (ba
code = invert_tree_comparison (gimple_cond_code (stmt),
   HONOR_NANS (op0));
  /* Add VR when (OP0 CODE OP1) condition is true.  */
- try_add_new_range (op0, code, op1);
+ value_range *op0_range = try_add_new_range (op0, code, op1);

  /* Register ranges for y in x < y where
 y might have ranges that are useful.  */
@@ -10728,8 +10740,13 @@ evrp_dom_walker::before_dom_children (ba
  &new_code, &limit))
{
  /* Add VR when (OP1 NEW_CODE LIMIT) condition is true.  */
- try_add_new_range (op1, new_code, limit);
+ value_range *op1_range = try_add_new_range (op1, new_code, limit);
+ if (op1_range)
+   push_value_range (op1, op1_range);
}
+
+ if (op0_range)
+   push_value_range (op0, op0_range);
}
 }



seems to fix that and the issue.

> Thanks,
> Kugan
>
>
>
>> As said the issue is with the equivalence / value-range representation so
>> you can't do sth like
>>
>>   /* Discover VR when condition is t

Re: [PATCH, ARM 5/7] Add support for MOVT/MOVW to ARMv8-M Baseline

2016-10-11 Thread Thomas Preudhomme

On 10/10/16 13:35, Christophe Lyon wrote:

Hi Thomas,


Hi Christophe,



On 13 July 2016 at 17:34, Thomas Preudhomme
 wrote:

On Wednesday 13 July 2016 17:14:52 Christophe Lyon wrote:

Hi Thomas,


Hi Christophe,



I'm seeing:
gcc.target/arm/pr42574.c: syntax error in target selector
"arm_thumb1_ok && { ! arm_thumb1_movt_ok }" for " dg-do 1 compile {
arm_thumb1_ok && { ! arm_thumb1_movt_ok } } "


Oops. I remember the trial and error to find the right amount of curly braces
yet I can indeed reproduce the error now. The target keyword is missing. I'll
submit a patch asap.

Best regards,

Thomas


I've noticed that the new test
  gcc.target/arm/movdi_movw.c scan-assembler-times movw\tr0, #61680 1
fails on armeb-none-linux-gnueabihf
--with-mode=thumb --with-cpu=cortex-a9 --with-fpu=neon-fp16


It seems DImode values are stored differently in register depending on the 
endianness. For little endian the low bits would be in the lowest register, but 
it's reverse in big endian. I'll adapt the test accordingly.




the other new tests pass, and using --with=mode=arm makes all three
of them unsupported.


Right, there is no reason to forbid ARM state indeed. I'll fix that too.



Sorry I missed it when I reported the other error.


No worry.



Can you have a look?


Absolutely.

Cheers,

Thomas


Re: Compile-time improvement for if conversion.

2016-10-11 Thread Yuri Rumyantsev
Richard,

I implemented this by passing callback function in_region which
returns true if block belongs to region.
I am testing it now

I attach modified patch for your quick review.

Thanks.

2016-10-11 13:33 GMT+03:00 Richard Biener :
> On Mon, Oct 10, 2016 at 4:17 PM, Yuri Rumyantsev  wrote:
>> Richard,
>>
>> If "fake" exit or entry block is created in dominance how we can
>> determine what is its the only  predecessor or successor without using
>> a notion of loop?
>
> The caller passes in an entry and exit edge instead of a block or loop.
>
> Richard.
>
>> 2016-10-10 15:00 GMT+03:00 Richard Biener :
>>> On Mon, Oct 10, 2016 at 1:42 PM, Yuri Rumyantsev  wrote:
 Thanks Richard for your comments.
 I'd like to answer on your last comment regarding use split_edge()
 instead of creating fake post-header. I started with this splitting
 but it requires to fix-up closed ssa form by creating additional phi
 nodes, so I decided to use only cfg change without updating ssa form.
 Other changes look reasonable and will fix them.
>>>
>>> Ah.  In this case can you investigate what it takes to make the entry/exit
>>> edges rather than BBs?  That is, introduce those "fakes" only internally
>>> in dominance.c?
>>>
 2016-10-10 12:52 GMT+03:00 Richard Biener :
> On Wed, Oct 5, 2016 at 3:22 PM, Yuri Rumyantsev  
> wrote:
>> Hi All,
>>
>> Here is implementation of Richard proposal:
>>
>> < For general infrastructure it would be nice to expose a 
>> (post-)dominator
>> < compute for MESE (post-dominators) / SEME (dominators) regions.  I 
>> believe
>> < what makes if-conversion expensive is the post-dom compute which 
>> happens
>> < for each loop for the whole function.  It shouldn't be very difficult
>> < to write this,
>> < sharing as much as possible code with the current DOM code might need
>> < quite some refactoring though.
>>
>> I implemented this proposal by adding calculation of dominance info
>> for SESE regions and incorporate this change to if conversion pass.
>> SESE region is built by adding loop pre-header and possibly fake
>> post-header blocks to loop body. Fake post-header is deleted after
>> predication completion.
>>
>> Bootstrapping and regression testing did not show any new failures.
>>
>> Is it OK for trunk?
>
> It's mostly reasonable but I have a few comments.  First, re-using
> bb->dom[] for the dominator info is somewhat fragile but indeed
> a requirement to make the patch reasonably small.  Please,
> in calculate_dominance_info_for_region, make sure that
> !dom_info_available_p (dir).
>
> You pass loop * everywhere but require ->aux to be set up as
> an array of BBs forming the region with special BBs at array ends.
>
> Please instead pass in a vec which avoids using ->aux
> and also allows other non-loop-based SESE regions to be used
> (I couldn't spot anything that relies on this being a loop).
>
> Adding a convenience wrapper for loop  * would be of course nice,
> to cover the special pre/post-header code in tree-if-conv.c.
>
> In theory a SESE region is fully specified by its entry end exit _edge_,
> so you might want to see if it's possible to use such a pair of edges
> to guard the dfs/idom walks to avoid the need to create fake blocks.
>
> Btw, instead of using create_empty_bb, unchecked_make_edge, etc.
> please use split_edge() of the entry/exit edges.
>
> Richard.
>
>> ChangeLog:
>> 2016-10-05  Yuri Rumyantsev  
>>
>> * dominance.c : Include cfgloop.h for loop recognition.
>> (dom_info): Add new functions and add boolean argument to recognize
>> computation for loop region.
>> (dom_info::dom_info): New function.
>> (dom_info::calc_dfs_tree): Add boolean argument IN_REGION to not
>> handle unvisited blocks.
>> (dom_info::calc_idoms): Likewise.
>> (compute_dom_fast_query_in_region): New function.
>> (calculate_dominance_info): Invoke calc_dfs_tree and calc_idoms with
>> false argument.
>> (calculate_dominance_info_for_region): New function.
>> (free_dominance_info_for_region): Likewise.
>> (verify_dominators): Invoke calc_dfs_tree and calc_idoms with false
>> argument.
>> * dominance.h: Add prototype for introduced functions
>> calculate_dominance_info_for_region and
>> free_dominance_info_for_region.
>> tree-if-conv.c: Add to local variables ifc_sese_bbs & fake_postheader.
>> (build_sese_region): New function.
>> (if_convertible_loop_p_1): Invoke local version of post-dominators
>> calculation, free it after basic block predication and delete created
>> fake post-header block if any.
>> (tree_if_conversion): Delete call of free_dominance_info for
>> post-dominators, free ifc_sese_bbs which represents SESE region.
>> (pass_if_conversion::execute): 

[C++ PATCH] RFC: implement P0386R2 - C++17 inline variables

2016-10-11 Thread Jakub Jelinek
Hi!

Here is an attempt to implement C++17 inline variables.
Bootstrapped/regtested on x86_64-linux and i686-linux.

The main question is if the inline variables, which are vague linkage,
should be !DECL_EXTERNAL or DECL_EXTERNAL DECL_NOT_REALLY_EXTERN while
in the FE.  In the patch, they are !DECL_EXTERNAL, except for inline
static data members in instantiated templates.  As the inline-var3.C
testcase shows, even if they are !DECL_EXTERNAL (except for the instantiated
static data members), even at -O0 we do not actually emit them unless
odr-used, so to some extent I don't see the point in forcing them to
be DECL_EXTERNAL DECL_NOT_REALLY_EXTERN.  E.g. for debug info it seems
desirable that they are not DECL_EXTERNAL, otherwise we emit the in-class
definitions as if they were just declarations, which is bad.  Right now
the patch emits them correctly, except for the instantiated inline
static data members (where one sees only the in-class declaration which
is actually definition, and not any definition).
I've attempted to use the DECL_EXTERNAL DECL_NOT_REALLY_EXTERN for all the
inline vars, see the first attached patch, but that just breaks too much
(e.g. most of the vars aren't recorded in pending_statics, so nothing really
finalizes them using import_export_decl at eof).  So, shall we still
attempt to do it the DECL_EXTERNAL DECL_NOT_REALLY_EXTERN way everywhere
and e.g. solve the debug info stuff using langhooks, push all the inline
vars into pending_statics (or defer them for further processing later on)?
Or instead e.g. change the DECL_EXTERNAL DECL_NOT_REALLY_EXTERN for the
instantiated inline static data members earlier (and tweak instantiate_decl
to cope with that)?

Another thing is I've noticed (with Jonathan's help to look it up) that
we aren't implementing DR1511, I'm willing to try to implement that, but
as it will need to touch the same spots as the patch, I think it should be
resolved incrementally.

Yet another thing are thread_local inline vars.  E.g. on:
struct S { S (); ~S (); };
struct T { ~T (); };
int foo ();
thread_local inline S s;
inline thread_local T t;
inline thread_local int u = foo ();
it seems both clang++ (~2 months old) and g++ with the patch emits:
8 byte TLS _ZGV1{stu] variables
1 byte TLS __tls_guard variable
and _ZTH1[stu] being aliases to __tls_init, which does essentially:
  if (__tls_guard) return;
  __tls_guard = 1;
  if (*(char *)&_ZGV1s == 0) {
*(char *)&_ZGV1s = 1;
S::S (&s);
__cxa_thread_atexit (S::~S, &s, &__dso_handle);
  }
  if (*(char *)&_ZGV1t == 0) {
*(char *)&_ZGV1t = 1;
__cxa_thread_atexit (T::~T, &t, &__dso_handle);
  }
  if (*(char *)&_ZGV1u == 0) {
*(char *)&_ZGV1u = 1;
u = foo ();
  }
Is that what we want to emit?  At first I doubted this could work properly,
now thinking about it more, perhaps it can.  And, do we really want all the
_ZGV* vars for the TLS inline vars (and other TLS comdats) to be 8 byte,
even when we are using just a single byte?  Or is it too late to change (ABI
break)?

For the non-TLS inline vars that need runtime construction/initialization
and/or destruction, GCC with the patch emits just non-atomic comparisons
of the _ZGV* vars, while clang++ apparently emits __cxa_guard*.  As it
happens in the library/binary constructors only, I think what G++ emits
looks right to me, but am not 100% sure.

And, as mentioned in the DWARF mailing list, I think we should emit
DW_AT_inline on the inline vars (both explicit and implicit - static
constexpr data members in C++17 mode).  I hope that can be done as a
follow-up.

2016-10-11  Jakub Jelinek  

Implement P0386R2 - C++17 inline variables
* dwarf2out.c (gen_member_die): Handle inline static data member
definitions.
cp/
* cp-tree.h (struct lang_type): Shrink language field to 1 bit
from 4.  Add var_declared_inline_p field.  Mention 2 spare bits.
(DECL_VAR_DECLARED_INLINE_P): Define.
(SET_DECL_VAR_DECLARED_INLINE_P): Define.
(DECL_INLINE_VAR_P): Define.
(diagnose_inline_vars_for_namespace): Declare.
* decl.c (diagnose_inline_vars_for_namespace): New function.
(duplicate_decls): For static data members copy
DECL_DECLARED_CONSTEXPR_P.
(redeclaration_error_message): Handle C++17 redundant redeclaration
of constexpr static data member outside of class.
(maybe_commonize_var): Handle inline variables.
(check_initializer): Ignore inline variables for diagnostics.
Adjust diagnostic wording for C++17.
(make_rtl_for_nonlocal_decl): Allow in-class definition of
inline static data members.
(bad_specifiers): Don't diagnose inline on variables here.
(grokvardecl): Add inlinep argument, non-static const inline variables
are TREE_PUBLIC.
(check_static_variable_definition): Return early also for inline
variables.
(grokdeclarator): Handle inline variables and inline static data
m

Re: Compile-time improvement for if conversion.

2016-10-11 Thread Richard Biener
On Tue, Oct 11, 2016 at 3:23 PM, Yuri Rumyantsev  wrote:
> Richard,
>
> I implemented this by passing callback function in_region which
> returns true if block belongs to region.
> I am testing it now
>
> I attach modified patch for your quick review.

+  FOR_EACH_VEC_ELT (region, i, bb)
+{
+  bb->dom[dir_index] = et_new_tree (bb);
+}
+  /* Check that region is SESE region.  */
+  entry = region[0];
+  if ( EDGE_COUNT (entry->succs) > 1)
+{
+  /* Create new entry block with the only successor.  */
+  basic_block succ = NULL;
+  bool found = false;
+  FOR_EACH_EDGE (e, ei, entry->succs)
+   if (in_region (region, e->dest))
+ {
+   gcc_assert (!found);

is that check equal to e->dest->dom[dir_index] != NULL?  I think we
shouldn't need the callback.

+new_entry = create_empty_bb (entry);
+unchecked_make_edge (new_entry, succ, 0);

I still think this is somewhat gross and we should try to avoid it
somehow - at least it's well-hidden now ;)

+/* Put it to region as entry node.  */
+region[0] = new_entry;

so region[0] is overwritten now?

As far as I understand calc_dfs_tree it should be possible to compute
the region on-the-fly
from calling calc_dfs_tree_nonrec on the entry/exit (also maybe
avoiding some of the still
"large" complexity of zeroing arrays in the constructor).

And if we use that DFS walk directly we should be able to avoid
creating those fake entry/exit
blocks by using entry/exit edges instead... (somehow).

Richard.



> Thanks.
>
> 2016-10-11 13:33 GMT+03:00 Richard Biener :
>> On Mon, Oct 10, 2016 at 4:17 PM, Yuri Rumyantsev  wrote:
>>> Richard,
>>>
>>> If "fake" exit or entry block is created in dominance how we can
>>> determine what is its the only  predecessor or successor without using
>>> a notion of loop?
>>
>> The caller passes in an entry and exit edge instead of a block or loop.
>>
>> Richard.
>>
>>> 2016-10-10 15:00 GMT+03:00 Richard Biener :
 On Mon, Oct 10, 2016 at 1:42 PM, Yuri Rumyantsev  
 wrote:
> Thanks Richard for your comments.
> I'd like to answer on your last comment regarding use split_edge()
> instead of creating fake post-header. I started with this splitting
> but it requires to fix-up closed ssa form by creating additional phi
> nodes, so I decided to use only cfg change without updating ssa form.
> Other changes look reasonable and will fix them.

 Ah.  In this case can you investigate what it takes to make the entry/exit
 edges rather than BBs?  That is, introduce those "fakes" only internally
 in dominance.c?

> 2016-10-10 12:52 GMT+03:00 Richard Biener :
>> On Wed, Oct 5, 2016 at 3:22 PM, Yuri Rumyantsev  
>> wrote:
>>> Hi All,
>>>
>>> Here is implementation of Richard proposal:
>>>
>>> < For general infrastructure it would be nice to expose a 
>>> (post-)dominator
>>> < compute for MESE (post-dominators) / SEME (dominators) regions.  I 
>>> believe
>>> < what makes if-conversion expensive is the post-dom compute which 
>>> happens
>>> < for each loop for the whole function.  It shouldn't be very difficult
>>> < to write this,
>>> < sharing as much as possible code with the current DOM code might need
>>> < quite some refactoring though.
>>>
>>> I implemented this proposal by adding calculation of dominance info
>>> for SESE regions and incorporate this change to if conversion pass.
>>> SESE region is built by adding loop pre-header and possibly fake
>>> post-header blocks to loop body. Fake post-header is deleted after
>>> predication completion.
>>>
>>> Bootstrapping and regression testing did not show any new failures.
>>>
>>> Is it OK for trunk?
>>
>> It's mostly reasonable but I have a few comments.  First, re-using
>> bb->dom[] for the dominator info is somewhat fragile but indeed
>> a requirement to make the patch reasonably small.  Please,
>> in calculate_dominance_info_for_region, make sure that
>> !dom_info_available_p (dir).
>>
>> You pass loop * everywhere but require ->aux to be set up as
>> an array of BBs forming the region with special BBs at array ends.
>>
>> Please instead pass in a vec which avoids using ->aux
>> and also allows other non-loop-based SESE regions to be used
>> (I couldn't spot anything that relies on this being a loop).
>>
>> Adding a convenience wrapper for loop  * would be of course nice,
>> to cover the special pre/post-header code in tree-if-conv.c.
>>
>> In theory a SESE region is fully specified by its entry end exit _edge_,
>> so you might want to see if it's possible to use such a pair of edges
>> to guard the dfs/idom walks to avoid the need to create fake blocks.
>>
>> Btw, instead of using create_empty_bb, unchecked_make_edge, etc.
>> please use split_edge() of the entry/exit edges.
>>
>> Richar

New option -flimit-function-alignment

2016-10-11 Thread Bernd Schmidt
Denys has submitted some patches to add more capabilities to the 
-falign-* options, but these still have some issues, and the original 
ideas seems to have been to allow for large alignments without 
over-aligning small functions. The following patch implements that idea 
by taking into account the function size as computed during 
shorten_branches: let's say we use "-falign-functions=128 
-flimit-function-alignment", then a 15-byte function will be 16-byte 
aligned rather than 128-byte aligned.


Bootstrapped and tested on x86_64-linux. Denys, does this solve your 
problem? Anyone else, ok to commit?



Bernd
gcc/
	* common.opt (flimit-function-alignment): New.
	* doc/invoke.texi (-flimit-function-alignment): Document.
	* emit-rtl.h (struct rtl_data): Add max_insn_address field.
	* final.c (shorten_branches): Set it.
	* varasm.c (assemble_start_function): Limit alignment to it
	if requested.

gcc/testsuite/
	* gcc.target/i386/align-limit.c: New test.

Index: gcc/common.opt
===
--- gcc/common.opt	(revision 240861)
+++ gcc/common.opt	(working copy)
@@ -906,6 +906,9 @@ Align the start of functions.
 falign-functions=
 Common RejectNegative Joined UInteger Var(align_functions)
 
+flimit-function-alignment
+Common Report Var(flag_limit_function_alignment) Optimization Init(0)
+
 falign-jumps
 Common Report Var(align_jumps,0) Optimization UInteger
 Align labels which are only reached by jumping.
Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi	(revision 240861)
+++ gcc/doc/invoke.texi	(working copy)
@@ -368,7 +368,7 @@ Objective-C and Objective-C++ Dialects}.
 -fno-ira-share-spill-slots @gol
 -fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute @gol
 -fivopts -fkeep-inline-functions -fkeep-static-functions @gol
--fkeep-static-consts -flive-range-shrinkage @gol
+-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage @gol
 -floop-block -floop-interchange -floop-strip-mine @gol
 -floop-unroll-and-jam -floop-nest-optimize @gol
 -floop-parallelize-all -flra-remat -flto -flto-compression-level @gol
@@ -8262,6 +8262,11 @@ If @var{n} is not specified or is zero,
 
 Enabled at levels @option{-O2}, @option{-O3}.
 
+@item -flimit-function-alignment
+When function alignment is requested by @option{-falign-functions}, use
+a size estimate to prevent functions from being over-aligned.  This
+limits the alignment to be no larger than the function itself.
+
 @item -falign-labels
 @itemx -falign-labels=@var{n}
 @opindex falign-labels
Index: gcc/emit-rtl.h
===
--- gcc/emit-rtl.h	(revision 240861)
+++ gcc/emit-rtl.h	(working copy)
@@ -284,6 +284,9 @@ struct GTY(()) rtl_data {
  to eliminable regs (like the frame pointer) are set if an asm
  sets them.  */
   HARD_REG_SET asm_clobbers;
+
+  /* The highest address seen during shorten_branches.  */
+  unsigned HOST_WIDE_INT max_insn_address;
 };
 
 #define return_label (crtl->x_return_label)
Index: gcc/final.c
===
--- gcc/final.c	(revision 240861)
+++ gcc/final.c	(working copy)
@@ -1462,7 +1462,7 @@ shorten_branches (rtx_insn *first)
   if (!increasing)
 	break;
 }
-
+  crtl->max_insn_address = insn_current_address;
   free (varying_length);
 }
 
Index: gcc/varasm.c
===
--- gcc/varasm.c	(revision 240861)
+++ gcc/varasm.c	(working copy)
@@ -1791,9 +1791,19 @@ assemble_start_function (tree decl, cons
   && align_functions_log > align
   && optimize_function_for_speed_p (cfun))
 {
+  int align_log = align_functions_log;
+  int max_skip = align_functions - 1;
+  if (flag_limit_function_alignment && crtl->max_insn_address > 0)
+	{
+	  int size_log = ceil_log2 (crtl->max_insn_address);
+	  if (size_log < align_log)
+	align_log = size_log;
+	  int sz = 1 << size_log;
+	  if (sz < max_skip)
+	max_skip = sz - 1;
+	}
 #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
-  ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file,
- align_functions_log, align_functions - 1);
+  ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file, align_log, max_skip);
 #else
   ASM_OUTPUT_ALIGN (asm_out_file, align_functions_log);
 #endif
Index: gcc/testsuite/gcc.target/i386/align-limit.c
===
--- gcc/testsuite/gcc.target/i386/align-limit.c	(nonexistent)
+++ gcc/testsuite/gcc.target/i386/align-limit.c	(working copy)
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -falign-functions=64 -flimit-function-alignment" } */
+/* { dg-final { scan-assembler ".p2align 1,,1" } } */
+/* { dg-final { scan-assembler-not ".p2align 6,,63" } } */
+
+void
+test_func (void)
+{
+}


Re: New option -flimit-function-alignment

2016-10-11 Thread Denys Vlasenko



On 10/11/2016 04:11 PM, Bernd Schmidt wrote:

Denys has submitted some patches to add more capabilities to the
-falign-* options, but these still have some issues, and the original
ideas seems to have been to allow for large alignments without
over-aligning small functions. The following patch implements that
idea by taking into account the function size as computed during
shorten_branches: let's say we use "-falign-functions=128
-flimit-function-alignment", then a 15-byte function will be 16-byte
aligned rather than 128-byte aligned.

Bootstrapped and tested on x86_64-linux. Denys, does this solve your
problem?


This is better than current behavior, but this is not what I want.

15-byte function does not need to be aligned to 16 bytes on a machine
with 128-byte L1I cachelines. It needs to be aligned to 128 bytes
if there are less than 15 bytes remaining; if there are MORE than 15 bytes
remaining, why align at all? It's a waste of space.


Re: [SPARC] Tidy up Condition Code support and more

2016-10-11 Thread Jose E. Marchesi

Hi Eric.

+(define_insn "*plus_sltu_vis3"
+  [(set (match_operand:W 0 "register_operand" "=r")
+   (plus:W (ltu:W (match_operand 2 "icc_register_operand" "X")
+  (const_int 0))
+   (match_operand:W 1 "arith_operand" "rI")))]
+  "TARGET_ARCH64 && TARGET_VIS3
+   && (GET_MODE (operands[2]) == CCXmode || GET_MODE (operands[2]) == 
CCXCmode)"
+  "addxc\t%%g0, %1, %0"
+  [(set_attr "type" "ialuX")])

[...]

+(define_insn "*minus_neg_sltu_subxc"
+  [(set (match_operand:W 0 "register_operand" "=r")
+   (minus:W (neg:W (ltu:W (match_operand 2 "icc_register_operand" "X")
+  (const_int 0)))
+(match_operand:W 1 "arith_operand" "rI")))]
+  "TARGET_ARCH64 && TARGET_SUBXC
+   && (GET_MODE (operands[2]) == CCXmode || GET_MODE (operands[2]) == 
CCXCmode)"
+  "subxc\t%%g0, %1, %0"

[... etc ...]

Note that the ADDXC, ADDXCCC, SUBXC and SUBXCCC instructions do not
support immediate operands.  Hence the patch breaks vis3-enabling arches
and niagara-7.

(Yes, ADXCC and SUBXCC both support immediate operands, it can be
confusing :/)


Re: PING! Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math

2016-10-11 Thread Andrew Pinski
On Tue, Oct 11, 2016 at 5:43 AM, Markus Trippelsdorf
 wrote:
> On 2016.10.11 at 07:26 -0400, Fritz Reese wrote:
>> On Mon, Oct 10, 2016 at 3:56 PM, Steve Kargl
>>  wrote:
>> ...
>> > There are a few small clean-up that can be
>> > done.  For example,
>> >
>> > +static gfc_expr *
>> > +get_radians (gfc_expr *deg)
>> > +{
>> > +  mpfr_t tmp;
>> ...
>> > the tmp variable is unneeded in the above.  Converting the double
>> > precision 180.0 to mpfr_t and then dividing is probably slower
>> > than just dividing by 180.
>> >
>> > +  /* Set factor = pi / 180.  */
>> > +  factor = gfc_get_constant_expr (deg->ts.type, deg->ts.kind, 
>> > °->where);
>> > +  mpfr_const_pi (factor->value.real, GFC_RND_MODE);
>> > +  mpfr_div_ui (factor->value.real, factor->value.real, 180, GFC_RND_MODE);
>> >
>> ...
>>
>> Good catch, fixed and committed r240989. Many thanks to you and Jerry.
>
> This patch breaks bootstrap:
>
> ../../gcc/gcc/fortran/iresolve.c: In function ‘gfc_expr* 
> get_degrees(gfc_expr*)’:
> ../../gcc/gcc/fortran/iresolve.c:2728:14: error: ‘tmp’ was not declared in 
> this scope
>  mpfr_init (tmp);
>
> Even declaring the variable doesn't help:
>
> ../../gcc/gcc/fortran/simplify.c: In function ‘void radians_f(__mpfr_struct*, 
> mpfr_rnd_t)’:
> ../../gcc/gcc/fortran/simplify.c:1775:5: error: ‘mpfr_fmod_d’ was not 
> declared in this scope
>  mpfr_fmod_d (tmp, x, 360.0, rnd_mode);
>  ^~~

Looks like it was only broken for some mpfr's.  That is ones which is
compiled with gcc it worked but one which comes with Ubuntu 1604 it
does not.  they are exactly the same version too.

Thanks,
Andrew


> --
> Markus


Re: [PATCH, PING] DWARF: process all TYPE_DECL nodes when iterating on scopes

2016-10-11 Thread Pierre-Marie de Rodat

On 09/28/2016 09:48 AM, Richard Biener wrote:

Hmm, interesting approach.  It might work reliably at this point of
the compilation
but we do actually recycle cgraph nodes.


Arf, what a pity. ;-)


So I wonder if given we do have
->origin / ->next_nested in the cgraph if we can simply perform a walk in the
appropriate order.



But then OTOH in my early LTO debug patchset I have
[…]
which is not 100% equivalent (looking at the abstract origin) but it
sounds like a
similar issue.  So I wonder if doing the same for DECL_CONTEXT being a function
makes sense here and would also fix your particular issue in a more
reliable way.


I think it makes sense, and it seems to work, so many thanks for the 
suggestion! Bootstrapped and regtested successfuly on x86_64-linux. And 
this time, I did not forgot to attach the new testcase!


--
Pierre-Marie de Rodat
>From ad9eeef49da48786caabe9ef529127d6f93ea766 Mon Sep 17 00:00:00 2001
From: Pierre-Marie de Rodat 
Date: Fri, 23 Sep 2016 18:16:07 +0200
Subject: [PATCH] DWARF: fix scoping for descriptions of local types

In Ada, it is possible to have nested subprograms in the following
configuration:

procedure Parent is
   type T;
   [...]
   procedure Child (Value : T) is
   begin
  [...]
   end Child;
begin
   [...]
end Parent;

As we currently generate debugging information for Child first before
Parent, the debug info for T appears in global scope since the DIE for
Parent does not exist yet.

This patch makes sure that when we generate early debug info for a
nested function, we trigger generation for the parent function first.

gcc/ChangeLog:

	* dwarf2out.c (dwarf2out_early_global_decl): For nested
	functions, call dwarf2out_decl on the parent function first.

gcc/testsuite/

	* gcc/testsuite/gnat.dg/debug9.adb: New testcase.
---
 gcc/dwarf2out.c  | 10 
 gcc/testsuite/gnat.dg/debug9.adb | 53 
 2 files changed, 63 insertions(+)
 create mode 100644 gcc/testsuite/gnat.dg/debug9.adb

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 4a3df33..413106d 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -23867,6 +23867,16 @@ dwarf2out_early_global_decl (tree decl)
 	  if (!DECL_STRUCT_FUNCTION (decl))
 	goto early_decl_exit;
 
+	  /* For nested functions, emit DIEs for the parents first so that all
+	 nested DIEs are generated at the proper scope in the first
+	 shot.  */
+	  tree context = decl_function_context (decl);
+	  if (context != NULL)
+	{
+	  current_function_decl = context;
+	  dwarf2out_decl (context);
+	}
+
 	  current_function_decl = decl;
 	}
   dwarf2out_decl (decl);
diff --git a/gcc/testsuite/gnat.dg/debug9.adb b/gcc/testsuite/gnat.dg/debug9.adb
new file mode 100644
index 000..dd14210
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/debug9.adb
@@ -0,0 +1,53 @@
+--  The aim of this test is to check that Ada types appear in the proper
+--  context in the debug info.
+-- 
+--  Checking this directly would be really tedious just scanning for assembly
+--  lines, so instead we rely on DWARFv4's .debug_types sections, which must be
+--  created only for global-scope types. Checking the number of .debug_types is
+--  some hackish way to check that types are output in the proper context (i.e.
+--  at global or local scope).
+--
+--  { dg-options "-g -gdwarf-4 -cargs -fdebug-types-section -dA" }
+--  { dg-final { scan-assembler-times "\\(DIE \\(0x\[a-f0-9\]*\\) DW_TAG_type_unit\\)" 0 } }
+
+procedure Debug9 is
+   type Array_Type is array (Natural range <>) of Integer;
+   type Record_Type (L1, L2 : Natural) is record
+  I1 : Integer;
+  A1 : Array_Type (1 .. L1);
+  I2 : Integer;
+  A2 : Array_Type (1 .. L2);
+  I3 : Integer;
+   end record;
+
+   function Get (L1, L2 : Natural) return Record_Type is
+  Result : Record_Type (L1, L2);
+   begin
+  Result.I1 := 1;
+  for I in Result.A1'Range loop
+ Result.A1 (I) := I;
+  end loop;
+  Result.I2 := 2;
+  for I in Result.A2'Range loop
+ Result.A2 (I) := I;
+  end loop;
+  Result.I3 := 3;
+  return Result;
+   end Get;
+
+   R1 : Record_Type := Get (0, 0);
+   R2 : Record_Type := Get (1, 0);
+   R3 : Record_Type := Get (0, 1);
+   R4 : Record_Type := Get (2, 2);
+
+   procedure Process (R : Record_Type) is
+   begin
+  null;
+   end Process;
+
+begin
+   Process (R1);
+   Process (R2);
+   Process (R3);
+   Process (R4);
+end Debug9;
-- 
2.10.0



[PATCH, RS6000, PR77934] mtvsrdd needs b (base register) constraint on first input

2016-10-11 Thread Aaron Sawdey
Gcc 7 trunk was generating incorrect code for spec2k6 403.gcc due to
this constraint issue. OK for trunk after bootstrap/regtest passes?

2016-10-06  Aaron Sawdey  

PR target/77934
* config/rs6000/vmx.md (vsx_concat_): The mtvsrdd instruction
needs a base register for arg 1.


Index: gcc/config/rs6000/vsx.md
===
--- gcc/config/rs6000/vsx.md(revision 240994)
+++ gcc/config/rs6000/vsx.md(working copy)
@@ -1938,7 +1938,7 @@
 (define_insn "vsx_concat_"
   [(set (match_operand:VSX_D 0 "gpc_reg_operand" "=,we")
(vec_concat:VSX_D
-(match_operand: 1 "gpc_reg_operand" ",r")
+(match_operand: 1 "gpc_reg_operand" ",b")
 (match_operand: 2 "gpc_reg_operand" ",r")))]
   "VECTOR_MEM_VSX_P (mode)"
 {

-- 
Aaron Sawdey, Ph.D.  acsaw...@linux.vnet.ibm.com
050-2/C113  (507) 253-7520 home: 507/263-0782
IBM Linux Technology Center - PPC Toolchain



gcc-patches@gcc.gnu.org

2016-10-11 Thread Bin Cheng
Hi,
We missed folding (convert)(X op const) -> (convert)X op (convert)const for 
unsigned narrowing because of reason reported at 
https://gcc.gnu.org/ml/gcc/2016-07/msg00126.html
This patch fixes the issue by adding new match&simplify pattern, it also adds a 
test case.  This is the prerequisite patch for next patch adding new 
vectorization pattern.

Bootstrap and test along with the next patch on x86_64 and AArch64.  Is it OK?

Thanks,
bin

2016-10-11  Bin Cheng  

* match.pd ((convert (X op C))): Fold type narrowing for unsigned
operation on constant.

gcc/testsuite/ChangeLog
2016-10-11  Bin Cheng  

* gcc.dg/fold-narrow-unsgn-opcst.c: New test.diff --git a/gcc/match.pd b/gcc/match.pd
index 786cf4c..7875424 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -1731,6 +1731,19 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 >= inside_prec - !inside_unsignedp)
  (convert @0)))
 
+/* (convert (X op C)) -> ((convert)X op (convert)C) if it is narrowing
+   conversion and both types wrap when overflow.  */
+(for op (plus minus)
+  (simplify
+(convert (op @0 @1))
+(if (INTEGRAL_TYPE_P (type)
+&& TYPE_OVERFLOW_WRAPS (type)
+&& TREE_CODE (@1) == INTEGER_CST
+&& INTEGRAL_TYPE_P (TREE_TYPE (@0))
+&& TYPE_OVERFLOW_WRAPS (TREE_TYPE (@0))
+&& TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@0)))
+ (op (convert @0) (convert @1)
+
 /* If we have a narrowing conversion to an integral type that is fed by a
BIT_AND_EXPR, we might be able to remove the BIT_AND_EXPR if it merely
masks off bits outside the final type (and nothing else).  */
diff --git a/gcc/testsuite/gcc.dg/fold-narrow-unsgn-opcst.c 
b/gcc/testsuite/gcc.dg/fold-narrow-unsgn-opcst.c
new file mode 100644
index 000..aff96a9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-narrow-unsgn-opcst.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-gimple" } */
+
+unsigned char foo (unsigned short s)
+{
+  return (unsigned char)(s + 65530);
+}
+/* { dg-final { scan-tree-dump-not " 65530" "gimple" } } */


[PATCH GCC]New vectorization pattern turning cond_expr into max/min and plus/minus

2016-10-11 Thread Bin Cheng
Hi,
Given below test case,
int foo (unsigned short a[], unsigned int x)
{
  unsigned int i;
  for (i = 0; i < 1000; i++)
{
  x = a[i];
  a[i] = (unsigned short)(x >= 32768 ? x - 32768 : 0);
}
  return x;
}

it now can be vectorized on AArch64, but generated assembly is way from optimal:
.L4:
ldr q4, [x3, x1]
add w2, w2, 1
cmp w2, w0
ushll   v1.4s, v4.4h, 0
ushll2  v0.4s, v4.8h, 0
add v3.4s, v1.4s, v6.4s
add v2.4s, v0.4s, v6.4s
cmhiv1.4s, v1.4s, v5.4s
cmhiv0.4s, v0.4s, v5.4s
and v1.16b, v3.16b, v1.16b
and v0.16b, v2.16b, v0.16b
xtn v2.4h, v1.4s
xtn2v2.8h, v0.4s
str q2, [x3, x1]
add x1, x1, 16
bcc .L4

The vectorized loop has 15 instructions, which can be greatly simplified by 
turning cond_expr into max_expr, as below:
.L4:
ldr q1, [x3, x1]
add w2, w2, 1
cmp w2, w0
umaxv0.8h, v1.8h, v2.8h
add v0.8h, v0.8h, v2.8h
str q0, [x3, x1]
add x1, x1, 16
bcc .L4

This patch addresses the issue by adding new vectorization pattern.
Bootstrap and test on x86_64 and AArch64.  Is it OK?

Thanks,
bin

2016-10-11  Bin Cheng  

* tree-vect-patterns.c (vect_recog_min_max_modify_pattern): New.
(vect_vect_recog_func_ptrs): New element for above pattern.
* tree-vectorizer.h (NUM_PATTERNS): Increase by 1.

gcc/testsuite/ChangeLog
2016-10-11  Bin Cheng  

* gcc.dg/vect/vect-umax-modify-pattern.c: New test.
* gcc.dg/vect/vect-umin-modify-pattern.c: New test.diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index 7e6e45d..b502498 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -65,6 +65,8 @@ static gimple *vect_recog_divmod_pattern (vec *,
 static gimple *vect_recog_mult_pattern (vec *,
   tree *, tree *);
 
+static gimple *vect_recog_min_max_modify_pattern (vec *,
+ tree *, tree *);
 static gimple *vect_recog_mixed_size_cond_pattern (vec *,
  tree *, tree *);
 static gimple *vect_recog_bool_pattern (vec *, tree *, tree *);
@@ -91,6 +93,7 @@ static vect_recog_func 
vect_vect_recog_func_ptrs[NUM_PATTERNS] = {
   { vect_recog_vector_vector_shift_pattern, "vector_vector_shift" },
   {vect_recog_divmod_pattern, "divmod" },
   {vect_recog_mult_pattern, "mult" },
+  {vect_recog_min_max_modify_pattern, "min_max_modify" },
   {vect_recog_mixed_size_cond_pattern, "mixed_size_cond" },
   {vect_recog_bool_pattern, "bool" },
   {vect_recog_mask_conversion_pattern, "mask_conversion" }
@@ -2964,6 +2967,262 @@ vect_recog_divmod_pattern (vec *stmts,
   return pattern_stmt;
 }
 
+/* Function vect_recog_min_max_modify_pattern
+
+   Try to find the following pattern:
+
+ type x_t, iftmp1_t, iftmp2_t;
+ TYPE a_T;
+   loop:
+ S1  a_T = (TYPE)x_t;
+ S2  iftmp1_t = x_t - CONST1;
+ S3  iftmp2_t = (a_T > (TYPE)CONST2) ? iftmp1_t : (CONST2 - CONST1);
+
+   Or
+
+   loop:
+ S1  a_T = (TYPE)x_t;
+ S2  iftmp1_t = x_t + CONST1;
+ S3  iftmp2_t = (a_T < (TYPE)CONST2) ? iftmp1_t : (CONST2 + CONST1);
+
+   where both type 'TYPE' and 'type' are unsigned integral types and
+   TYPE is larger than type in prevision.  All constant operands need
+   to fit into 'type'.
+
+   Input:
+
+   * LAST_STMT: A stmt from which the pattern search begins.
+
+   Output:
+
+   * TYPE_IN: The type of the input arguments to the pattern.
+
+   * TYPE_OUT: The type of the output of this pattern.
+
+   * Return value: A new stmt that will be used to replace the pattern,
+ as well as an additional def_stmt is generated.
+
+   patt_5 = MAX_EXPR ;
+   iftmp2_t = patt_5 - CONST1;
+
+ Or
+
+   patt_5 = MIN_EXPR ;
+   iftmp2_t = patt_5 + CONST1;  */
+
+static gimple *
+vect_recog_min_max_modify_pattern (vec *stmts, tree *type_in,
+  tree *type_out)
+{
+  gimple *last_stmt = (*stmts)[0];
+  stmt_vec_info stmt_vinfo = vinfo_for_stmt (last_stmt), def_stmt_info;
+  gimple *pattern_stmt, *def_stmt;
+  vec_info *vinfo = stmt_vinfo->vinfo;
+  enum tree_code code, p_code;
+  tree op0 = NULL_TREE, op1, p_op1, orig_type;
+  bool promotion;
+
+  if (!is_gimple_assign (last_stmt)
+  || gimple_assign_rhs_code (last_stmt) != COND_EXPR
+  || STMT_VINFO_DEF_TYPE (stmt_vinfo) != vect_internal_def)
+return NULL;
+
+  tree cond_expr = gimple_assign_rhs1 (last_stmt);
+  if (!COMPARISON_CLASS_P (cond_expr))
+return NULL;
+
+  enum tree_code cond_code = TREE_CODE (cond_expr);
+  if (cond_code != LE_EXPR && cond_code != LT_EXPR
+  && cond_code != GE_EXPR && cond_code != GT_EXPR)
+return NULL;
+
+  tree then_clause = gimple_assign_rhs2 (

[PATCH] Split print_rtx into subroutines

2016-10-11 Thread David Malcolm
print_rtx is a ~550 line function, the bulk of which is a ~400-line
switch statement, with a fair amount to #if logic.

This patch simplifies things by moving the switch statement into its
own subroutine, and by moving the more complicated cases into their
own subroutines.

No functional changes (but preliminary work for various other dump
improvements I'd like to make).

Successfully bootstrapped®rtested on x86_64-pc-linux-gnu.

OK for trunk?

gcc/ChangeLog:
* print-rtl.c (print_rtx): Rename "i" to "idx".  Split out the
operand-printing "switch" statement into...
(print_rtx_operand): ...this new function, ...
(print_rtx_operand_code_0): ...this new function, ...
(print_rtx_operand_code_e): ...this new function, ...
(print_rtx_operand_codes_E_and_V): ...this new function, ...
(print_rtx_operand_code_i): ...this new function, ...
(print_rtx_operand_code_r): ...this new function, ...
(print_rtx_operand_code_u): ...and this new function.
---
 gcc/print-rtl.c | 858 ++--
 1 file changed, 462 insertions(+), 396 deletions(-)

diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
index a905127..bb5817a 100644
--- a/gcc/print-rtl.c
+++ b/gcc/print-rtl.c
@@ -61,6 +61,13 @@ static int indent;
 static bool in_call_function_usage;
 
 static void print_rtx (const_rtx);
+static void print_rtx_operand (const_rtx in_rtx, int idx);
+static void print_rtx_operand_code_0 (const_rtx in_rtx, int idx);
+static void print_rtx_operand_code_e (const_rtx in_rtx, int idx);
+static void print_rtx_operand_codes_E_and_V (const_rtx in_rtx, int idx);
+static void print_rtx_operand_code_i (const_rtx in_rtx, int idx);
+static void print_rtx_operand_code_r (const_rtx in_rtx);
+static void print_rtx_operand_code_u (const_rtx in_rtx, int idx);
 
 /* String printed at beginning of each RTL when it is dumped.
This string is set to ASM_COMMENT_START when the RTL is dumped in
@@ -99,10 +106,7 @@ print_mem_expr (FILE *outfile, const_tree expr)
 static void
 print_rtx (const_rtx in_rtx)
 {
-  int i = 0;
-  int j;
-  const char *format_ptr;
-  int is_insn;
+  int idx = 0;
 
   if (sawclose)
 {
@@ -127,8 +131,6 @@ print_rtx (const_rtx in_rtx)
return;
 }
 
-  is_insn = INSN_P (in_rtx);
-
   /* Print name of expression code.  */
   if (flag_simple && CONST_INT_P (in_rtx))
 fputc ('(', outfile);
@@ -184,14 +186,14 @@ print_rtx (const_rtx in_rtx)
  == VAR_INIT_STATUS_UNINITIALIZED)
fprintf (outfile, " [uninit]");
  sawclose = 1;
- i = GET_RTX_LENGTH (VAR_LOCATION);
+ idx = GET_RTX_LENGTH (VAR_LOCATION);
}
 #endif
 }
 
 #ifndef GENERATOR_FILE
   if (CONST_DOUBLE_AS_FLOAT_P (in_rtx))
-i = 5;
+idx = 5;
 #endif
 
   if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx)))
@@ -204,394 +206,8 @@ print_rtx (const_rtx in_rtx)
 
   /* Get the format string and skip the first elements if we have handled
  them already.  */
-  format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx)) + i;
-  for (; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++)
-switch (*format_ptr++)
-  {
-   const char *str;
-
-  case 'T':
-   str = XTMPL (in_rtx, i);
-   goto string;
-
-  case 'S':
-  case 's':
-   str = XSTR (in_rtx, i);
-  string:
-
-   if (str == 0)
- fputs (" \"\"", outfile);
-   else
- fprintf (outfile, " (\"%s\")", str);
-   sawclose = 1;
-   break;
-
-   /* 0 indicates a field for internal use that should not be printed.
-  An exception is the third field of a NOTE, where it indicates
-  that the field has several different valid contents.  */
-  case '0':
-#ifndef GENERATOR_FILE
-   if (i == 1 && GET_CODE (in_rtx) == SYMBOL_REF)
- {
-   int flags = SYMBOL_REF_FLAGS (in_rtx);
-   if (flags)
- fprintf (outfile, " [flags %#x]", flags);
-   tree decl = SYMBOL_REF_DECL (in_rtx);
-   if (decl)
- print_node_brief (outfile, "", decl, dump_flags);
- }
-   else if (i == 3 && NOTE_P (in_rtx))
- {
-   switch (NOTE_KIND (in_rtx))
- {
- case NOTE_INSN_EH_REGION_BEG:
- case NOTE_INSN_EH_REGION_END:
-   if (flag_dump_unnumbered)
- fprintf (outfile, " #");
-   else
- fprintf (outfile, " %d", NOTE_EH_HANDLER (in_rtx));
-   sawclose = 1;
-   break;
-
- case NOTE_INSN_BLOCK_BEG:
- case NOTE_INSN_BLOCK_END:
-   dump_addr (outfile, " ", NOTE_BLOCK (in_rtx));
-   sawclose = 1;
-   break;
-
- case NOTE_INSN_BASIC_BLOCK:
-   {
- basic_block bb = NOTE_BASIC_BLOCK (in_rtx);
- if (bb != 0)
-   fprintf (outfile, " [bb %d]", bb->index);
- break;
-   }
-
-

Re: [PATCH] Split print_rtx into subroutines

2016-10-11 Thread Bernd Schmidt

On 10/11/2016 05:34 PM, David Malcolm wrote:


+static void print_rtx_operand (const_rtx in_rtx, int idx);
+static void print_rtx_operand_code_0 (const_rtx in_rtx, int idx);
+static void print_rtx_operand_code_e (const_rtx in_rtx, int idx);
+static void print_rtx_operand_codes_E_and_V (const_rtx in_rtx, int idx);
+static void print_rtx_operand_code_i (const_rtx in_rtx, int idx);
+static void print_rtx_operand_code_r (const_rtx in_rtx);
+static void print_rtx_operand_code_u (const_rtx in_rtx, int idx);


Please order functions so as to avoid needing forward declarations as 
much as possible.


Ok with that change. Before committing, please verify that dumps 
produced before and after for one large input file are identical.



Bernd


Re: [PATCH][check_GNU_style.sh] More aggressively ignore dg-xxx directives

2016-10-11 Thread Jeff Law

On 10/11/2016 05:01 AM, Bernd Schmidt wrote:

On 10/11/2016 12:56 PM, Jakub Jelinek wrote:

On Tue, Oct 11, 2016 at 11:47:21AM +0100, Kyrill Tkachov wrote:

check_GNU_style.sh complains a lot about dg-* directives in the
testsuite and in particular about line lengths.
There's nothing we can do about the directives and sometimes they're
supposed to be long, in particular the scan-assembler
checks in dg-final.  Currently check_GNU_style.sh has code to avoid
warning for dg-* directives but it's too weak, it doesn't
catch dg-final or dg-options directives.
This patch makes the code ignore all "{ dg-.*" lines for length
purposes.
This eliminates a lot of false positives in my patches and didn't
filter any legitimate warnings in my patches.


I wonder if we just shouldn't ignore all line lengths in testcases (or
perhaps any coding style whatsoever).  Some testcases are meant to be
formatted more-less according to our coding style (but, e.g.
/* PR tree-optimization/12345 */
comments never end with . and 2 spaces), except for dg- directives, but
others are entered in whatever form they came from the reporter.


I agree, probably best not to check testcases for style (but then I
don't trust automatic checkers anyway).

Agreed that checking testcases for style isn't desirable.


jeff


Re: [PATCH 01/16] read-md.c: Add various cleanups to ~rtx_reader

2016-10-11 Thread David Malcolm
On Wed, 2016-10-05 at 17:51 +0200, Bernd Schmidt wrote:
> On 10/05/2016 06:14 PM, David Malcolm wrote:
> > The selftests for the RTL frontend require supporting multiple
> > reader instances being alive one after another in-process, so
> > this lack of cleanup would become a leak.
> 
> > +  /* Initialize global data.  */
> > +  obstack_init (&string_obstack);
> > +  ptr_locs = htab_create (161, leading_ptr_hash, leading_ptr_eq_p,
> > 0);
> > +  obstack_init (&ptr_loc_obstack);
> > +  joined_conditions = htab_create (161, leading_ptr_hash,
> > leading_ptr_eq_p, 0);
> > +  obstack_init (&joined_conditions_obstack);
> > +  md_constants = htab_create (31, leading_string_hash,
> > + leading_string_eq_p, (htab_del) 0);
> > +  enum_types = htab_create (31, leading_string_hash,
> > +   leading_string_eq_p, (htab_del) 0);
> > +
> > +  /* Unlock the stdio streams.  */
> > +  unlock_std_streams ();
> 
> Hmm, but these are global statics. Shouldn't they first be moved to 
> become class members?

[CCing Richard Sandiford]

I tried to move these into class rtx_reader, but doing so rapidly
became quite invasive, with many of functions in the gen* tools
becoming methods.

Arguably that would be a good thing, but there are a couple of issues:

(a) some of these functions take "vec" arguments; moving them from
static functions to being class methods requires that vec.h has been
included when the relevant class decl is parsed.

(b) rtx_reader turns into a bug dumping ground of methods, for the
union of all of the various gen* tools.

One way to alleviate these issues would be to do the split of
rtx_reader into base_rtx_reader vs rtx_reader from patch 9 of the kit:
  https://gcc.gnu.org/ml/gcc-patches/2016-10/msg00273.html
and perhaps to split out part of read-md.h into a new read-rtl.h.

Before I reorganize the patches, does this approach sound reasonable?

Alternatively, a less invasive approach is to have an accessor for
these fields, so that things using them can get at them via the
rtx_reader_ptr singleton e.g.:

void
grow_string_obstack (char ch)
{
   obstack_1grow (rtx_reader_ptr->get_string_obstack (), ch);
}

and similar.

Thoughts?
Dave


Re: [PATCH][check_GNU_style.sh] More aggressively ignore dg-xxx directives

2016-10-11 Thread Kyrill Tkachov


On 11/10/16 16:13, Jeff Law wrote:

On 10/11/2016 05:01 AM, Bernd Schmidt wrote:

On 10/11/2016 12:56 PM, Jakub Jelinek wrote:

On Tue, Oct 11, 2016 at 11:47:21AM +0100, Kyrill Tkachov wrote:

check_GNU_style.sh complains a lot about dg-* directives in the
testsuite and in particular about line lengths.
There's nothing we can do about the directives and sometimes they're
supposed to be long, in particular the scan-assembler
checks in dg-final.  Currently check_GNU_style.sh has code to avoid
warning for dg-* directives but it's too weak, it doesn't
catch dg-final or dg-options directives.
This patch makes the code ignore all "{ dg-.*" lines for length
purposes.
This eliminates a lot of false positives in my patches and didn't
filter any legitimate warnings in my patches.


I wonder if we just shouldn't ignore all line lengths in testcases (or
perhaps any coding style whatsoever).  Some testcases are meant to be
formatted more-less according to our coding style (but, e.g.
/* PR tree-optimization/12345 */
comments never end with . and 2 spaces), except for dg- directives, but
others are entered in whatever form they came from the reporter.


I agree, probably best not to check testcases for style (but then I
don't trust automatic checkers anyway).

Agreed that checking testcases for style isn't desirable.



Ok, here's a patch that does that by filtering out everything between "+++.*testsuite/" and 
"+++".
Is this is an ok approach?
This eliminates all testsuite warnings on a few of my patches that I tried it 
out on.

Disclaimer: I'm not an awk expert.

Thanks,
Kyrill

2016-10-11  Kyrylo Tkachov  

* check_GNU_style.sh (remove_testsuite): New function.
Use it to remove testsuite from the diff.



jeff


diff --git a/contrib/check_GNU_style.sh b/contrib/check_GNU_style.sh
index 87a276c9cf47b5e07c4407f740ce05dce1928c30..f290a83e20eed7920155b2258d6cc6f424fc0dc0 100755
--- a/contrib/check_GNU_style.sh
+++ b/contrib/check_GNU_style.sh
@@ -81,7 +81,17 @@ if [ $nfiles -eq 1 ]; then
 else
 format="-nH"
 fi
+
+# Remove the testsuite part of the diff.  We don't care about GNU style
+# in testcases and the dg-* directives give too many false positives.
+remove_testsuite ()
+{
+  awk 'BEGIN{testsuite=0} /^\+\+\+[[:space:]]/ && ! /testsuite/{testsuite=0} \
+   {if (!testsuite) print} /\+\+\+[[:space:]].*testsuite\//{testsuite=1}'
+}
+
 grep $format '^+' $files \
+| remove_testsuite \
 | grep -v ':+++' \
 > $inp
 
@@ -162,6 +172,7 @@ col (){
 	# Don't reuse $inp, which may be generated using -H and thus contain a
 	# file prefix.
 	grep -n '^+' $f \
+	| remove_testsuite \
 	| grep -v ':+++' \
 	> $tmp
 
@@ -178,7 +189,7 @@ col (){
 	cat "$tmp" \
 	| sed 's/^[0-9]*:+//' \
 	| expand \
-	| awk '$0 !~ /{[[:space:]]*dg-(error|warning|message)[[:space:]]/ { \
+	| awk '{ \
 		 if (length($0) > 80) \
 		   printf "%s\033[1;31m%s\033[0m\n", \
 			  substr($0,1,80), \


Re: PING! Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math

2016-10-11 Thread Jerry DeLisle
On 10/11/2016 07:37 AM, Andrew Pinski wrote:
> 
> Looks like it was only broken for some mpfr's.  That is ones which is
> compiled with gcc it worked but one which comes with Ubuntu 1604 it
> does not.  they are exactly the same version too.
> 
> Thanks,
> Andrew

Also broken on Fedora 24.

Fritz, suggest you revert unless you have a quick fix. Or maybe go without using
mpfr_mod_d for a while.

Jerry


[PATCH v2] testsuite: Use -Wno-psabi instead of pruning compiler messages

2016-10-11 Thread Segher Boessenkool
It is much nicer to avoid a warning than to manually prune it from the
compiler output.  This patch adds -Wno-psabi to various testcases, and
removes dg-prune-output, for the testcases where x86 and/or PowerPC had
those (or did warn, so the testcase failed).  It also removes -w whenever
there is -Wno-psabi already.

Tested on powerpc64-linux {-m32,-m64}, and on x86_64-linux
{-m64,-m32/-msse,-m32/-mno-sse}.  No changes, except there are a few
fewer FAILs with -m32/-mno-sse (because of the -Wno-psabi).

Is this okay for trunk?


2016-10-11  Segher Boessenkool  

gcc/testsuite/
* c-c++-common/Wbool-operation-1.c: Add -Wno-psabi and do not prune
the messages printed by -Wpsabi.  Do not use -w.
* c-c++-common/Wunused-var-15.c: Ditto.
* c-c++-common/convert-vec-1.c: Ditto.
* c-c++-common/scal-to-vec2.c: Ditto.
* c-c++-common/torture/vector-compare-2.c: Ditto.
* c-c++-common/vector-compare-1.c: Ditto.
* c-c++-common/vector-compare-2.c: Ditto.
* c-c++-common/vector-compare-4.c: Ditto.
* c-c++-common/vector-subscript-4.c: Ditto.
* g++.dg/conversion/simd1.C: Ditto.
* g++.dg/cpp0x/constexpr-53094-2.C: Ditto.
* g++.dg/cpp0x/constexpr-53094-3.C: Ditto.
* g++.dg/cpp0x/constexpr-55573.C: Ditto.
* g++.dg/ext/attribute-test-1.C: Ditto.
* g++.dg/ext/attribute-test-2.C: Ditto.
* g++.dg/ext/attribute-test-3.C: Ditto.
* g++.dg/ext/attribute-test-4.C: Ditto.
* g++.dg/ext/pr56790-1.C: Ditto.
* g++.dg/ext/pr70290.C: Ditto.
* g++.dg/ext/vector14.C: Ditto.
* g++.dg/ext/vector23.C: Ditto.
* g++.dg/torture/pr38565.C: Ditto.
* g++.dg/torture/pr63419.C: Ditto.
* g++.dg/torture/pr70251.C: Ditto.
* g++.dg/torture/pr70499.C: Ditto.
* gcc.c-torture/compile/pr33617.c: Ditto.
* gcc.dg/Wstrict-aliasing-bogus-ref-all-2.c: Ditto.
* gcc.dg/compat/vector-1_x.c: Ditto.
* gcc.dg/compat/vector-1_y.c: Ditto.
* gcc.dg/compat/vector-1a_x.c: Ditto.
* gcc.dg/compat/vector-1a_y.c: Ditto.
* gcc.dg/compat/vector-1b_x.c: Ditto.
* gcc.dg/compat/vector-1b_y.c: Ditto.
* gcc.dg/compat/vector-2_x.c: Ditto.
* gcc.dg/compat/vector-2_y.c: Ditto.
* gcc.dg/compat/vector-2a_x.c: Ditto.
* gcc.dg/compat/vector-2a_y.c: Ditto.
* gcc.dg/compat/vector-2b_x.c: Ditto.
* gcc.dg/compat/vector-2b_y.c: Ditto.
* gcc.dg/graphite/id-pr46845.c: Ditto.
* gcc.dg/plugin/diagnostic-test-expressions-1.c: Ditto.
* gcc.dg/pr34856.c: Ditto.
* gcc.dg/pr35442.c: Ditto.
* gcc.dg/pr43300.c: Ditto.
* gcc.dg/pr44136.c: Ditto.
* gcc.dg/pr53060.c: Ditto.
* gcc.dg/pr63594-1.c: Ditto.
* gcc.dg/pr63594-2.c: Ditto.
* gcc.dg/pr63914.c: Ditto.
* gcc.dg/pr69634.c: Ditto.
* gcc.dg/pr70022.c: Ditto.
* gcc.dg/pr70050.c: Ditto.
* gcc.dg/pr70219.c: Ditto.
* gcc.dg/pr70326.c: Ditto.
* gcc.dg/pr71478.c: Ditto.
* gcc.dg/pr76783.c: Ditto.
* gcc.dg/simd-7.c: Ditto.
* gcc.dg/simd-8.c: Ditto.
* gcc.dg/torture/pr36891.c: Ditto.
* gcc.dg/torture/pr47968.c: Ditto.
* gcc.dg/torture/pr52402.c: Ditto.
* gcc.dg/torture/pr69613.c: Ditto.
* gcc.dg/torture/pr69886.c: Ditto.
* gcc.dg/torture/pr70083.c: Ditto.
* gcc.dg/torture/pr70307.c: Ditto.
* gcc.dg/torture/pr70421.c: Ditto.
* gcc.dg/torture/pr71428.c: Ditto.
* gcc.dg/torture/pr71984.c: Ditto.
* gcc.dg/tree-ssa/forwprop-35.c: Ditto.
* gcc.dg/tree-ssa/pr68714.c: Ditto.
* gcc.dg/tree-ssa/pr70372.c: Ditto.
* gcc.dg/tree-ssa/pr71179.c: Ditto.
* gcc.dg/tree-ssa/ssa-fre-55.c: Ditto.
* gcc.dg/tree-ssa/vector-6.c: Ditto.
* gcc.target/i386/vect-args.c: Ditto.

---
 gcc/testsuite/c-c++-common/Wbool-operation-1.c  | 2 --
 gcc/testsuite/c-c++-common/Wunused-var-15.c | 3 ---
 gcc/testsuite/c-c++-common/convert-vec-1.c  | 3 ++-
 gcc/testsuite/c-c++-common/scal-to-vec2.c   | 3 +--
 gcc/testsuite/c-c++-common/torture/vector-compare-2.c   | 2 +-
 gcc/testsuite/c-c++-common/vector-compare-1.c   | 3 +--
 gcc/testsuite/c-c++-common/vector-compare-2.c   | 3 +--
 gcc/testsuite/c-c++-common/vector-compare-4.c   | 2 --
 gcc/testsuite/c-c++-common/vector-subscript-4.c | 2 +-
 gcc/testsuite/g++.dg/conversion/simd1.C | 4 +---
 gcc/testsuite/g++.dg/cpp0x/constexpr-53094-2.C  | 4 +---
 gcc/testsuite/g++.dg/cpp0x/constexpr-53094-3.C  | 3 +--
 gcc/testsuite/g++.dg/cpp0x/constexpr-55573.C| 3 +--
 gcc/testsuite/g++.dg/ext/attribute-test-1.C | 6 +-
 gcc/testsuite/g++.dg/ext/attribute-test-2.C | 6 +-
 gcc/t

[PATCH, PING*3] DWARF: space-optimize loc. descr. for integer literals on 32-bit targets

2016-10-11 Thread Pierre-Marie de Rodat

Hello,

Ping for the patch submitted at 
. Thanks!


--
Pierre-Marie de Rodat



Re: [PATCH 09/16] Split class rtx_reader into base_rtx_reader vs rtx_reader

2016-10-11 Thread Bernd Schmidt

On 10/05/2016 06:15 PM, David Malcolm wrote:

- rtx_reader_ptr->get_top_level_filename ());
+ base_rtx_reader_ptr->get_top_level_filename ());


I wonder if the number of changes could be minimized by retaining the 
name rtx_reader for the base class, and using something more specific 
for the derived ones. Or would that require renaming a bunch of other 
locations?



-static void
-read_rtx_operand (rtx return_rtx, int idx)
+rtx
+rtx_reader::read_rtx_operand (rtx return_rtx, int idx)
 {
   RTX_CODE code = GET_CODE (return_rtx);
   const char *format_ptr = GET_RTX_FORMAT (code);


> +
> +  return return_rtx;
>  }
>

This appears to be an unrelated change. The return value needs to be 
documented.



Bernd


Re: [PATCH v2] testsuite: Use -Wno-psabi instead of pruning compiler messages

2016-10-11 Thread Jakub Jelinek
On Tue, Oct 11, 2016 at 03:43:03PM +, Segher Boessenkool wrote:
> It is much nicer to avoid a warning than to manually prune it from the
> compiler output.  This patch adds -Wno-psabi to various testcases, and
> removes dg-prune-output, for the testcases where x86 and/or PowerPC had
> those (or did warn, so the testcase failed).  It also removes -w whenever
> there is -Wno-psabi already.
> 
> Tested on powerpc64-linux {-m32,-m64}, and on x86_64-linux
> {-m64,-m32/-msse,-m32/-mno-sse}.  No changes, except there are a few
> fewer FAILs with -m32/-mno-sse (because of the -Wno-psabi).
> 
> Is this okay for trunk?

LGTM, though if you'd like to spend some short extra time on it, further
changes would be appreciated.

> --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-53094-3.C
> +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-53094-3.C
> @@ -1,7 +1,6 @@
>  // { dg-do compile { target c++11 } }
>  // { dg-options "" }
> -// Ignore warning on some powerpc-ibm-aix configurations.
> -// { dg-prune-output "non-standard ABI extension" }
> +// { dg-additional-options "-Wno-psabi" }

Here I'd just use
// { dg-options "-Wno-psabi" }
and not add dg-additional-options.

> --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-55573.C
> +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-55573.C
> @@ -1,8 +1,7 @@
>  // PR c++/55573
>  // { dg-do compile { target c++11 } }
>  // { dg-options "" }
> -// Ignore warning on some powerpc-ibm-aix configurations.
> -// { dg-prune-output "non-standard ABI extension" }
> +// { dg-additional-options "-Wno-psabi" }

Likewise.

> --- a/gcc/testsuite/g++.dg/ext/pr56790-1.C
> +++ b/gcc/testsuite/g++.dg/ext/pr56790-1.C
> @@ -1,6 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fdump-tree-ccp1" } */
> -/* { dg-prune-output "changes the ABI" } */
> +/* { dg-additional-options "-Wno-psabi" } */

Similarly, append -Wno-psabi to dg-options.

> --- a/gcc/testsuite/g++.dg/ext/vector23.C
> +++ b/gcc/testsuite/g++.dg/ext/vector23.C
> @@ -1,9 +1,6 @@
>  /* { dg-do compile { target c++14 } } */
>  /* { dg-options "-Wsign-conversion" } */
> -// Ignore warning on some powerpc-linux configurations.
> -// { dg-prune-output "non-standard ABI extension" }
> -// Ignore warning on Linux/x86
> -// { dg-prune-output "changes the ABI" }
> +/* { dg-additional-options "-Wno-psabi" } */

Similarly.

> --- a/gcc/testsuite/gcc.c-torture/compile/pr33617.c
> +++ b/gcc/testsuite/gcc.c-torture/compile/pr33617.c
> @@ -1,4 +1,4 @@
> -/* { dg-options "-w -Wno-psabi" { target { i?86-*-* x86_64-*-* } } } */
> +/* { dg-options "-Wno-psabi" { target { i?86-*-* x86_64-*-* } } } */

Is there any reason to limit the -Wno-psabi to i?86-*-* x86_64-*-* ?

> --- a/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-ref-all-2.c
> +++ b/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-ref-all-2.c
> @@ -2,6 +2,7 @@
>  /* { dg-options "-O2 -Wall" } */
>  /* { dg-options "-O2 -Wall -mabi=altivec" { target { { powerpc*-*-linux* } 
> && ilp32 } } } */
>  /* { dg-options "-O2 -Wall -msse2" { target { i?86-*-* x86_64-*-* } } } */
> +/* { dg-additional-options "-Wno-psabi" } */

This really should be turned into:
/* { dg-options "-O2 -Wall -Wno-psabi" } */
/* { dg-additional-options "-mabi=altivec" { target { { powerpc*-*-linux* } && 
ilp32 } } } */
/* { dg-additional-options "-msse2" { target { i?86-*-* x86_64-*-* } } } */

> --- a/gcc/testsuite/gcc.dg/compat/vector-2_x.c
> +++ b/gcc/testsuite/gcc.dg/compat/vector-2_x.c
> @@ -1,5 +1,5 @@
> -/* { dg-options "-w" } */
> -/* { dg-options "-w -mno-mmx -Wno-psabi" { target { i?86-*-* x86_64-*-* } } 
> } */
> +/* { dg-options "-Wno-psabi" } */
> +/* { dg-options "-Wno-psabi -mno-mmx" { target { i?86-*-* x86_64-*-* } } } */

Similarly.

> --- a/gcc/testsuite/gcc.dg/compat/vector-2_y.c
> +++ b/gcc/testsuite/gcc.dg/compat/vector-2_y.c
> @@ -1,5 +1,5 @@
> -/* { dg-options "-w" } */
> -/* { dg-options "-w -mno-mmx -Wno-psabi" { target { i?86-*-* x86_64-*-* } } 
> } */
> +/* { dg-options "-Wno-psabi" } */
> +/* { dg-options "-Wno-psabi -mno-mmx" { target { i?86-*-* x86_64-*-* } } } */

Likewise.

> --- a/gcc/testsuite/gcc.dg/graphite/id-pr46845.c
> +++ b/gcc/testsuite/gcc.dg/graphite/id-pr46845.c
> @@ -1,4 +1,4 @@
> -/* { dg-options "-O2 -ffast-math -fgraphite-identity -w -Wno-psabi" { target 
> { i?86-*-* x86_64-*-* powerpc*-*-* } } } */
> +/* { dg-options "-O2 -ffast-math -fgraphite-identity -Wno-psabi" { target { 
> i?86-*-* x86_64-*-* powerpc*-*-* } } } */

This is just weird.  I'd try to remove the target selector altogether.

> --- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-expressions-1.c
> +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-expressions-1.c
> @@ -1,5 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O -fdiagnostics-show-caret" } */
> +/* { dg-additional-options "-Wno-psabi" } */

Append to dg-options.

> --- a/gcc/testsuite/gcc.dg/pr34856.c
> +++ b/gcc/testsuite/gcc.dg/pr34856.c
> @@ -1,5 +1,5 @@
>  /* { dg-do compile } */
> -/* { dg-options "-O2" } */
> +/* { dg-options "-O2 -Wno-psabi" } */
>  /* { d

Re: PING! Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math

2016-10-11 Thread Aaron Sawdey
On Tue, 2016-10-11 at 07:26 -0400, Fritz Reese wrote:
> On Mon, Oct 10, 2016 at 3:56 PM, Steve Kargl
>  wrote:
> ...
> > 
> > There are a few small clean-up that can be
> > done.  For example,
> > 
> > +static gfc_expr *
> > +get_radians (gfc_expr *deg)
> > +{
> > +  mpfr_t tmp;
> ...
> > 
> > the tmp variable is unneeded in the above.  Converting the double
> > precision 180.0 to mpfr_t and then dividing is probably slower
> > than just dividing by 180.
> > 
> > +  /* Set factor = pi / 180.  */
> > +  factor = gfc_get_constant_expr (deg->ts.type, deg->ts.kind,
> > °->where);
> > +  mpfr_const_pi (factor->value.real, GFC_RND_MODE);
> > +  mpfr_div_ui (factor->value.real, factor->value.real, 180,
> > GFC_RND_MODE);
> > 
> ...
> 
> Good catch, fixed and committed r240989. Many thanks to you and
> Jerry.
> 
> ---
> Fritz Reese
> 

I think the first part of that cleanup didn't get applied as I am
seeing this:

../../gcc/gcc/fortran/iresolve.c: In function âgfc_expr* 
get_degrees(gfc_expr*)â:
../../gcc/gcc/fortran/iresolve.c:2728:14: error: âtmpâ was not declared in this 
scope

and also this:

../../gcc/gcc/fortran/simplify.c: In function âvoid radians_f(__mpfr_struct*, 
mpfr_rnd_t)â:
../../gcc/gcc/fortran/simplify.c:1775:5: error: âmpfr_fmod_dâ was not declared 
in this scope
 mpfr_fmod_d (tmp, x, 360.0, rnd_mode);
 ^~~

-- 
Aaron Sawdey, Ph.D.  acsaw...@linux.vnet.ibm.com
050-2/C113  (507) 253-7520 home: 507/263-0782
IBM Linux Technology Center - PPC Toolchain



[PATCH, alpha]: Use alpha-passes.def to register passes.

2016-10-11 Thread Uros Bizjak
2016-10-11  Uros Bizjak  

* config/alpha/alpha-passes.def: New file.
* config/alpha/t-alpha: New file.
* config/alpha/alpha-protos.h (gcc::context, rtl_opt_pass): Declare.
(make_pass_handle_trap_shadows): New prototype.
(make_pass_align_insns): Ditto.
* config/alpha/alpha.c (alpha_option_override): Don't register
passes here.
* config.gcc (alpha*-*-*) Add alpha/t-alpha to tmake_file.

Bootstrapped and regression tested on alphaev68-linux-gnu.

Committed to mainline SVN.

BTW - Jakub, it looks there is a bug in awk script. If the order of
pass insertion commands in alpha/alpha-passes.def is reversed to:

  INSERT_PASS_AFTER (pass_convert_to_eh_region_ranges, 1,
pass_handle_trap_shadows);
  INSERT_PASS_BEFORE (pass_shorten_branches, 1, pass_align_insns);

then the second pass is not registered for some reason. This can be
seen in generated pass-instances.def (also when building crosscompiler
to alpha-linux-gnu), where pass_align_insns insertion is simply
missing from what is the correct pass order:

  NEXT_PASS (pass_convert_to_eh_region_ranges, 1);
  NEXT_PASS ( pass_handle_trap_shadows, 1);
  NEXT_PASS ( pass_align_insns, 1);
  NEXT_PASS (pass_shorten_branches, 1);

(There is no problem with the pass insertion commands order, as
committed in the patch).

BTW2: There is a superfluous space generated after the opening paren.

Uros.
Index: config/alpha/alpha-passes.def
===
--- config/alpha/alpha-passes.def   (nonexistent)
+++ config/alpha/alpha-passes.def   (working copy)
@@ -0,0 +1,21 @@
+/* Description of target passes for DEC Alpha
+   Copyright (C) 2016 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC 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
+.  */
+
+  INSERT_PASS_BEFORE (pass_shorten_branches, 1, pass_align_insns);
+  INSERT_PASS_AFTER (pass_convert_to_eh_region_ranges, 1, 
pass_handle_trap_shadows);
Index: config/alpha/alpha-protos.h
===
--- config/alpha/alpha-protos.h (revision 240976)
+++ config/alpha/alpha-protos.h (working copy)
@@ -112,3 +112,9 @@ extern rtx unicosmk_add_call_info_word (rtx);
 extern bool some_small_symbolic_operand_int (rtx);
 extern int tls_symbolic_operand_1 (rtx, int, int);
 extern rtx resolve_reload_operand (rtx);
+
+namespace gcc { class context; }
+class rtl_opt_pass;
+
+extern rtl_opt_pass *make_pass_handle_trap_shadows (gcc::context *);
+extern rtl_opt_pass *make_pass_align_insns (gcc::context *);
Index: config/alpha/alpha.c
===
--- config/alpha/alpha.c(revision 240976)
+++ config/alpha/alpha.c(working copy)
@@ -374,18 +374,6 @@ alpha_option_override (void)
   64, 64, 16*1024 }
   };
 
-  opt_pass *pass_handle_trap_shadows = make_pass_handle_trap_shadows (g);
-  struct register_pass_info handle_trap_shadows_info
-= { pass_handle_trap_shadows, "eh_ranges",
-   1, PASS_POS_INSERT_AFTER
-  };
-
-  opt_pass *pass_align_insns = make_pass_align_insns (g);
-  struct register_pass_info align_insns_info
-= { pass_align_insns, "shorten",
-   1, PASS_POS_INSERT_BEFORE
-  };
-
   int const ct_size = ARRAY_SIZE (cpu_table);
   int line_size = 0, l1_size = 0, l2_size = 0;
   int i;
@@ -610,9 +598,6 @@ alpha_option_override (void)
 target_flags |= MASK_LONG_DOUBLE_128;
 #endif
 
-  /* This needs to be done at start up.  It's convenient to do it here.  */
-  register_pass (&handle_trap_shadows_info);
-  register_pass (&align_insns_info);
 }
 
 /* Implement targetm.override_options_after_change.  */
Index: config/alpha/t-alpha
===
--- config/alpha/t-alpha(nonexistent)
+++ config/alpha/t-alpha(working copy)
@@ -0,0 +1,19 @@
+# Copyright (C) 2016 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC 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 m

Re: [PATCH,rs6000] Add built-in function support for Power9 string operations

2016-10-11 Thread Segher Boessenkool
On Mon, Oct 10, 2016 at 12:11:40PM -0600, Kelvin Nilsen wrote:
> 
> This patch adds support for 26 new instructions that are introduced
> with the Power ISA 3.0 (Power9).  The instructions are lxvl, stxvl,
> vcmpneb, "vcmpneb.", vcmnezb, "vcmpnezb.", vcmpneh, "vcmpneh.", vcmpnezh,
> "vcmpnezh.", cmpnew, "vcmpnew.", vcmpnezw, "vcmpnezw.", vclzlsbb, vctzlsbb,
> vextublx, vextubrx, vextuhlx, vextuhrx, vextuwlx, vextuwrx,
> xvcmpnesp, "xvcmpnesp.", xvcmpnedp, and "xvcmpnedp.".
> 
> The new support consists in part of changes to the implementation of
> the vec_cmp_ne, vec_all_ne, and vec_any_eq functions, so that these
> built-in functions now translate into Power9 instructions when the
> target architecture supports Power9.
> 
> Additionally, the following built-in functions have been added:
> 
>vec_all_nez: Test for all vector elements not equal and not zero
>vec_any_eqz: Test for any vector elements equal or zero
>vec_cmpnez: Do pairwise comparison of two vectors, setting the
>   corresponding element of the result vector to all ones if the
>   pairwise comparison finds the pair of incoming values are not
>   equal of if either of the pair's values equals zero.
>vec_cntlz_lsbb: Count leading zeros of least significant byte bits.
>vec_cnttz_lsbb: Count trailing zeros of least significant byte bits.
>vec_xl_len: Load a variable length vector from memory.
>vec_xst_len: Store a variable lenght vector to memory.
>vec_xlx: Extract element from vector left indexed.
>vec_xrx: Extract element from vector right indexed.
> 
> All of the built-in functions mentioned above conform to a draft
> update of "Power Architecture 64-Bit ELF V2 ABI Specification",
> also known as "OpenPOWER ABI for Linux Supplement".
> 
> New tests have been added to exercise each of the new functions
> and to exercise the non-deprecated forms of the modified functions.
> 
> This patch has been bootstrapped and tested on
> powerpc64le-unknown-linux (little-endian) and on
> powerpc64-unknown-linux (big-endian, with both -m32 and -m64 target
> options) with no regressions.  Is this ok for the trunk? 

>   (vec_any_eq): Revised macro under _ARCH_PWR9 conditional
>   compilation. 

Trailing space.  There are a few more; please fix all.

>  static rtx
> +altivec_expand_stxvl_builtin (enum insn_code icode, tree exp)
> +{
> +  rtx pat;
> +  tree arg0 = CALL_EXPR_ARG (exp, 0);
> +  tree arg1 = CALL_EXPR_ARG (exp, 1);
> +  tree arg2 = CALL_EXPR_ARG (exp, 2);
> +  rtx op0 = expand_normal (arg0);
> +  rtx op1 = expand_normal (arg1);
> +  rtx op2 = expand_normal (arg2);
> +  /*  machine_mode tmode = insn_data[icode].operand[0].mode; */

Delete that last line?  Or is it useful some way?

> +;; ISA 3.0 String Operations (VSU) Support

What does "VSU" here mean?  (Don't tell me, put it in the patch :-) )

> +(define_insn "*vsx_ne__p"
> +  [(set (reg:CC 74)

Please don't hardcode the register number.  CR6_REGNO instead.  I thought
I changed it everywhere?  Is your base an old tree?

> +(define_insn "*stxvl"
> +  [(set (mem:V16QI (match_operand:DI 1 "gpc_reg_operand" "b"))
> + (unspec:V16QI
> +  [(match_operand:V16QI 0 "vsx_register_operand" "wa")
> +   (match_operand:DI 2 "register_operand" "r")]
> +  UNSPEC_STXVL))]
> +  "TARGET_P9_VECTOR && TARGET_64BIT"
> +  "sldi %2,%2\;stxvl %x0,%1,%2"

On all these patterns you change operand 2, but the constraints don't
say; that probably will not work correctly?  I'm thinking you need "+r".

> -;; Vec int modes
> -(define_mode_iterator VI [V4SI V8HI V16QI])
>  ;; Like VI, but add ISA 2.07 integer vector ops
>  (define_mode_iterator VI2 [V4SI V8HI V16QI V2DI])

"Like VI", but you removed VI.

> Index: gcc/config/rs6000/vector.md
> ===
> --- gcc/config/rs6000/vector.md   (revision 239612)
> +++ gcc/config/rs6000/vector.md   (working copy)
> @@ -61,6 +61,9 @@
>  ;; Vector modes for 64-bit base types
>  (define_mode_iterator VEC_64 [V2DI V2DF])
>  
> +;; Vector integer modes
> +(define_mode_iterator VI [V4SI V8HI V16QI])

... oh, you added it back here?  Why?

> +;; This expansion handles the V16QI, V8HI, and V4SI modes in the
> +;; implementation of the vec_all_ne and vec_any_eq built-in functions
> +;; on Power9.
> +(define_expand "vector_ne__p"
> +  [(parallel
> +[(set (reg:CC 74)
> +   (unspec:CC [(ne:CC (match_operand:VI 1 "vlogical_operand" "")
> +  (match_operand:VI 2 "vlogical_operand" ""))]
> +UNSPEC_PREDICATE))
> + (set (match_operand:VI 0 "vlogical_operand" "")
> +   (ne:VI (match_dup 1)
> +  (match_dup 2)))])]
> +  "TARGET_P9_VECTOR"
> +  "")

You can drop the default args (the "" at the end of operands).

> +/* Overloaded CMPNE support was implemented prior to Power 9,
> +   so is not mentioned here.  */
> +BU_P9V_OVERLOAD_2 (CMPNEZ,   "vcmpnez")
> +
> +BU_P9V_OVERLOAD_P (VCMPNEZ_P,   "vcmpnez_p")
> +BU_P9V_OVE

Re: [PATCH] Remove x86 pcommit instruction

2016-10-11 Thread Andrew Senkevich
2016-10-06 1:07 GMT+03:00 H.J. Lu :
> On Wed, Oct 5, 2016 at 1:42 PM, Andrew Senkevich
>  wrote:
>> 2016-10-05 18:06 GMT+03:00 Uros Bizjak :
>>> On Wed, Oct 5, 2016 at 3:47 PM, Andrew Senkevich
>>>  wrote:
> -mpcommit
> -Target Report Mask(ISA_PCOMMIT) Var(ix86_isa_flags) Save
> -Support PCOMMIT instruction.
> -
>
> You should not simply delete a option that was in the released
> compiler, but a warning should be emitted instead. Please see how
> msse5 is handled in i386.opt.

 Thank you, it is fixed in patch below. Ok for trunk?
>>>
>>> OK.
>>>
 Is it subject for backport for 5.* and 6.* releases?
>>>
>>> Yes, but please wait a couple of days if any problem arises in trunk.
>>>
>>> (Please also provide an entry for Release Changes, since this is
>>> user-facing change. Also for release branches.)
>>
>> Hi HJ,
>>
>> could you please commit this patch for trunk since I have no commit rights.
>> Attached in format for git am.
>>
>>
>
> Done.

Thanks, HJ!

Should I ask you or somebody else for backports for to 5.* and 6.* or
may be I can somehow get commit after approval rights to don't disturb
others with commits? I am preparing several patches.



--
WBR,
Andrew


Re: [PATCH] Remove x86 pcommit instruction

2016-10-11 Thread H.J. Lu
On Tue, Oct 11, 2016 at 10:04 AM, Andrew Senkevich
 wrote:
> 2016-10-06 1:07 GMT+03:00 H.J. Lu :
>> On Wed, Oct 5, 2016 at 1:42 PM, Andrew Senkevich
>>  wrote:
>>> 2016-10-05 18:06 GMT+03:00 Uros Bizjak :
 On Wed, Oct 5, 2016 at 3:47 PM, Andrew Senkevich
  wrote:
>> -mpcommit
>> -Target Report Mask(ISA_PCOMMIT) Var(ix86_isa_flags) Save
>> -Support PCOMMIT instruction.
>> -
>>
>> You should not simply delete a option that was in the released
>> compiler, but a warning should be emitted instead. Please see how
>> msse5 is handled in i386.opt.
>
> Thank you, it is fixed in patch below. Ok for trunk?

 OK.

> Is it subject for backport for 5.* and 6.* releases?

 Yes, but please wait a couple of days if any problem arises in trunk.

 (Please also provide an entry for Release Changes, since this is
 user-facing change. Also for release branches.)
>>>
>>> Hi HJ,
>>>
>>> could you please commit this patch for trunk since I have no commit rights.
>>> Attached in format for git am.
>>>
>>>
>>
>> Done.
>
> Thanks, HJ!
>
> Should I ask you or somebody else for backports for to 5.* and 6.* or
> may be I can somehow get commit after approval rights to don't disturb
> others with commits? I am preparing several patches.
>

Please provide patches for GCC 5 and 6.


-- 
H.J.


Re: [PATCH], PR 77924, Fix PowerPC breakage on AIX

2016-10-11 Thread Segher Boessenkool
On Mon, Oct 10, 2016 at 04:46:53PM -0400, Michael Meissner wrote:
> I accidently broke AIX with my patch on October 6th.  That patch split
> -mfloat128 into -mfloat128-type and -mfloat128 under PowerPC Linux.  This 
> patch
> fixes that issue.  I bootstrapped it on PowerPC Linux with no regressions, and
> David Edelsohn reports that it fixes the problem on AIX.  Is it ok to apply 
> the
> patch?
> 
> 2016-10-10  Michael Meissner  
> 
>   PR target/77924
>   * config/rs6000/rs6000.c (rs6000_init_builtins): Only create the
>   distinct __ibm128 IBM extended double type if long doubles are
>   128-bits and the default format for long double is IEEE 128-bit.

Okay, thanks!


Segher


Re: [PATCH, RS6000, PR77934] mtvsrdd needs b (base register) constraint on first input

2016-10-11 Thread Segher Boessenkool
On Tue, Oct 11, 2016 at 09:39:10AM -0500, Aaron Sawdey wrote:
> Gcc 7 trunk was generating incorrect code for spec2k6 403.gcc due to
> this constraint issue. OK for trunk after bootstrap/regtest passes?
> 
> 2016-10-06  Aaron Sawdey  
> 
>   PR target/77934
>   * config/rs6000/vmx.md (vsx_concat_): The mtvsrdd instruction
>   needs a base register for arg 1.
> 
> 
> Index: gcc/config/rs6000/vsx.md
> ===
> --- gcc/config/rs6000/vsx.md(revision 240994)
> +++ gcc/config/rs6000/vsx.md(working copy)
> @@ -1938,7 +1938,7 @@
>  (define_insn "vsx_concat_"
>[(set (match_operand:VSX_D 0 "gpc_reg_operand" "=,we")
> (vec_concat:VSX_D
> -(match_operand: 1 "gpc_reg_operand" ",r")
> +(match_operand: 1 "gpc_reg_operand" ",b")
>  (match_operand: 2 "gpc_reg_operand" ",r")))]

That does

  else if (which_alternative == 1)
return (BYTES_BIG_ENDIAN
? "mtvsrdd %x0,%1,%2"
: "mtvsrdd %x0,%2,%1");

so you need the same for operand 2 as well?  Okay with that change.

Thanks,


Segher


Re: [PATCH v2] testsuite: Use -Wno-psabi instead of pruning compiler messages

2016-10-11 Thread Segher Boessenkool
On Tue, Oct 11, 2016 at 06:11:29PM +0200, Jakub Jelinek wrote:
> On Tue, Oct 11, 2016 at 03:43:03PM +, Segher Boessenkool wrote:
> > It is much nicer to avoid a warning than to manually prune it from the
> > compiler output.  This patch adds -Wno-psabi to various testcases, and
> > removes dg-prune-output, for the testcases where x86 and/or PowerPC had
> > those (or did warn, so the testcase failed).  It also removes -w whenever
> > there is -Wno-psabi already.
> > 
> > Tested on powerpc64-linux {-m32,-m64}, and on x86_64-linux
> > {-m64,-m32/-msse,-m32/-mno-sse}.  No changes, except there are a few
> > fewer FAILs with -m32/-mno-sse (because of the -Wno-psabi).
> > 
> > Is this okay for trunk?
> 
> LGTM, though if you'd like to spend some short extra time on it, further
> changes would be appreciated.

This set is ballooning so much already :-)  I'll see what I can do.

> > --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-53094-3.C
> > +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-53094-3.C
> > @@ -1,7 +1,6 @@
> >  // { dg-do compile { target c++11 } }
> >  // { dg-options "" }
> > -// Ignore warning on some powerpc-ibm-aix configurations.
> > -// { dg-prune-output "non-standard ABI extension" }
> > +// { dg-additional-options "-Wno-psabi" }
> 
> Here I'd just use
> // { dg-options "-Wno-psabi" }
> and not add dg-additional-options.

I would get rid of dg-options completely, it's an abomination, but that
unfortunately changes behaviour.  dg-additional-options always does what
you think, but dg-options does not.

> > --- a/gcc/testsuite/gcc.c-torture/compile/pr33617.c
> > +++ b/gcc/testsuite/gcc.c-torture/compile/pr33617.c
> > @@ -1,4 +1,4 @@
> > -/* { dg-options "-w -Wno-psabi" { target { i?86-*-* x86_64-*-* } } } */
> > +/* { dg-options "-Wno-psabi" { target { i?86-*-* x86_64-*-* } } } */
> 
> Is there any reason to limit the -Wno-psabi to i?86-*-* x86_64-*-* ?

No not really, I mindlessly edited what was already there.

> > --- a/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-ref-all-2.c
> > +++ b/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-ref-all-2.c
> > @@ -2,6 +2,7 @@
> >  /* { dg-options "-O2 -Wall" } */
> >  /* { dg-options "-O2 -Wall -mabi=altivec" { target { { powerpc*-*-linux* } 
> > && ilp32 } } } */
> >  /* { dg-options "-O2 -Wall -msse2" { target { i?86-*-* x86_64-*-* } } } */
> > +/* { dg-additional-options "-Wno-psabi" } */
> 
> This really should be turned into:
> /* { dg-options "-O2 -Wall -Wno-psabi" } */
> /* { dg-additional-options "-mabi=altivec" { target { { powerpc*-*-linux* } 
> && ilp32 } } } */
> /* { dg-additional-options "-msse2" { target { i?86-*-* x86_64-*-* } } } */

Right.

> 
> > --- a/gcc/testsuite/gcc.dg/compat/vector-2_x.c
> > +++ b/gcc/testsuite/gcc.dg/compat/vector-2_x.c
> > @@ -1,5 +1,5 @@
> > -/* { dg-options "-w" } */
> > -/* { dg-options "-w -mno-mmx -Wno-psabi" { target { i?86-*-* x86_64-*-* } 
> > } } */
> > +/* { dg-options "-Wno-psabi" } */
> > +/* { dg-options "-Wno-psabi -mno-mmx" { target { i?86-*-* x86_64-*-* } } } 
> > */
> 
> Similarly.

compat.exp does not support dg-additional-options.

> > --- a/gcc/testsuite/gcc.dg/graphite/id-pr46845.c
> > +++ b/gcc/testsuite/gcc.dg/graphite/id-pr46845.c
> > @@ -1,4 +1,4 @@
> > -/* { dg-options "-O2 -ffast-math -fgraphite-identity -w -Wno-psabi" { 
> > target { i?86-*-* x86_64-*-* powerpc*-*-* } } } */
> > +/* { dg-options "-O2 -ffast-math -fgraphite-identity -Wno-psabi" { target 
> > { i?86-*-* x86_64-*-* powerpc*-*-* } } } */
> 
> This is just weird.  I'd try to remove the target selector altogether.

OK, will try.


Segher


Re: [PATCH v2] testsuite: Use -Wno-psabi instead of pruning compiler messages

2016-10-11 Thread Jakub Jelinek
On Tue, Oct 11, 2016 at 12:32:03PM -0500, Segher Boessenkool wrote:
> > > --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-53094-3.C
> > > +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-53094-3.C
> > > @@ -1,7 +1,6 @@
> > >  // { dg-do compile { target c++11 } }
> > >  // { dg-options "" }
> > > -// Ignore warning on some powerpc-ibm-aix configurations.
> > > -// { dg-prune-output "non-standard ABI extension" }
> > > +// { dg-additional-options "-Wno-psabi" }
> > 
> > Here I'd just use
> > // { dg-options "-Wno-psabi" }
> > and not add dg-additional-options.
> 
> I would get rid of dg-options completely, it's an abomination, but that
> unfortunately changes behaviour.  dg-additional-options always does what
> you think, but dg-options does not.

There are important differences between dg-options and
dg-additional-options, e.g. for g++.dg/ testsuite presence of dg-options
results in the -std=gnu++* modes being cycled (unless -std= appears in
those), while without dg-options it cycles through -std=c++* modes.
But, if there already is unconditional dg-options, adding
dg-additional-options instead of just adding that option to dg-options
doesn't make much sense.

> > > --- a/gcc/testsuite/gcc.dg/compat/vector-2_x.c
> > > +++ b/gcc/testsuite/gcc.dg/compat/vector-2_x.c
> > > @@ -1,5 +1,5 @@
> > > -/* { dg-options "-w" } */
> > > -/* { dg-options "-w -mno-mmx -Wno-psabi" { target { i?86-*-* x86_64-*-* 
> > > } } } */
> > > +/* { dg-options "-Wno-psabi" } */
> > > +/* { dg-options "-Wno-psabi -mno-mmx" { target { i?86-*-* x86_64-*-* } } 
> > > } */
> > 
> > Similarly.
> 
> compat.exp does not support dg-additional-options.

Okay.

> OK, will try.

Thanks.

Jakub


Re: PING! Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math

2016-10-11 Thread Andre Vehreschild
Hi all,

attached a small patch that resolves the issues at least on x86_64-linux/F23.

- Andre

On Tue, 11 Oct 2016 11:32:50 -0500
Aaron Sawdey  wrote:

> On Tue, 2016-10-11 at 07:26 -0400, Fritz Reese wrote:
> > On Mon, Oct 10, 2016 at 3:56 PM, Steve Kargl
> >  wrote:
> > ...  
> > > 
> > > There are a few small clean-up that can be
> > > done.  For example,
> > > 
> > > +static gfc_expr *
> > > +get_radians (gfc_expr *deg)
> > > +{
> > > +  mpfr_t tmp;  
> > ...  
> > > 
> > > the tmp variable is unneeded in the above.  Converting the double
> > > precision 180.0 to mpfr_t and then dividing is probably slower
> > > than just dividing by 180.
> > > 
> > > +  /* Set factor = pi / 180.  */
> > > +  factor = gfc_get_constant_expr (deg->ts.type, deg->ts.kind,
> > > °->where);
> > > +  mpfr_const_pi (factor->value.real, GFC_RND_MODE);
> > > +  mpfr_div_ui (factor->value.real, factor->value.real, 180,
> > > GFC_RND_MODE);
> > >   
> > ...
> > 
> > Good catch, fixed and committed r240989. Many thanks to you and
> > Jerry.
> > 
> > ---
> > Fritz Reese
> >   
> 
> I think the first part of that cleanup didn't get applied as I am
> seeing this:
> 
> ../../gcc/gcc/fortran/iresolve.c: In function âgfc_expr*
> get_degrees(gfc_expr*)â: ../../gcc/gcc/fortran/iresolve.c:2728:14: error:
> âtmpâ was not declared in this scope
> 
> and also this:
> 
> ../../gcc/gcc/fortran/simplify.c: In function âvoid radians_f(__mpfr_struct*,
> mpfr_rnd_t)â: ../../gcc/gcc/fortran/simplify.c:1775:5: error: âmpfr_fmod_dâ
> was not declared in this scope mpfr_fmod_d (tmp, x, 360.0, rnd_mode);
>  ^~~
> 


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 
diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
index f4f81b2..4334522 100644
--- a/gcc/fortran/iresolve.c
+++ b/gcc/fortran/iresolve.c
@@ -2702,6 +2702,7 @@ get_degrees (gfc_expr *rad)
 {
   gfc_expr *result, *factor;
   gfc_actual_arglist *mod_args;
+  mpfr_t tmp;
 
   gcc_assert (rad->ts.type == BT_REAL);
 
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index bf60f74..9204962 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -1768,11 +1768,13 @@ degrees_f (mpfr_t x, mp_rnd_t rnd_mode)
 static void
 radians_f (mpfr_t x, mp_rnd_t rnd_mode)
 {
-mpfr_t tmp;
+mpfr_t tmp, tmp2;
 mpfr_init (tmp);
+mpfr_init (tmp2);
 
 /* Set x = x % 360 to avoid offsets with large angles.  */
-mpfr_fmod_d (tmp, x, 360.0, rnd_mode);
+mpfr_set_d (tmp2, 360.0, rnd_mode);
+mpfr_fmod (tmp, x, tmp2, rnd_mode);
 
 /* Set x = x * pi.  */
 mpfr_const_pi (tmp, rnd_mode);
@@ -1782,6 +1784,7 @@ radians_f (mpfr_t x, mp_rnd_t rnd_mode)
 mpfr_div_d (x, x, 180.0, rnd_mode);
 
 mpfr_clear (tmp);
+mpfr_clear (tmp2);
 }
 
 


Re: PING! Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math

2016-10-11 Thread Jerry DeLisle

On 10/11/2016 09:32 AM, Aaron Sawdey wrote:
> On Tue, 2016-10-11 at 07:26 -0400, Fritz Reese wrote:
>> On Mon, Oct 10, 2016 at 3:56 PM, Steve Kargl
... snip ...
>
> I think the first part of that cleanup didn't get applied as I am
> seeing this:
>
> ../../gcc/gcc/fortran/iresolve.c: In function âgfc_expr* 
get_degrees(gfc_expr*)â:
> ../../gcc/gcc/fortran/iresolve.c:2728:14: error: âtmpâ was not declared in 
this scope

>
> and also this:
>
> ../../gcc/gcc/fortran/simplify.c: In function âvoid radians_f(__mpfr_struct*, 
mpfr_rnd_t)â:
> ../../gcc/gcc/fortran/simplify.c:1775:5: error: âmpfr_fmod_dâ was not 
declared in this scope

>  mpfr_fmod_d (tmp, x, 360.0, rnd_mode);
>  ^~~
>

This allows compilation. Still have to check if its the right result. --Jerry

diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
index f4f81b2e..4334522c 100644
--- a/gcc/fortran/iresolve.c
+++ b/gcc/fortran/iresolve.c
@@ -2702,6 +2702,7 @@ get_degrees (gfc_expr *rad)
 {
   gfc_expr *result, *factor;
   gfc_actual_arglist *mod_args;
+  mpfr_t tmp;

   gcc_assert (rad->ts.type == BT_REAL);

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index bf60f747..18135d2f 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -1768,11 +1768,13 @@ degrees_f (mpfr_t x, mp_rnd_t rnd_mode)
 static void
 radians_f (mpfr_t x, mp_rnd_t rnd_mode)
 {
-mpfr_t tmp;
+mpfr_t tmp, modtmp;
 mpfr_init (tmp);
+mpfr_init (modtmp);

 /* Set x = x % 360 to avoid offsets with large angles.  */
-mpfr_fmod_d (tmp, x, 360.0, rnd_mode);
+mpfr_set_d (modtmp, 360.0, GFC_RND_MODE);
+mpfr_fmod (tmp, x, modtmp, rnd_mode);

 /* Set x = x * pi.  */
 mpfr_const_pi (tmp, rnd_mode);
@@ -1782,6 +1784,7 @@ radians_f (mpfr_t x, mp_rnd_t rnd_mode)
 mpfr_div_d (x, x, 180.0, rnd_mode);

 mpfr_clear (tmp);
+mpfr_clear (modtmp);
 }




Re: PING! Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math

2016-10-11 Thread Steve Kargl
On Tue, Oct 11, 2016 at 11:10:13AM -0700, Jerry DeLisle wrote:
> 
> diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
> index bf60f747..18135d2f 100644
> --- a/gcc/fortran/simplify.c
> +++ b/gcc/fortran/simplify.c
> @@ -1768,11 +1768,13 @@ degrees_f (mpfr_t x, mp_rnd_t rnd_mode)
>   static void
>   radians_f (mpfr_t x, mp_rnd_t rnd_mode)
>   {
> -mpfr_t tmp;
> +mpfr_t tmp, modtmp;
>   mpfr_init (tmp);
> +mpfr_init (modtmp);

Delete modtmp.

> 
>   /* Set x = x % 360 to avoid offsets with large angles.  */
> -mpfr_fmod_d (tmp, x, 360.0, rnd_mode);
> +mpfr_set_d (modtmp, 360.0, GFC_RND_MODE);

Change this to 

   mpfr_set_ui(tmp, 360, rnd_mode);

> +mpfr_fmod (tmp, x, modtmp, rnd_mode);

Change this to 

mpfr_fmod (tmp, x, tmp, rnd_mode);

> 
>   /* Set x = x * pi.  */
>   mpfr_const_pi (tmp, rnd_mode);
> @@ -1782,6 +1784,7 @@ radians_f (mpfr_t x, mp_rnd_t rnd_mode)
>   mpfr_div_d (x, x, 180.0, rnd_mode);
> 
>   mpfr_clear (tmp);
> +mpfr_clear (modtmp);

Delete this.

>   }

-- 
Steve


Re: PING! Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math

2016-10-11 Thread Steve Kargl
On Tue, Oct 11, 2016 at 11:10:13AM -0700, Jerry DeLisle wrote:
> @@ -1782,6 +1784,7 @@ radians_f (mpfr_t x, mp_rnd_t rnd_mode)
>   mpfr_div_d (x, x, 180.0, rnd_mode);
> 

I forgot to point out that the above should changed to

   mpfr_div_ui (x, x, 180, rnd_mode);

In fact, any place where 180.0 and/or 360.0 should be
chnage to the unsigned integer equivalent.

-- 
Steve


Re: [PATCH v2] testsuite: Use -Wno-psabi instead of pruning compiler messages

2016-10-11 Thread Segher Boessenkool
On Tue, Oct 11, 2016 at 07:40:24PM +0200, Jakub Jelinek wrote:
> On Tue, Oct 11, 2016 at 12:32:03PM -0500, Segher Boessenkool wrote:
> > > > --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-53094-3.C
> > > > +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-53094-3.C
> > > > @@ -1,7 +1,6 @@
> > > >  // { dg-do compile { target c++11 } }
> > > >  // { dg-options "" }
> > > > -// Ignore warning on some powerpc-ibm-aix configurations.
> > > > -// { dg-prune-output "non-standard ABI extension" }
> > > > +// { dg-additional-options "-Wno-psabi" }
> > > 
> > > Here I'd just use
> > > // { dg-options "-Wno-psabi" }
> > > and not add dg-additional-options.
> > 
> > I would get rid of dg-options completely, it's an abomination, but that
> > unfortunately changes behaviour.  dg-additional-options always does what
> > you think, but dg-options does not.
> 
> There are important differences between dg-options and
> dg-additional-options, e.g. for g++.dg/ testsuite presence of dg-options
> results in the -std=gnu++* modes being cycled (unless -std= appears in
> those), while without dg-options it cycles through -std=c++* modes.
> But, if there already is unconditional dg-options, adding
> dg-additional-options instead of just adding that option to dg-options
> doesn't make much sense.

Hrm, I thought dg-options overrides even RUNTESTFLAGS, but it doesn't,
not in my single trivial test anyway.


Segher


Re: [PING][PATCH 3/4][Ada,DJGPP] Ada support for DJGPP

2016-10-11 Thread Andris Pavenis

On 10/11/2016 11:46 AM, Arnaud Charlet wrote:

I'd like to ping patch

https://gcc.gnu.org/ml/gcc-patches/2016-09/msg00164.html

Additional comments about using ZCX_By_Default := true are in
https://gcc.gnu.org/ml/gcc-patches/2016-09/msg00845.html

Well this patch doesn't inspire lots of confidence since the initial
version had the wrong setting and this got unnoticed.

It's OK on principle, but really shows that beyond building the compiler,
this port hasn't been used in practice.


Committed patches (except rejected 1/4)

About value of  ZCX_By_Default: exceptions work for DJGPP for both values true and false. So it is 
not too surprising that wrong setting got unnoticed.


Andris




Re: PING! Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math

2016-10-11 Thread Fritz Reese
On Mon, 2016-10-11 08:43 AM, Markus Trippelsdorf  wrote:
> This patch breaks bootstrap:
...

Sorry all!! was in a rush to get in the car this morning and made a
hasty commit. Fixed for r241001 (sorry Jerry, I was a little too
slow.)

---
Fritz Reese


Re: PING! Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math

2016-10-11 Thread Fritz Reese
On Tue, Oct 11, 2016 at 2:44 PM, Fritz Reese  wrote:
> On Mon, 2016-10-11 08:43 AM, Markus Trippelsdorf  
> wrote:
>> This patch breaks bootstrap:
> ...
>
> Sorry all!! was in a rush to get in the car this morning and made a
> hasty commit. Fixed for r241001 (sorry Jerry, I was a little too
> slow.)
>
> ---
> Fritz Reese


dec_math_4_fix.patch
Description: Binary data


Bootstrap breakage in Fortran

2016-10-11 Thread Jerry DeLisle

There was a breakage in Fortran that has now been fixed.

In case anyone runs into it. Resolved by:

M   gcc/fortran/ChangeLog
M   gcc/fortran/iresolve.c
M   gcc/fortran/simplify.c
r241000 = 7b8ebc39f2db57dcadd8b8f22b6b7561d187c279 (refs/remotes/svn/trunk)

Related to a recent patch adding COTAN function.

Regards,

Jerry


Re: [PATCH] Implement new hook for max_align_t_align

2016-10-11 Thread Jason Merrill
/* Alignment, in bits, a C conformant malloc implementation has to
provide.
   The HP-UX malloc implementation provides a default alignment of 8
bytes.
   This can be increased with mallopt.  The glibc implementation also
provides
   8-byte alignment.  Note that this isn't enough for various POSIX
types such
   as pthread_mutex_t.  However, since we no longer need the 16-byte
alignment
   for atomic operations, we ignore the nominal alignment specified
for these
   types.  The same is true for long double on 64-bit HP-UX.  */

If PA malloc doesn't actually provide 16-byte alignment, this change
seems problematic; it will mean any type that wants 16-byte alignment
will silently get 8-byte alignment instead.

Jason


Re: [PATCH] Implement new hook for max_align_t_align

2016-10-11 Thread DJ Delorie

Jason Merrill  writes:
> If PA malloc doesn't actually provide 16-byte alignment, this change
> seems problematic; it will mean any type that wants 16-byte alignment
> will silently get 8-byte alignment instead.

Should such cases be calling memalign (or posix_memalign) instead of
malloc?


[PATCH] Fix formatting of the -fdec-math changes

2016-10-11 Thread Jakub Jelinek
On Tue, Oct 11, 2016 at 02:47:34PM -0400, Fritz Reese wrote:
> On Tue, Oct 11, 2016 at 2:44 PM, Fritz Reese  wrote:
> > On Mon, 2016-10-11 08:43 AM, Markus Trippelsdorf  
> > wrote:
> >> This patch breaks bootstrap:
> > ...
> >
> > Sorry all!! was in a rush to get in the car this morning and made a
> > hasty commit. Fixed for r241001 (sorry Jerry, I was a little too
> > slow.)

While looking at the changes, I've noticed various coding style and
formatting issues (mainly wrong indentation).

The patch below should resolve what I've noticed.  Ok for trunk if it passes
bootstrap/regtest?

2016-10-11  Jakub Jelinek  

* iresolve.c (is_trig_resolved, resolve_trig_call): Formatting fixes.
* simplify.c (simplify_trig_call, degrees_f, radians_f,
gfc_simplify_atrigd, gfc_simplify_cotan): Likewise.

--- gcc/fortran/iresolve.c.jj   2016-10-11 20:51:01.754308259 +0200
+++ gcc/fortran/iresolve.c  2016-10-11 20:55:35.677852859 +0200
@@ -685,8 +685,8 @@ is_trig_resolved (gfc_expr *f)
 {
   /* We know we've already resolved the function if we see the lib call
  starting with '__'.  */
-  return f->value.function.name != NULL
-&& 0 == strncmp ("__", f->value.function.name, 2);
+  return (f->value.function.name != NULL
+ && strncmp ("__", f->value.function.name, 2) == 0);
 }
 
 /* Return a shallow copy of the function expression f.  The original expression
@@ -2744,28 +2744,26 @@ resolve_trig_call (gfc_expr *f, gfc_expr
 {
   switch (f->value.function.isym->id)
 {
-  case GFC_ISYM_ACOS:
-   return gfc_resolve_acos (f, x);
-  case GFC_ISYM_ASIN:
-   return gfc_resolve_asin (f, x);
-  case GFC_ISYM_ATAN:
-   return gfc_resolve_atan (f, x);
-  case GFC_ISYM_ATAN2:
-   /* NB. arg3 is unused for atan2 */
-   return gfc_resolve_atan2 (f, x, NULL);
-  case GFC_ISYM_COS:
-   return gfc_resolve_cos (f, x);
-  case GFC_ISYM_COTAN:
-   return gfc_resolve_cotan (f, x);
-  case GFC_ISYM_SIN:
-   return gfc_resolve_sin (f, x);
-  case GFC_ISYM_TAN:
-   return gfc_resolve_tan (f, x);
-  default:
-   break;
+case GFC_ISYM_ACOS:
+  return gfc_resolve_acos (f, x);
+case GFC_ISYM_ASIN:
+  return gfc_resolve_asin (f, x);
+case GFC_ISYM_ATAN:
+  return gfc_resolve_atan (f, x);
+case GFC_ISYM_ATAN2:
+  /* NB. arg3 is unused for atan2 */
+  return gfc_resolve_atan2 (f, x, NULL);
+case GFC_ISYM_COS:
+  return gfc_resolve_cos (f, x);
+case GFC_ISYM_COTAN:
+  return gfc_resolve_cotan (f, x);
+case GFC_ISYM_SIN:
+  return gfc_resolve_sin (f, x);
+case GFC_ISYM_TAN:
+  return gfc_resolve_tan (f, x);
+default:
+  gcc_unreachable ();
 }
-
-  gcc_unreachable ();
 }
 
 /* Resolve degree trig function as trigd (x) = trig (radians (x)).  */
--- gcc/fortran/simplify.c.jj   2016-10-11 20:51:01.767308095 +0200
+++ gcc/fortran/simplify.c  2016-10-11 20:56:27.468199551 +0200
@@ -1717,27 +1717,24 @@ simplify_trig_call (gfc_expr *icall)
 
   /* The actual simplifiers will return NULL for non-constant x.  */
   switch (func)
-  {
+{
 case GFC_ISYM_ACOS:
-   return gfc_simplify_acos (x);
+  return gfc_simplify_acos (x);
 case GFC_ISYM_ASIN:
-   return gfc_simplify_asin (x);
+  return gfc_simplify_asin (x);
 case GFC_ISYM_ATAN:
-   return gfc_simplify_atan (x);
+  return gfc_simplify_atan (x);
 case GFC_ISYM_COS:
-   return gfc_simplify_cos (x);
+  return gfc_simplify_cos (x);
 case GFC_ISYM_COTAN:
-   return gfc_simplify_cotan (x);
+  return gfc_simplify_cotan (x);
 case GFC_ISYM_SIN:
-   return gfc_simplify_sin (x);
+  return gfc_simplify_sin (x);
 case GFC_ISYM_TAN:
-   return gfc_simplify_tan (x);
+  return gfc_simplify_tan (x);
 default:
-break;
-  }
-
-  gfc_internal_error ("in simplify_trig_call(): Bad intrinsic");
-  return NULL;
+  gfc_internal_error ("in simplify_trig_call(): Bad intrinsic");
+}
 }
 
 /* Convert a floating-point number from radians to degrees.  */
@@ -1745,22 +1742,22 @@ simplify_trig_call (gfc_expr *icall)
 static void
 degrees_f (mpfr_t x, mp_rnd_t rnd_mode)
 {
-mpfr_t tmp;
-mpfr_init (tmp);
+  mpfr_t tmp;
+  mpfr_init (tmp);
 
-/* Set x = x % 2pi to avoid offsets with large angles.  */
-mpfr_const_pi (tmp, rnd_mode);
-mpfr_mul_ui (tmp, tmp, 2, rnd_mode);
-mpfr_fmod (tmp, x, tmp, rnd_mode);
-
-/* Set x = x * 180.  */
-mpfr_mul_ui (x, x, 180, rnd_mode);
-
-/* Set x = x / pi.  */
-mpfr_const_pi (tmp, rnd_mode);
-mpfr_div (x, x, tmp, rnd_mode);
+  /* Set x = x % 2pi to avoid offsets with large angles.  */
+  mpfr_const_pi (tmp, rnd_mode);
+  mpfr_mul_ui (tmp, tmp, 2, rnd_mode);
+  mpfr_fmod (tmp, x, tmp, rnd_mode);
+
+  /* Set x = x * 180.  */
+  mpfr_mul_ui (x, x, 180, rnd_mode);
+
+  /* Set x = x / pi.  */
+  mpfr_const_pi (tmp, rnd_mode);
+  mpfr_div (x, x, tmp, rnd_mode);
 
-mpfr_

Re: [PATCH][check_GNU_style.sh] More aggressively ignore dg-xxx directives

2016-10-11 Thread Martin Sebor

On 10/11/2016 09:22 AM, Kyrill Tkachov wrote:


On 11/10/16 16:13, Jeff Law wrote:

On 10/11/2016 05:01 AM, Bernd Schmidt wrote:

On 10/11/2016 12:56 PM, Jakub Jelinek wrote:

On Tue, Oct 11, 2016 at 11:47:21AM +0100, Kyrill Tkachov wrote:

check_GNU_style.sh complains a lot about dg-* directives in the
testsuite and in particular about line lengths.
There's nothing we can do about the directives and sometimes they're
supposed to be long, in particular the scan-assembler
checks in dg-final.  Currently check_GNU_style.sh has code to avoid
warning for dg-* directives but it's too weak, it doesn't
catch dg-final or dg-options directives.
This patch makes the code ignore all "{ dg-.*" lines for length
purposes.
This eliminates a lot of false positives in my patches and didn't
filter any legitimate warnings in my patches.


I wonder if we just shouldn't ignore all line lengths in testcases (or
perhaps any coding style whatsoever).  Some testcases are meant to be
formatted more-less according to our coding style (but, e.g.
/* PR tree-optimization/12345 */
comments never end with . and 2 spaces), except for dg- directives, but
others are entered in whatever form they came from the reporter.


I agree, probably best not to check testcases for style (but then I
don't trust automatic checkers anyway).

Agreed that checking testcases for style isn't desirable.



Ok, here's a patch that does that by filtering out everything between
"+++.*testsuite/" and "+++".
Is this is an ok approach?
This eliminates all testsuite warnings on a few of my patches that I
tried it out on.

Disclaimer: I'm not an awk expert.


I've been meaning to propose a similar change for some time so thanks!
Just a couple of minor comments (nits really) about the AWK script.

+# Remove the testsuite part of the diff.  We don't care about GNU style
+# in testcases and the dg-* directives give too many false positives.
+remove_testsuite ()
+{
+  awk 'BEGIN{testsuite=0} /^\+\+\+[[:space:]]/ && ! 
/testsuite/{testsuite=0} \
+   {if (!testsuite) print} 
/\+\+\+[[:space:]].*testsuite\//{testsuite=1}'

+}

In the standard (POSIX) diff format, modified file names are prefixed
by a line matching the "^+++ [^ /]" regular expression (i.e., with
exactly one space after +++).  [[:space:]] matches other whitespace
characters including newline and carriage return in the POSIX locale,
and possibly other characters in named locales.  Using a literal space
in the regex should be safer.

Also, the pattern that starts with "/\+\+\+" looks like it's missing
the ^ anchor.  Presumably it should be "/^\+\+\+ \/testsuite\//".

Martin


Re: [PATCH] Fix formatting of the -fdec-math changes

2016-10-11 Thread Fritz Reese
On Tue, Oct 11, 2016 at 3:00 PM, Jakub Jelinek  wrote:
> On Tue, Oct 11, 2016 at 02:47:34PM -0400, Fritz Reese wrote:
>> On Tue, Oct 11, 2016 at 2:44 PM, Fritz Reese  wrote:
>> > On Mon, 2016-10-11 08:43 AM, Markus Trippelsdorf  
>> > wrote:
>> >> This patch breaks bootstrap:
>> > ...
>> >
>> > Sorry all!! was in a rush to get in the car this morning and made a
>> > hasty commit. Fixed for r241001 (sorry Jerry, I was a little too
>> > slow.)
>
> While looking at the changes, I've noticed various coding style and
> formatting issues (mainly wrong indentation).
>
> The patch below should resolve what I've noticed.  Ok for trunk if it passes
> bootstrap/regtest?
>
> 2016-10-11  Jakub Jelinek  
>
> * iresolve.c (is_trig_resolved, resolve_trig_call): Formatting fixes.
> * simplify.c (simplify_trig_call, degrees_f, radians_f,
> gfc_simplify_atrigd, gfc_simplify_cotan): Likewise.
>

Thanks for these- I thought I fixed all that stuff already, but I
guess I miffed it somewhere along the line.

...
>
>  /* Resolve degree trig function as trigd (x) = trig (radians (x)).  */
> --- gcc/fortran/simplify.c.jj   2016-10-11 20:51:01.767308095 +0200
> +++ gcc/fortran/simplify.c  2016-10-11 20:56:27.468199551 +0200
> @@ -1717,27 +1717,24 @@ simplify_trig_call (gfc_expr *icall)
>
>/* The actual simplifiers will return NULL for non-constant x.  */
>switch (func)
> -  {
> +{
...
>  default:
> -break;
> -  }
> -
> -  gfc_internal_error ("in simplify_trig_call(): Bad intrinsic");
> -  return NULL;
> +  gfc_internal_error ("in simplify_trig_call(): Bad intrinsic");
> +}
>  }
>

I only had a 'return NULL' so no compiler could complain that
"simplify_trig_call might not return a value". Your way is okay too if
it works.

Otherwise looks OK to me. Thanks again.

---
Fritz Reese


Re: [PATCH][check_GNU_style.sh] More aggressively ignore dg-xxx directives

2016-10-11 Thread Jakub Jelinek
On Tue, Oct 11, 2016 at 01:11:04PM -0600, Martin Sebor wrote:
> Also, the pattern that starts with "/\+\+\+" looks like it's missing
> the ^ anchor.  Presumably it should be "/^\+\+\+ \/testsuite\//".

No, it will be almost never +++ /testsuite/
There needs to be .* in between "+++ " and "/testsuite/", and perhaps
it should also ignore "+++ testsuite/".
So /^\+\+\+ (.*\/)?testsuite\// ?
Also, normally (when matching $0) there won't be newlines in the text.

Jakub


Re: [PATCH] Fix formatting of the -fdec-math changes

2016-10-11 Thread Jakub Jelinek
On Tue, Oct 11, 2016 at 03:15:24PM -0400, Fritz Reese wrote:
> > --- gcc/fortran/simplify.c.jj   2016-10-11 20:51:01.767308095 +0200
> > +++ gcc/fortran/simplify.c  2016-10-11 20:56:27.468199551 +0200
> > @@ -1717,27 +1717,24 @@ simplify_trig_call (gfc_expr *icall)
> >
> >/* The actual simplifiers will return NULL for non-constant x.  */
> >switch (func)
> > -  {
> > +{
> ...
> >  default:
> > -break;
> > -  }
> > -
> > -  gfc_internal_error ("in simplify_trig_call(): Bad intrinsic");
> > -  return NULL;
> > +  gfc_internal_error ("in simplify_trig_call(): Bad intrinsic");
> > +}
> >  }
> >
> 
> I only had a 'return NULL' so no compiler could complain that
> "simplify_trig_call might not return a value". Your way is okay too if
> it works.

gfc_internal_error is marked __attribute__((noreturn)), so gcc should not
warn.  And, for other compilers we generally ignore warnings.

Jakub


Re: [PATCH v2] aarch64: Add split-stack initial support

2016-10-11 Thread Adhemerval Zanella


On 07/10/2016 05:28, Kyrill Tkachov wrote:
> Hi Adhemerval,
> 
> CC'ing the aarch64 maintainers/reviewers.
> I have some comments inline, mostly about the GCC coding conventions.

Thanks for the review.

>> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
>> index df6514d..c689440 100644
>> --- a/gcc/config/aarch64/aarch64.c
>> +++ b/gcc/config/aarch64/aarch64.c
>> @@ -3149,6 +3149,49 @@ aarch64_restore_callee_saves (machine_mode mode,
>>   }
>>   }
>>   +static bool
>> +split_stack_arg_pointer_used_p (void)
>> +{
> 
> New function needs a function comment.
> 

Ack, I will add one.

>> +  bool using_split_stack = (flag_split_stack
>> +&& (lookup_attribute ("no_split_stack",
>> +  DECL_ATTRIBUTES (cfun->decl))
>> +   == NULL));
>> +  if (using_split_stack == false)
>> +return false;
>> +
>> +  /* If the pseudo holding the arg pointer is no longer a pseudo,
>> + then the arg pointer is used.  */
>> +  if (cfun->machine->frame.split_stack_arg_pointer != NULL_RTX
>> +  && (!REG_P (cfun->machine->frame.split_stack_arg_pointer)
>> +  || (REGNO (cfun->machine->frame.split_stack_arg_pointer)
>> +  < FIRST_PSEUDO_REGISTER)))
>> +return true;
>> +
>> +  /* Unfortunately we also need to do some code scanning, since
>> + x10 may have been substituted for the pseudo.  */
>> +  rtx_insn *insn;
>> +  basic_block bb = ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb;
>> +  FOR_BB_INSNS (bb, insn)
>> +if (NONDEBUG_INSN_P (insn))
>> +  {
>> +df_ref use;
>> +FOR_EACH_INSN_USE (use, insn)
>> +  {
>> +rtx x = DF_REF_REG (use);
>> +if (REG_P (x) && REGNO (x) == R10_REGNUM)
>> +  return true;
>> +  }
>> +df_ref def;
>> +FOR_EACH_INSN_DEF (def, insn)
>> +  {
>> +rtx x = DF_REF_REG (def);
>> +if (REG_P (x) && REGNO (x) == R10_REGNUM)
>> +  return false;
>> +  }
>> +  }
>> +  return bitmap_bit_p (DF_LR_OUT (bb), R10_REGNUM);
>> +}
>> +
>>   /* AArch64 stack frames generated by this compiler look like:
>> +---+
>> @@ -3204,6 +3247,7 @@ aarch64_expand_prologue (void)
>> unsigned reg1 = cfun->machine->frame.wb_candidate1;
>> unsigned reg2 = cfun->machine->frame.wb_candidate2;
>> rtx_insn *insn;
>> +  bool split_stack_arg_pointer_used = split_stack_arg_pointer_used_p ();
>>   if (flag_stack_usage_info)
>>   current_function_static_stack_size = frame_size;
>> @@ -3220,6 +3264,10 @@ aarch64_expand_prologue (void)
>>   aarch64_emit_probe_stack_range (STACK_CHECK_PROTECT, frame_size);
>>   }
>>   +  /* Save split-stack argument pointer before stack adjustment.  */
>> +  if (split_stack_arg_pointer_used)
>> +emit_move_insn (gen_rtx_REG (Pmode, R10_REGNUM), stack_pointer_rtx);
>> +
>> aarch64_add_constant (Pmode, SP_REGNUM, IP0_REGNUM, -initial_adjust, 
>> true);
>>   if (callee_adjust != 0)
>> @@ -3243,6 +3291,30 @@ aarch64_expand_prologue (void)
>>callee_adjust != 0 || frame_pointer_needed);
>> aarch64_add_constant (Pmode, SP_REGNUM, IP1_REGNUM, -final_adjust,
>>   !frame_pointer_needed);
>> +
>> +  if (split_stack_arg_pointer_used_p ())
>> +{
>> +  /* Setup the argument pointer (x10) for -fsplit-stack code.  If
>> + __morestack was called, it will left the arg pointer to the
>> + old stack in x28.  Otherwise, the argument pointer is the top
>> + of current frame.  */
>> +  rtx x10 = gen_rtx_REG (Pmode, R10_REGNUM);
>> +  rtx x28 = gen_rtx_REG (Pmode, R28_REGNUM);
>> +  rtx not_more = gen_label_rtx ();
>> +  rtx cc_reg = gen_rtx_REG (CCmode, CC_REGNUM);
>> +  rtx jump;
>> +
>> +  jump = gen_rtx_IF_THEN_ELSE (VOIDmode,
>> +   gen_rtx_GEU (VOIDmode, cc_reg,
>> +const0_rtx),
>> +   gen_rtx_LABEL_REF (VOIDmode, not_more),
>> +   pc_rtx);
>> +  jump = emit_jump_insn (gen_rtx_SET (pc_rtx, jump));
> 
> Are you trying to emit a conditional jump here?
> If so it would be cleaner to use the pattern name you have in mind
> directly like so (barring typos ;):
> rtx cmp = gen_rtx_fmt_ee (GEU, VOIDmode, cc_reg, const0_rtx);
> jump = emit_jump_insn (gen_condjump (cmp, cc_reg, not_more));
> This will avoid constructing the SET and IF_THEN_ELSE rtxes manually.

Yes, the idea is to emit a conditional jump.  I have no preference here,
I used the IF_THEN_ELSE functions mainly because the other arches are
using it, but I think your suggestion should be simpler.

> 
>> +  JUMP_LABEL (jump) = not_more;
>> +  LABEL_NUSES (not_more) += 1;
>> +  emit_move_insn (x10, x28);
>> +  emit_label (not_more);
>> +}
>>   }
>> /* Return TRUE if we can use a simple_return insn.
>> @@ -9677,7 +9749,7 @@ aarch64_expand_builtin_va_start (tree valist, rtx 
>>

[Ada] Set Backend_Overflow_Checks to True everywhere

2016-10-11 Thread Eric Botcazou
It's not clear why this was set to False in some configuration files.

Applied on the mainline.


2016-10-11  Eric Botcazou  

* system-linux-armeb.ads (Backend_Overflow_Checks): Change to True.
* system-linux-mips.ads (Backend_Overflow_Checks): Likewise.
* system-linux-mips64el.ads (Backend_Overflow_Checks): Likewise.
* system-linux-mipsel.ads (Backend_Overflow_Checks): Likewise.
* system-linux-sparcv9.ads (Backend_Overflow_Checks): Likewise.
* system-rtems.ads: Likewise.

-- 
Eric BotcazouIndex: system-linux-armeb.ads
===
--- system-linux-armeb.ads	(revision 240962)
+++ system-linux-armeb.ads	(working copy)
@@ -7,7 +7,7 @@
 -- S p e c  --
 --(GNU-Linux/ARMEB Version) --
 --  --
---  Copyright (C) 1992-2015, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2016, Free Software Foundation, Inc. --
 --  --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -127,7 +127,7 @@ private
--  of the individual switch values.
 
Backend_Divide_Checks : constant Boolean := False;
-   Backend_Overflow_Checks   : constant Boolean := False;
+   Backend_Overflow_Checks   : constant Boolean := True;
Command_Line_Args : constant Boolean := True;
Configurable_Run_Time : constant Boolean := False;
Denorm: constant Boolean := True;
@@ -150,7 +150,7 @@ private
Always_Compatible_Rep : constant Boolean := False;
Suppress_Standard_Library : constant Boolean := False;
Use_Ada_Main_Program_Name : constant Boolean := False;
-   Frontend_Exceptions   : constant Boolean := True;
-   ZCX_By_Default: constant Boolean := False;
+   Frontend_Exceptions   : constant Boolean := False;
+   ZCX_By_Default: constant Boolean := True;
 
 end System;
Index: system-linux-mips.ads
===
--- system-linux-mips.ads	(revision 240962)
+++ system-linux-mips.ads	(working copy)
@@ -119,7 +119,7 @@ private
--  of the individual switch values.
 
Backend_Divide_Checks : constant Boolean := False;
-   Backend_Overflow_Checks   : constant Boolean := False;
+   Backend_Overflow_Checks   : constant Boolean := True;
Command_Line_Args : constant Boolean := True;
Configurable_Run_Time : constant Boolean := False;
Denorm: constant Boolean := True;
Index: system-linux-mips64el.ads
===
--- system-linux-mips64el.ads	(revision 240962)
+++ system-linux-mips64el.ads	(working copy)
@@ -119,7 +119,7 @@ private
--  of the individual switch values.
 
Backend_Divide_Checks : constant Boolean := False;
-   Backend_Overflow_Checks   : constant Boolean := False;
+   Backend_Overflow_Checks   : constant Boolean := True;
Command_Line_Args : constant Boolean := True;
Configurable_Run_Time : constant Boolean := False;
Denorm: constant Boolean := True;
Index: system-linux-mipsel.ads
===
--- system-linux-mipsel.ads	(revision 240962)
+++ system-linux-mipsel.ads	(working copy)
@@ -119,7 +119,7 @@ private
--  of the individual switch values.
 
Backend_Divide_Checks : constant Boolean := False;
-   Backend_Overflow_Checks   : constant Boolean := False;
+   Backend_Overflow_Checks   : constant Boolean := True;
Command_Line_Args : constant Boolean := True;
Configurable_Run_Time : constant Boolean := False;
Denorm: constant Boolean := True;
Index: system-linux-sparcv9.ads
===
--- system-linux-sparcv9.ads	(revision 240962)
+++ system-linux-sparcv9.ads	(working copy)
@@ -119,7 +119,7 @@ private
--  of the individual switch values.
 
Backend_Divide_Checks : constant Boolean := False;
-   Backend_Overflow_Checks   : constant Boolean := False;
+   Backend_Overflow_Checks   : constant Boolean := True;
Command_Line_Args : constant Boolean := True;
Configurable_Run_Time : constant Boolean := False;
Denorm: constant Boolean := True;
Index: system-rtems.ads
===
--- system-rtems.ads	(revision 240962)
+++ system-rtems.ads	(working copy)
@@ -138,7 +138,7 @@ private
--  of the individual switch values.
 
Backend_Divide_Checks : constant Boolean := False

Re: [PATCH] Implement new hook for max_align_t_align

2016-10-11 Thread John David Anglin

On 2016-10-11 2:50 PM, Jason Merrill wrote:

/* Alignment, in bits, a C conformant malloc implementation has to
provide.
The HP-UX malloc implementation provides a default alignment of 8
bytes.
This can be increased with mallopt.  The glibc implementation also
provides
8-byte alignment.  Note that this isn't enough for various POSIX
types such
as pthread_mutex_t.  However, since we no longer need the 16-byte
alignment
for atomic operations, we ignore the nominal alignment specified
for these
types.  The same is true for long double on 64-bit HP-UX.  */

If PA malloc doesn't actually provide 16-byte alignment, this change
seems problematic; it will mean any type that wants 16-byte alignment
will silently get 8-byte alignment instead.


I agree the situation is something of a mess.  On linux, we could bump 
the alignment
of malloc to 16-bytes.  However, Carlos argued that we don't need to and 
I think doing

so would be detrimental to performance.

The 16-byte alignment was used originally because the ldcw instruction 
used for atomic
operations in linux threads needs 16-byte alignment.  However, the nptl 
pthread
implementation now uses a kernel helper for atomic operations.  It only 
needs
4-byte alignment.  The largest alignment actually needed is for long 
double (8 bytes).
However, we can't change the 16-byte alignment without affecting the 
layout of various

structures.

The same is true for long double on HPUX.  Originally, it was planned to 
implement it
in hardware and that would have required 16-byte alignment.  It was only 
implemented
in software with an 8-byte alignment requirement.  Somehow, it ended up 
with 8 and
16-byte alignment in the HP 32 and 64-bit compilers, respectively. In 
both cases, malloc
has 8-byte alignment.  It is possible to increase the "grain" size of HP 
malloc to 16 bytes.


Thus, I don't think the silent reduction to 8-byte alignment matters.  
Without the change,

we are faced with spurious warnings from new.

--
 John David Anglin dave.ang...@bell.net


Re: fix -fmax-errors & notes

2016-10-11 Thread David Malcolm
On Tue, 2016-10-11 at 06:34 -0400, Nathan Sidwell wrote:
> Hi,
> Jonathan & I were chatting at the cauldron about how -fmax-errors
> kills any 
> notes about the final error.  That's because we bail out just after
> emitting the 
> final error.  This patch fixes the problem by bailing out just before
> emitting 
> the error or warning after that.
> 
> Sure, we'll do slightly more compilation than asked for, but this is
> the fatal 
> error path, so who cares how long it takes.  Better to get notes to
> the user.
> 
> I augmented the fmax-errors testcase so that the final emitted error
> has a 
> trailing note (which we now emit), and is followed by a warning
> (which causes us 
> to bail).
> 
> The same logic applies to -Wfatal-errors handling.
> 
> ok?

Thanks.  Various comments inline below.

> 2016-10-11  Nathan Sidwell  
> 
>   * diagnostic.c (diagnostic_action_after_output): Remove fatal
>   and max error handling here 
>   (diagnostic_report_diagnostic): ... do it here instead.
> 
>   testsuite/
>   * c-c++-common/fmax-errors.c: Add error with note.
> 
> Index: diagnostic.c
> ===
> --- diagnostic.c  (revision 240920)
> +++ diagnostic.c  (working copy)
> @@ -464,24 +464,6 @@ diagnostic_action_after_output (diagnost
>  case DK_SORRY:
>if (context->abort_on_error)
>   real_abort ();
> -  if (context->fatal_errors)
> - {
> -   fnotice (stderr, "compilation terminated due to -Wfatal
-errors.\n");
> -   diagnostic_finish (context);
> -   exit (FATAL_EXIT_CODE);
> - }
> -  if (context->max_errors != 0
> -   && ((unsigned) (diagnostic_kind_count (context, DK_ERROR)
> -   + diagnostic_kind_count (context,
DK_SORRY)
> -   + diagnostic_kind_count (context,
DK_WERROR))
> -   >= context->max_errors))
> - {
> -   fnotice (stderr,
> -"compilation terminated due to -fmax
-errors=%u.\n",
> -context->max_errors);
> -   diagnostic_finish (context);
> -   exit (FATAL_EXIT_CODE);
> - }
>break;
>  
>  case DK_ICE:
> @@ -890,6 +872,25 @@ diagnostic_report_diagnostic (diagnostic
>   return false;
>  }
>  
> +  if (diagnostic->kind != DK_NOTE
> +  && (unsigned)(diagnostic_kind_count (context, DK_ERROR)
> + + diagnostic_kind_count (context, DK_SORRY)
> + + diagnostic_kind_count (context, DK_WERROR))
> +  >= (context->fatal_errors ? 1
> +   : context->max_errors ? context->max_errors : ~0u))

Please simplify this conditional logic by breaking if up into multiple
nested if statements:

   if (diagnostic->kind != DK_NOTE)
 {
int count =
(diagnostic_kind_count (context, DK_ERROR)
 +
diagnostic_kind_count (context, DK_SORRY)
 +
diagnostic_kind_count (context, DK_WERROR);
or somesuch...

> +  >= (context->fatal_errors ? 1
> +   : context->max_errors ? context->max_errors : ~0u))
> +{
> +  /* Check before emitting the diagnostic that would exceed the
> +  limit.  This way we will emit notes relevant to the final
> +  emitted error.  */
> +  fnotice (stderr,
> +context->fatal_errors
> +? "compilation terminated due to -Wfatal-errors.\n"
> +: "compilation terminated due to -fmax-errors=%u.\n",
> +context->max_errors);
> +  diagnostic_finish (context);
> +  exit (FATAL_EXIT_CODE);
> +}

This logic is running when the next diagnostic is about to be emitted.
But what if the user has selected -Wfatal-errors and there's a single
error and no further diagnostics?  Could this change the observable
behavior?  (I'm trying to think of a case here, but failing).


>context->lock++;
>  
>if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
> Index: testsuite/c-c++-common/fmax-errors.c
> ===
> --- testsuite/c-c++-common/fmax-errors.c  (revision 240920)
> +++ testsuite/c-c++-common/fmax-errors.c  (working copy)
> @@ -1,11 +1,13 @@
>  /* PR c/44782 */
>  /* { dg-do compile } */
> -/* { dg-options "-fmax-errors=3" } */
> +/* { dg-options "-fmax-errors=3 -Wall" } */
>  
>  void foo (unsigned int i, unsigned int j)
>  {
>(i) ();/* { dg-error "" } */
>(j) ();/* { dg-error "" } */
> -  (i+j) ();  /* { dg-error "" } */
> +  (k) ();/* { dg-error "" } */
> +  /* { dg-message "identifier" "" { target c } 9 } */
> +  i + j; /* no warning.  */
>(i*j) ();  /* no error here due to -fmax
-errors */
>  } /* { dg-prune-output "compilation terminated" } */

Please can you add a comment about the dg-message directive, explaining
the intent.  ("Verify that with -fmax-errors that a note associated
with the final error is still emitted"

Re: [PATCH] Fix formatting of the -fdec-math changes

2016-10-11 Thread Steve Kargl
On Tue, Oct 11, 2016 at 09:00:54PM +0200, Jakub Jelinek wrote:
> On Tue, Oct 11, 2016 at 02:47:34PM -0400, Fritz Reese wrote:
> > On Tue, Oct 11, 2016 at 2:44 PM, Fritz Reese  wrote:
> > > On Mon, 2016-10-11 08:43 AM, Markus Trippelsdorf  
> > > wrote:
> > >> This patch breaks bootstrap:
> > > ...
> > >
> > > Sorry all!! was in a rush to get in the car this morning and made a
> > > hasty commit. Fixed for r241001 (sorry Jerry, I was a little too
> > > slow.)
> 
> While looking at the changes, I've noticed various coding style and
> formatting issues (mainly wrong indentation).
> 
> The patch below should resolve what I've noticed.  Ok for trunk if it passes
> bootstrap/regtest?
> 

Yes.  Formatting/style corrections are pre-approved.

-- 
Steve


  1   2   >