Re: [PATCH] Fix gimplification of const var initialization from COND_EXPR (PR c++/80129)

2017-03-22 Thread Richard Biener
On Tue, 21 Mar 2017, Jakub Jelinek wrote:

> Hi!
> 
> For non-gimple reg types var = x ? y : z; is gimplified as
> x ? (var = y) : (var = z);.  The problem is that if var is TREE_READONLY,
> we can gimplify one of those assignments by promoting them to TREE_STATIC
> (if not addressable) and making the initializer into their DECL_INITIAL.
> That doesn't work well, because then we conditionally store into that and
> during optimizations, as it is a TREE_READONLY var with DECL_INITIAL, just
> use that initializer for optimizations.
> 
> The following patch fixes that by clearing TREE_READONLY flag if we are
> going to store it more than once.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> 2017-03-21  Jakub Jelinek  
> 
>   PR c++/80129
>   * gimplify.c (gimplify_modify_expr_rhs) : Clear
>   TREE_READONLY on result if writing it more than once.
> 
>   * g++.dg/torture/pr80129.C: New test.
> 
> --- gcc/gimplify.c.jj 2017-03-21 07:56:55.0 +0100
> +++ gcc/gimplify.c2017-03-21 13:37:45.555612652 +0100
> @@ -5098,6 +5098,13 @@ gimplify_modify_expr_rhs (tree *expr_p,
> if (ret != GS_ERROR)
>   ret = GS_OK;
>  
> +   /* If we are going to write RESULT more than once, clear
> +  TREE_READONLY flag, otherwise we might gimplify it
> +  incorrectly.  */
> +   if (DECL_P (result)

Can it ever be that result is sth like decl.component?  At least I
don't see GENERIC restricted in a way that it cannot.  (and generally
assigning to sth TREE_READONLY is fishy at best...)

I see how this fixes the problem at hand (and in a safe way), so the
patch is probably ok, just looking how to avoid this situation in
a more general (and better) way.

> +   && TREE_TYPE (TREE_OPERAND (cond, 1)) != void_type_node
> +   && TREE_TYPE (TREE_OPERAND (cond, 2)) != void_type_node)
> + TREE_READONLY (result) = 0;
> if (TREE_TYPE (TREE_OPERAND (cond, 1)) != void_type_node)
>   TREE_OPERAND (cond, 1)
> = build2 (code, void_type_node, result,
> --- gcc/testsuite/g++.dg/torture/pr80129.C.jj 2017-03-21 13:40:04.179852313 
> +0100
> +++ gcc/testsuite/g++.dg/torture/pr80129.C2017-03-21 13:41:32.121735570 
> +0100
> @@ -0,0 +1,14 @@
> +// PR c++/80129
> +// { dg-do run }
> +// { dg-options "-std=c++11" }
> +
> +struct A { bool a; int b; };
> +
> +int
> +main ()
> +{
> +  bool c = false;
> +  const A x = c ? A {true, 1} : A {false, 0};
> +  if (x.a)
> +__builtin_abort ();
> +}
> 
>   Jakub
> 
> 

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


Re: [PATCH] Fix gimplification of const var initialization from COND_EXPR (PR c++/80129)

2017-03-22 Thread Jakub Jelinek
On Wed, Mar 22, 2017 at 09:20:32AM +0100, Richard Biener wrote:
> > --- gcc/gimplify.c.jj   2017-03-21 07:56:55.0 +0100
> > +++ gcc/gimplify.c  2017-03-21 13:37:45.555612652 +0100
> > @@ -5098,6 +5098,13 @@ gimplify_modify_expr_rhs (tree *expr_p,
> >   if (ret != GS_ERROR)
> > ret = GS_OK;
> >  
> > + /* If we are going to write RESULT more than once, clear
> > +TREE_READONLY flag, otherwise we might gimplify it
> > +incorrectly.  */
> > + if (DECL_P (result)
> 
> Can it ever be that result is sth like decl.component?  At least I
> don't see GENERIC restricted in a way that it cannot.  (and generally
> assigning to sth TREE_READONLY is fishy at best...)

I guess it can, but it can't trigger
if (valid_const_initializer
&& num_nonzero_elements > 1
&& TREE_READONLY (object)
&& VAR_P (object)
&& (flag_merge_constants >= 2 || !TREE_ADDRESSABLE (object)))
which is the problem here.  The problem isn't multiple assignments to
TREE_READONLY object if it isn't promoted to static.

So, if you want, I can replace the DECL_P (result) check with VAR_P
(result), and perhaps change the comment somehow.

> I see how this fixes the problem at hand (and in a safe way), so the
> patch is probably ok, just looking how to avoid this situation in
> a more general (and better) way.

Jakub


Re: [PATCH] Fix gimplification of const var initialization from COND_EXPR (PR c++/80129)

2017-03-22 Thread Richard Biener
On Wed, 22 Mar 2017, Jakub Jelinek wrote:

> On Wed, Mar 22, 2017 at 09:20:32AM +0100, Richard Biener wrote:
> > > --- gcc/gimplify.c.jj 2017-03-21 07:56:55.0 +0100
> > > +++ gcc/gimplify.c2017-03-21 13:37:45.555612652 +0100
> > > @@ -5098,6 +5098,13 @@ gimplify_modify_expr_rhs (tree *expr_p,
> > > if (ret != GS_ERROR)
> > >   ret = GS_OK;
> > >  
> > > +   /* If we are going to write RESULT more than once, clear
> > > +  TREE_READONLY flag, otherwise we might gimplify it
> > > +  incorrectly.  */
> > > +   if (DECL_P (result)
> > 
> > Can it ever be that result is sth like decl.component?  At least I
> > don't see GENERIC restricted in a way that it cannot.  (and generally
> > assigning to sth TREE_READONLY is fishy at best...)
> 
> I guess it can, but it can't trigger
> if (valid_const_initializer
> && num_nonzero_elements > 1
> && TREE_READONLY (object)
> && VAR_P (object)
> && (flag_merge_constants >= 2 || !TREE_ADDRESSABLE (object)))
> which is the problem here.  The problem isn't multiple assignments to
> TREE_READONLY object if it isn't promoted to static.

Ok.

> So, if you want, I can replace the DECL_P (result) check with VAR_P
> (result), and perhaps change the comment somehow.

Yeah, changing it to VAR_P and expanding the comment so it says
it avoids incorrect promotion to readonly-static.  (so it _is_
fishy that we have multiple assignments to TREE_READONLY objects
given that code looks at a single assignment only)

> > I see how this fixes the problem at hand (and in a safe way), so the
> > patch is probably ok, just looking how to avoid this situation in
> > a more general (and better) way.
> 
>   Jakub
> 
> 

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


[PATCH] Support for Ada on aarch64 with -mabi=ilp32

2017-03-22 Thread Andreas Schwab
PR ada/80117
* system-linux-arm-ilp32.ads: New file.
* gcc-interface/Makefile.in (LIBGNAT_TARGET_PAIRS_COMMON): Use it
for aarch64-linux with -mabi=ilp32.

diff --git a/gcc/ada/gcc-interface/Makefile.in 
b/gcc/ada/gcc-interface/Makefile.in
index e5a79f8d97..a4947b5f9e 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -1973,7 +1973,7 @@ endif
 
 # AArch64 Linux
 ifeq ($(strip $(filter-out aarch64% linux%,$(target_cpu) $(target_os))),)
-  LIBGNAT_TARGET_PAIRS = \
+  LIBGNAT_TARGET_PAIRS_COMMON = \
   a-exetim.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 := 32;
+   Memory_Size  : constant := 2 ** Word_Size;
+
+   --  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 :=
+ Bit_Order'Val (Standard'Default_Bit_Order);
+   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 := True;
+   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 Boolean := False;
+   Frontend_Layout   : cons

Backport to GCC6

2017-03-22 Thread Martin Liška
Hello.

I would like to backport following set of revisions to GCC6:

r246345
r246321
r246316
r246276
r246275
r246129
r246120
r246098
r246027
r245998
r245997
r245993
r245992
r245870
r245869
r245868
r245531
r245532
r237353

Survives bootstrap on ppc64le-linux-gnu and x86_64-linux-gnu and the series was 
run against regress
tests.

Ready for the branch?
Thanks,
Martin
>From 273d0ab1c03889b43945cfd62a346caeea8682a7 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Mon, 13 Jun 2016 07:17:16 +
Subject: [PATCH 01/19] Backport r237353

gcc/ChangeLog:

2016-06-13  Martin Liska  

	PR sanitizer/71458
	* toplev.c (process_options): Do not enable -fcheck-pointer-bounds
	w/ -fsanitize=bounds.

gcc/testsuite/ChangeLog:

2016-06-13  Martin Liska  

	* gcc.target/i386/pr71458.c: New test.
---
 gcc/testsuite/gcc.target/i386/pr71458.c | 7 +++
 gcc/toplev.c| 9 +
 2 files changed, 16 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr71458.c

diff --git a/gcc/testsuite/gcc.target/i386/pr71458.c b/gcc/testsuite/gcc.target/i386/pr71458.c
new file mode 100644
index 000..27e7764b5a0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr71458.c
@@ -0,0 +1,7 @@
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=bounds" } */
+/* { dg-error "-fcheck-pointer-bounds is not supported with -fsanitize=bounds" "" { target *-*-* } 0 } */
+
+enum {} a[0];
+void fn1(int);
+void fn2() { fn1(a[-1]); }
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 8979d263426..85e203403dd 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1274,6 +1274,15 @@ process_options (void)
 		"Address Sanitizer");
 	  flag_check_pointer_bounds = 0;
 	}
+
+  if (flag_sanitize & SANITIZE_BOUNDS)
+	{
+	  error_at (UNKNOWN_LOCATION,
+		"-fcheck-pointer-bounds is not supported with "
+		"-fsanitize=bounds");
+	  flag_check_pointer_bounds = 0;
+	}
+
 }
 
   /* One region RA really helps to decrease the code size.  */
-- 
2.12.0

>From 6ed5359ec70aa7bf98a53346882dae955d79d683 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Fri, 17 Feb 2017 14:47:08 +
Subject: [PATCH 02/19] Backport r245532

gcc/ChangeLog:

2017-02-17  Martin Liska  
	PR rtl-optimization/79577
	* params.def (selsched-max-sched-times): Increase minimum to 1.
---
 gcc/params.def | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/params.def b/gcc/params.def
index 6190e984f81..76308cdfcdb 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -634,7 +634,7 @@ DEFPARAM(PARAM_SELSCHED_MAX_LOOKAHEAD,
 DEFPARAM(PARAM_SELSCHED_MAX_SCHED_TIMES,
  "selsched-max-sched-times",
  "Maximum number of times that an insn could be scheduled.",
- 2, 0, 0)
+ 2, 1, 0)
 
 DEFPARAM(PARAM_SELSCHED_INSNS_TO_RENAME,
  "selsched-insns-to-rename",
-- 
2.12.0

>From 41aaa157cb11c8b99d555d501cc4321bfcc22492 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Fri, 17 Feb 2017 14:46:14 +
Subject: [PATCH 03/19] Backport r245531

gcc/ChangeLog:

2017-02-17  Martin Liska  
	PR rtl-optimization/79574
	* gcse.c (want_to_gcse_p): Prevent integer overflow.

gcc/testsuite/ChangeLog:

2017-02-17  Martin Liska  

	PR rtl-optimization/79574
	* gcc.dg/pr79574.c: New test.
---
 gcc/gcse.c |  5 +++--
 gcc/testsuite/gcc.dg/pr79574.c | 10 ++
 2 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr79574.c

diff --git a/gcc/gcse.c b/gcc/gcse.c
index a3a7dc31353..3c300f371bc 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -789,7 +789,7 @@ want_to_gcse_p (rtx x, machine_mode mode, int *max_distance_ptr)
 	/* PRE doesn't implement max_distance restriction.  */
 	{
 	  int cost;
-	  int max_distance;
+	  HOST_WIDE_INT max_distance;
 
 	  gcc_assert (!optimize_function_for_speed_p (cfun)
 		  && optimize_function_for_size_p (cfun));
@@ -797,7 +797,8 @@ want_to_gcse_p (rtx x, machine_mode mode, int *max_distance_ptr)
 
 	  if (cost < COSTS_N_INSNS (GCSE_UNRESTRICTED_COST))
 	{
-	  max_distance = (GCSE_COST_DISTANCE_RATIO * cost) / 10;
+	  max_distance
+		= ((HOST_WIDE_INT)GCSE_COST_DISTANCE_RATIO * cost) / 10;
 	  if (max_distance == 0)
 		return 0;
 
diff --git a/gcc/testsuite/gcc.dg/pr79574.c b/gcc/testsuite/gcc.dg/pr79574.c
new file mode 100644
index 000..1b666e20d21
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr79574.c
@@ -0,0 +1,10 @@
+/* PR rtl-optimization/79574 */
+/* { dg-do compile } */
+/* { dg-options "-Os --param gcse-cost-distance-ratio=2147483647" } */
+
+void a (void)
+{
+  volatile int b;
+  for (;; b)
+;
+}
-- 
2.12.0

>From 4104f8d9ec99905e65e451cfe1a26f89002d0c29 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Fri, 3 Mar 2017 11:53:14 +
Subject: [PATCH 04/19] Backport r245868

gcc/ChangeLog:

2017-03-03  Martin Liska  

	PR rtl-optimization/79574
	* gcse.c (struct gcse_expr): Use HOST_WIDE_INT instead of int.
	(hash_scan_set): Likewise.
	(dump_hash_table): Likewise.
	(hoist

[PATCH, GCC/ARM, stage4] Fix PR80082: LDRD erronously used for 64bit load on ARMv7-R

2017-03-22 Thread Thomas Preudhomme

Hi,

Currently GCC is happy to use LDRD to perform a 64bit load on ARMv7-R,
as shown by the testcase on this patch. However, LDRD is only atomic
when LPAE extensions is available, which they are not for ARMv7-R. This
commit solve the issue by introducing a new feature bit to distinguish
LPAE extensions instead of deducing it from div instruction
availability.

ChangeLog entries are as follow:

*** gcc/ChangeLog ***

PR target/80082
* config/arm/arm-isa.h (isa_bit_lpae): New feature bit.
(ISA_ARMv7ve): Add isa_bit_lpae to the definition.
* config/arm/arm-protos.h (arm_arch7ve): Rename into ...
(arm_arch_lpae): This.
* config/arm/arm.c (arm_arch7ve): Rename into ...
(arm_arch_lpae): This.  Define it in term of isa_bit_lpae.
* config/arm/arm.h (TARGET_HAVE_LPAE): Redefine in term of
arm_arch_lpae.

*** gcc/testsuite/ChangeLog ***

PR target/80082
* gcc.target/arm/atomic_loaddi_10.c: New testcase.
* gcc.target/arm/atomic_loaddi_11.c: Likewise.


Boostrapped for -march=armv7ve and no testsuite regression.

Is this ok for stage4?

Best regards,

Thomas
diff --git a/gcc/config/arm/arm-isa.h b/gcc/config/arm/arm-isa.h
index 6050bca95587f68a3671dd2144cf845b83da3692..7d1e23be0a22ea3d04368a73538d606eef3ae092 100644
--- a/gcc/config/arm/arm-isa.h
+++ b/gcc/config/arm/arm-isa.h
@@ -58,6 +58,7 @@ enum isa_feature
 isa_bit_VFPv3,	/* Vector floating point v3.  */
 isa_bit_VFPv4,	/* Vector floating point v4.  */
 isa_bit_FPv5,	/* Floating point v5.  */
+isa_bit_lpae,	/* ARMv7-A LPAE.  */
 isa_bit_FP_ARMv8,	/* ARMv8 floating-point extension.  */
 isa_bit_neon,	/* Advanced SIMD instructions.  */
 isa_bit_fp16conv,	/* Conversions to/from fp16 (VFPv3 extension).  */
@@ -116,7 +117,7 @@ enum isa_feature
integer SIMD instructions that are in ARMv6T2.  */
 #define ISA_ARMv7	ISA_ARMv6m, isa_bit_thumb2, isa_bit_ARMv7
 #define ISA_ARMv7a	ISA_ARMv7, isa_bit_notm, isa_bit_ARMv6k
-#define ISA_ARMv7ve	ISA_ARMv7a, isa_bit_adiv, isa_bit_tdiv
+#define ISA_ARMv7ve	ISA_ARMv7a, isa_bit_adiv, isa_bit_tdiv, isa_bit_lpae
 #define ISA_ARMv7r	ISA_ARMv7a, isa_bit_tdiv
 #define ISA_ARMv7m	ISA_ARMv7, isa_bit_tdiv
 #define ISA_ARMv7em	ISA_ARMv7m, isa_bit_ARMv7em
diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index 680a1e6236411c0e27888dc4379fe93ef2ed39e2..cf8b43714d8cfc1aa6b648fc7f57d2234fd74927 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -391,8 +391,8 @@ extern int arm_arch6m;
 /* Nonzero if this chip supports the ARM 7 extensions.  */
 extern int arm_arch7;
 
-/* Nonzero if this chip supports the ARM 7ve extensions.  */
-extern int arm_arch7ve;
+/* Nonzero if this chip supports the Large Physical Address Extension.  */
+extern int arm_arch_lpae;
 
 /* Nonzero if instructions not present in the 'M' profile can be used.  */
 extern int arm_arch_notm;
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index e95eda358a54ca0804cfbb9acc0801835c3d7bfb..4dab73d37be8465fe6f504232e3ee83548beef95 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -251,7 +251,7 @@ extern tree arm_fp16_type_node;
   || (arm_arch8 && !arm_arch_notm))
 
 /* Nonzero if this chip supports LPAE.  */
-#define TARGET_HAVE_LPAE (arm_arch7ve)
+#define TARGET_HAVE_LPAE (arm_arch_lpae)
 
 /* Nonzero if this chip supports ldrex{bh} and strex{bh}.  */
 #define TARGET_HAVE_LDREXBH ((arm_arch6k && TARGET_ARM)		\
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 511e16377640894c143e905faace17c72044b5aa..b24143e32e2f10f3b150f7ed0df4fabb3cc8 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -841,8 +841,8 @@ int arm_arch6m = 0;
 /* Nonzero if this chip supports the ARM 7 extensions.  */
 int arm_arch7 = 0;
 
-/* Nonzero if this chip supports the ARM 7ve extensions.  */
-int arm_arch7ve = 0;
+/* Nonzero if this chip supports the Large Physical Address Extension.  */
+int arm_arch_lpae = 0;
 
 /* Nonzero if instructions not present in the 'M' profile can be used.  */
 int arm_arch_notm = 0;
@@ -3365,8 +3365,7 @@ arm_option_override (void)
   arm_arch_crc = bitmap_bit_p (arm_active_target.isa, isa_bit_crc32);
   arm_arch_cmse = bitmap_bit_p (arm_active_target.isa, isa_bit_cmse);
   arm_fp16_inst = bitmap_bit_p (arm_active_target.isa, isa_bit_fp16);
-  arm_arch7ve
-= (arm_arch6k && arm_arch7 && arm_arch_thumb_hwdiv && arm_arch_arm_hwdiv);
+  arm_arch_lpae = bitmap_bit_p (arm_active_target.isa, isa_bit_lpae);
   if (arm_fp16_inst)
 {
   if (arm_fp16_format == ARM_FP16_FORMAT_ALTERNATIVE)
diff --git a/gcc/testsuite/gcc.target/arm/atomic_loaddi_10.c b/gcc/testsuite/gcc.target/arm/atomic_loaddi_10.c
new file mode 100644
index ..ecc3d06d0c9f5966daa3ce7e2d52e09d14e0cbc8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/atomic_loaddi_10.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_arch

Re: Backport to GCC6

2017-03-22 Thread Richard Biener
On Wed, Mar 22, 2017 at 11:15 AM, Martin Liška  wrote:
> Hello.
>
> I would like to backport following set of revisions to GCC6:
>
> r246345
> r246321
> r246316
> r246276
> r246275
> r246129
> r246120
> r246098
> r246027
> r245998
> r245997
> r245993
> r245992
> r245870
> r245869
> r245868
> r245531
> r245532
> r237353
>
> Survives bootstrap on ppc64le-linux-gnu and x86_64-linux-gnu and the series 
> was run against regress
> tests.
>
> Ready for the branch?

Works for me (if they are all regressions you don't even have to ask).

Richard.

> Thanks,
> Martin


Re: [PATCH, GCC/ARM, stage4] Fix PR80082: LDRD erronously used for 64bit load on ARMv7-R

2017-03-22 Thread Richard Earnshaw (lists)
On 22/03/17 10:25, Thomas Preudhomme wrote:
> Hi,
> 
> Currently GCC is happy to use LDRD to perform a 64bit load on ARMv7-R,
> as shown by the testcase on this patch. However, LDRD is only atomic
> when LPAE extensions is available, which they are not for ARMv7-R. This
> commit solve the issue by introducing a new feature bit to distinguish
> LPAE extensions instead of deducing it from div instruction
> availability.
> 
> ChangeLog entries are as follow:
> 
> *** gcc/ChangeLog ***
> 
> PR target/80082
> * config/arm/arm-isa.h (isa_bit_lpae): New feature bit.
> (ISA_ARMv7ve): Add isa_bit_lpae to the definition.
> * config/arm/arm-protos.h (arm_arch7ve): Rename into ...
> (arm_arch_lpae): This.
> * config/arm/arm.c (arm_arch7ve): Rename into ...
> (arm_arch_lpae): This.  Define it in term of isa_bit_lpae.
> * config/arm/arm.h (TARGET_HAVE_LPAE): Redefine in term of
> arm_arch_lpae.
> 
> *** gcc/testsuite/ChangeLog ***
> 
> PR target/80082
> * gcc.target/arm/atomic_loaddi_10.c: New testcase.
> * gcc.target/arm/atomic_loaddi_11.c: Likewise.
> 
> 
> Boostrapped for -march=armv7ve and no testsuite regression.
> 
> Is this ok for stage4?
> 

OK.  Can you do backports for gcc-5 and -6 please.


R.

> Best regards,
> 
> Thomas
> 
> fix_ldrd_64bit_atomic_armv7r.patch
> 
> 
> diff --git a/gcc/config/arm/arm-isa.h b/gcc/config/arm/arm-isa.h
> index 
> 6050bca95587f68a3671dd2144cf845b83da3692..7d1e23be0a22ea3d04368a73538d606eef3ae092
>  100644
> --- a/gcc/config/arm/arm-isa.h
> +++ b/gcc/config/arm/arm-isa.h
> @@ -58,6 +58,7 @@ enum isa_feature
>  isa_bit_VFPv3,   /* Vector floating point v3.  */
>  isa_bit_VFPv4,   /* Vector floating point v4.  */
>  isa_bit_FPv5,/* Floating point v5.  */
> +isa_bit_lpae,/* ARMv7-A LPAE.  */
>  isa_bit_FP_ARMv8,/* ARMv8 floating-point extension.  */
>  isa_bit_neon,/* Advanced SIMD instructions.  */
>  isa_bit_fp16conv,/* Conversions to/from fp16 (VFPv3 extension).  
> */
> @@ -116,7 +117,7 @@ enum isa_feature
> integer SIMD instructions that are in ARMv6T2.  */
>  #define ISA_ARMv7ISA_ARMv6m, isa_bit_thumb2, isa_bit_ARMv7
>  #define ISA_ARMv7a   ISA_ARMv7, isa_bit_notm, isa_bit_ARMv6k
> -#define ISA_ARMv7ve  ISA_ARMv7a, isa_bit_adiv, isa_bit_tdiv
> +#define ISA_ARMv7ve  ISA_ARMv7a, isa_bit_adiv, isa_bit_tdiv, isa_bit_lpae
>  #define ISA_ARMv7r   ISA_ARMv7a, isa_bit_tdiv
>  #define ISA_ARMv7m   ISA_ARMv7, isa_bit_tdiv
>  #define ISA_ARMv7em  ISA_ARMv7m, isa_bit_ARMv7em
> diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
> index 
> 680a1e6236411c0e27888dc4379fe93ef2ed39e2..cf8b43714d8cfc1aa6b648fc7f57d2234fd74927
>  100644
> --- a/gcc/config/arm/arm-protos.h
> +++ b/gcc/config/arm/arm-protos.h
> @@ -391,8 +391,8 @@ extern int arm_arch6m;
>  /* Nonzero if this chip supports the ARM 7 extensions.  */
>  extern int arm_arch7;
>  
> -/* Nonzero if this chip supports the ARM 7ve extensions.  */
> -extern int arm_arch7ve;
> +/* Nonzero if this chip supports the Large Physical Address Extension.  */
> +extern int arm_arch_lpae;
>  
>  /* Nonzero if instructions not present in the 'M' profile can be used.  */
>  extern int arm_arch_notm;
> diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
> index 
> e95eda358a54ca0804cfbb9acc0801835c3d7bfb..4dab73d37be8465fe6f504232e3ee83548beef95
>  100644
> --- a/gcc/config/arm/arm.h
> +++ b/gcc/config/arm/arm.h
> @@ -251,7 +251,7 @@ extern tree arm_fp16_type_node;
> || (arm_arch8 && !arm_arch_notm))
>  
>  /* Nonzero if this chip supports LPAE.  */
> -#define TARGET_HAVE_LPAE (arm_arch7ve)
> +#define TARGET_HAVE_LPAE (arm_arch_lpae)
>  
>  /* Nonzero if this chip supports ldrex{bh} and strex{bh}.  */
>  #define TARGET_HAVE_LDREXBH ((arm_arch6k && TARGET_ARM)  \
> diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
> index 
> 511e16377640894c143e905faace17c72044b5aa..b24143e32e2f10f3b150f7ed0df4fabb3cc8
>  100644
> --- a/gcc/config/arm/arm.c
> +++ b/gcc/config/arm/arm.c
> @@ -841,8 +841,8 @@ int arm_arch6m = 0;
>  /* Nonzero if this chip supports the ARM 7 extensions.  */
>  int arm_arch7 = 0;
>  
> -/* Nonzero if this chip supports the ARM 7ve extensions.  */
> -int arm_arch7ve = 0;
> +/* Nonzero if this chip supports the Large Physical Address Extension.  */
> +int arm_arch_lpae = 0;
>  
>  /* Nonzero if instructions not present in the 'M' profile can be used.  */
>  int arm_arch_notm = 0;
> @@ -3365,8 +3365,7 @@ arm_option_override (void)
>arm_arch_crc = bitmap_bit_p (arm_active_target.isa, isa_bit_crc32);
>arm_arch_cmse = bitmap_bit_p (arm_active_target.isa, isa_bit_cmse);
>arm_fp16_inst = bitmap_bit_p (arm_active_target.isa, isa_bit_fp16);
> -  arm_arch7ve
> -= (arm_arch6k && arm_arch7 && arm_arch_thumb_hwdiv && 
> arm_arch_arm_hwdiv);
> +  arm_arch_lpae = bitmap_bit_p (arm_active_target.isa, isa_bit_lpae);
>if (arm_fp16_inst)
>  {
>  

[PATCH, GCC/ARM, Stage 1] Rename FPSCR builtins to correct names

2017-03-22 Thread Prakhar Bahuguna
The GCC documentation in section 6.60.8 ARM Floating Point Status and Control
Intrinsics states that the FPSCR register can be read and written to using the
intrinsics __builtin_arm_get_fpscr and __builtin_arm_set_fpscr. However, these
are misnamed within GCC itself and these intrinsic names are not recognised.
This patch corrects the intrinsic names to match the documentation, and adds
tests to verify these intrinsics generate the correct instructions.

Testing done: Ran regression tests on arm-none-eabi for Cortex-M4.

2017-03-09  Prakhar Bahuguna  

gcc/ChangeLog:

* gcc/config/arm/arm-builtins.c (arm_init_builtins): Rename
  __builtin_arm_ldfscr to __builtin_arm_get_fpscr, and rename
  __builtin_arm_stfscr to __builtin_arm_set_fpscr.
* gcc/testsuite/gcc.target/arm/fpscr.c: New file.

Okay for stage 1?

--

Prakhar Bahuguna
>From 8359732084b5b5585d14b7fbdf70d3cfa4c6dda2 Mon Sep 17 00:00:00 2001
From: Prakhar Bahuguna 
Date: Wed, 8 Mar 2017 16:29:09 +
Subject: [PATCH] Rename FPSCR builtins to correct names

---
 gcc/config/arm/arm-builtins.c|  4 ++--
 gcc/testsuite/gcc.target/arm/fpscr.c | 16 
 2 files changed, 18 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/arm/fpscr.c

diff --git a/gcc/config/arm/arm-builtins.c b/gcc/config/arm/arm-builtins.c
index ca622519b7d..aef05d0127f 100644
--- a/gcc/config/arm/arm-builtins.c
+++ b/gcc/config/arm/arm-builtins.c
@@ -1860,10 +1860,10 @@ arm_init_builtins (void)
= build_function_type_list (unsigned_type_node, NULL);
 
   arm_builtin_decls[ARM_BUILTIN_GET_FPSCR]
-   = add_builtin_function ("__builtin_arm_ldfscr", ftype_get_fpscr,
+   = add_builtin_function ("__builtin_arm_get_fpscr", ftype_get_fpscr,
ARM_BUILTIN_GET_FPSCR, BUILT_IN_MD, NULL, 
NULL_TREE);
   arm_builtin_decls[ARM_BUILTIN_SET_FPSCR]
-   = add_builtin_function ("__builtin_arm_stfscr", ftype_set_fpscr,
+   = add_builtin_function ("__builtin_arm_set_fpscr", ftype_set_fpscr,
ARM_BUILTIN_SET_FPSCR, BUILT_IN_MD, NULL, 
NULL_TREE);
 }
 
diff --git a/gcc/testsuite/gcc.target/arm/fpscr.c 
b/gcc/testsuite/gcc.target/arm/fpscr.c
new file mode 100644
index 000..7b4d71d72d8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/fpscr.c
@@ -0,0 +1,16 @@
+/* Test the fpscr builtins.  */
+
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_fp_ok } */
+/* { dg-skip-if "need fp instructions" { *-*-* } { "-mfloat-abi=soft" } { "" } 
} */
+/* { dg-add-options arm_fp } */
+
+void
+test_fpscr ()
+{
+  volatile unsigned int status = __builtin_arm_get_fpscr ();
+  __builtin_arm_set_fpscr (status);
+}
+
+/* { dg-final { scan-assembler "mrc\tp10, 7, r\[0-9\]+, cr1, cr0, 0" } } */
+/* { dg-final { scan-assembler "mcr\tp10, 7, r\[0-9\]+, cr1, cr0, 0" } } */
-- 
2.11.0



Re: [build,darwin] Fix toplevel configure test for LTO on darwin

2017-03-22 Thread FX
*ping*


When LTO was introduced, on macOS it needed darwin9 to work. Over time, most 
tests for “*-apple-darwin9” in the toplevel configure were changed to also 
include later darwin versions: *-darwin[[912]]*  However, the check for LTO was 
not updated. As far as I know, this is merely an oversight: LTO works fine on 
Darwin, and most vendors (homebrew, macports, etc.) have been shipping with 
--enable-lto for years.

The attached patch makes it build LTO by default on darwin >= 9. I realize it’s 
late but I hope the very restricted nature (and ultra-low risk) of the patch 
make it a candidate for inclusion in trunk nonetheless.

Bootstrapped and regtested on x86_64-apple-darwin16. OK to commit?

FX




lto_darwin.ChangeLog
Description: Binary data


lto_darwin.diff
Description: Binary data


Backport to GCC5

2017-03-22 Thread Martin Liška
Hello.

This is very same series as the one for GCC6. Only exception is toplev.c, which 
is
squashed just to a single patch. And a multi-versioning patch is omitted.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

I'm going to install the series.
Martin
>From 62b6cbefcf9eba678d77aa6e979b3f0c6a3f6b79 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Fri, 17 Feb 2017 14:47:08 +
Subject: [PATCH 01/15] Backport r245532

gcc/ChangeLog:

2017-02-17  Martin Liska  

	PR rtl-optimization/79577
	* params.def (selsched-max-sched-times): Increase minimum to 1.
---
 gcc/params.def | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/params.def b/gcc/params.def
index 48b39a25041..33d637675ab 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -656,7 +656,7 @@ DEFPARAM(PARAM_SELSCHED_MAX_LOOKAHEAD,
 DEFPARAM(PARAM_SELSCHED_MAX_SCHED_TIMES,
  "selsched-max-sched-times",
  "Maximum number of times that an insn could be scheduled",
- 2, 0, 0)
+ 2, 1, 0)
 
 DEFPARAM(PARAM_SELSCHED_INSNS_TO_RENAME,
  "selsched-insns-to-rename",
-- 
2.12.0

>From 3005209ed0529e7cefed1fdb27c76e9c6c001a9d Mon Sep 17 00:00:00 2001
From: marxin 
Date: Fri, 17 Feb 2017 14:46:14 +
Subject: [PATCH 02/15] Backport r245531

gcc/ChangeLog:

2017-02-17  Martin Liska  

	PR rtl-optimization/79574
	* gcse.c (want_to_gcse_p): Prevent integer overflow.

gcc/testsuite/ChangeLog:

2017-02-17  Martin Liska  

	PR rtl-optimization/79574
	* gcc.dg/pr79574.c: New test.
---
 gcc/gcse.c |  5 +++--
 gcc/testsuite/gcc.dg/pr79574.c | 10 ++
 2 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr79574.c

diff --git a/gcc/gcse.c b/gcc/gcse.c
index 0f6d456ab39..c6bea33c6d2 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -824,7 +824,7 @@ want_to_gcse_p (rtx x, int *max_distance_ptr)
 	/* PRE doesn't implement max_distance restriction.  */
 	{
 	  int cost;
-	  int max_distance;
+	  HOST_WIDE_INT max_distance;
 
 	  gcc_assert (!optimize_function_for_speed_p (cfun)
 		  && optimize_function_for_size_p (cfun));
@@ -832,7 +832,8 @@ want_to_gcse_p (rtx x, int *max_distance_ptr)
 
 	  if (cost < COSTS_N_INSNS (GCSE_UNRESTRICTED_COST))
 	{
-	  max_distance = (GCSE_COST_DISTANCE_RATIO * cost) / 10;
+	  max_distance
+		= ((HOST_WIDE_INT)GCSE_COST_DISTANCE_RATIO * cost) / 10;
 	  if (max_distance == 0)
 		return 0;
 
diff --git a/gcc/testsuite/gcc.dg/pr79574.c b/gcc/testsuite/gcc.dg/pr79574.c
new file mode 100644
index 000..1b666e20d21
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr79574.c
@@ -0,0 +1,10 @@
+/* PR rtl-optimization/79574 */
+/* { dg-do compile } */
+/* { dg-options "-Os --param gcse-cost-distance-ratio=2147483647" } */
+
+void a (void)
+{
+  volatile int b;
+  for (;; b)
+;
+}
-- 
2.12.0

>From 895302c15bcfefca67a3c9f6a9802112ca1b2b12 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Fri, 3 Mar 2017 11:53:14 +
Subject: [PATCH 03/15] Backport r245868

gcc/ChangeLog:

2017-03-03  Martin Liska  

	PR rtl-optimization/79574
	* gcse.c (struct gcse_expr): Use HOST_WIDE_INT instead of int.
	(hash_scan_set): Likewise.
	(dump_hash_table): Likewise.
	(hoist_code): Likewise.

gcc/testsuite/ChangeLog:

2017-03-03  Martin Liska  

	PR rtl-optimization/79574
	* gcc.dg/pr79574-2.c: New test.
---
 gcc/gcse.c   | 29 +
 gcc/testsuite/gcc.dg/pr79574-2.c | 33 +
 2 files changed, 50 insertions(+), 12 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr79574-2.c

diff --git a/gcc/gcse.c b/gcc/gcse.c
index c6bea33c6d2..394620d64f6 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -311,7 +311,7 @@ struct gcse_expr
  to keep register pressure under control.
  A value of "0" removes restrictions on how far the expression can
  travel.  */
-  int max_distance;
+  HOST_WIDE_INT max_distance;
 };
 
 /* Occurrence of an expression.
@@ -486,12 +486,12 @@ static void hash_scan_insn (rtx_insn *, struct gcse_hash_table_d *);
 static void hash_scan_set (rtx, rtx_insn *, struct gcse_hash_table_d *);
 static void hash_scan_clobber (rtx, rtx_insn *, struct gcse_hash_table_d *);
 static void hash_scan_call (rtx, rtx_insn *, struct gcse_hash_table_d *);
-static int want_to_gcse_p (rtx, int *);
+static int want_to_gcse_p (rtx, HOST_WIDE_INT *);
 static int oprs_unchanged_p (const_rtx, const rtx_insn *, int);
 static int oprs_anticipatable_p (const_rtx, const rtx_insn *);
 static int oprs_available_p (const_rtx, const rtx_insn *);
 static void insert_expr_in_table (rtx, machine_mode, rtx_insn *, int, int,
-  int, struct gcse_hash_table_d *);
+  HOST_WIDE_INT, struct gcse_hash_table_d *);
 static unsigned int hash_expr (const_rtx, machine_mode, int *, int);
 static void record_last_reg_set_info (rtx, int);
 static void record_last_mem_set_info (rtx_insn *);
@@ -521,8 +521,10 @@ static void alloc_code_hoist_mem (int, int);
 static void free

[PATCH] Fix PR80032 fix fallout

2017-03-22 Thread Richard Biener

The following reportedly fixes a LLVM miscompile.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2017-03-22  Richard Biener  

PR tree-optimization/80032
* gimplify.c (gimple_push_cleanup): Forced unconditional
cleanups still have to go to the conditional_cleanups
sequence.

Index: gcc/gimplify.c
===
--- gcc/gimplify.c  (revision 246364)
+++ gcc/gimplify.c  (working copy)
@@ -6304,7 +6304,7 @@ gimple_push_cleanup (tree var, tree clea
   if (seen_error ())
 return;
 
-  if (gimple_conditional_context () && ! force_uncond)
+  if (gimple_conditional_context ())
 {
   /* If we're in a conditional context, this is more complex.  We only
 want to run the cleanup if we actually ran the initialization that
@@ -6326,22 +6326,31 @@ gimple_push_cleanup (tree var, tree clea
   }
   val
   */
-  tree flag = create_tmp_var (boolean_type_node, "cleanup");
-  gassign *ffalse = gimple_build_assign (flag, boolean_false_node);
-  gassign *ftrue = gimple_build_assign (flag, boolean_true_node);
-
-  cleanup = build3 (COND_EXPR, void_type_node, flag, cleanup, NULL);
-  gimplify_stmt (&cleanup, &cleanup_stmts);
-  wce = gimple_build_wce (cleanup_stmts);
-
-  gimplify_seq_add_stmt (&gimplify_ctxp->conditional_cleanups, ffalse);
-  gimplify_seq_add_stmt (&gimplify_ctxp->conditional_cleanups, wce);
-  gimplify_seq_add_stmt (pre_p, ftrue);
-
-  /* Because of this manipulation, and the EH edges that jump
-threading cannot redirect, the temporary (VAR) will appear
-to be used uninitialized.  Don't warn.  */
-  TREE_NO_WARNING (var) = 1;
+  if (force_uncond)
+   {
+ gimplify_stmt (&cleanup, &cleanup_stmts);
+ wce = gimple_build_wce (cleanup_stmts);
+ gimplify_seq_add_stmt (&gimplify_ctxp->conditional_cleanups, wce);
+   }
+  else
+   {
+ tree flag = create_tmp_var (boolean_type_node, "cleanup");
+ gassign *ffalse = gimple_build_assign (flag, boolean_false_node);
+ gassign *ftrue = gimple_build_assign (flag, boolean_true_node);
+
+ cleanup = build3 (COND_EXPR, void_type_node, flag, cleanup, NULL);
+ gimplify_stmt (&cleanup, &cleanup_stmts);
+ wce = gimple_build_wce (cleanup_stmts);
+
+ gimplify_seq_add_stmt (&gimplify_ctxp->conditional_cleanups, ffalse);
+ gimplify_seq_add_stmt (&gimplify_ctxp->conditional_cleanups, wce);
+ gimplify_seq_add_stmt (pre_p, ftrue);
+
+ /* Because of this manipulation, and the EH edges that jump
+threading cannot redirect, the temporary (VAR) will appear
+to be used uninitialized.  Don't warn.  */
+ TREE_NO_WARNING (var) = 1;
+   }
 }
   else
 {


[PATCH] internal/syscall/unix: fix syscalls for m68k

2017-03-22 Thread Andreas Schwab
---
 libgo/go/internal/syscall/unix/getrandom_linux_m68k.go | 9 +
 1 file changed, 9 insertions(+)
 create mode 100644 libgo/go/internal/syscall/unix/getrandom_linux_m68k.go

diff --git a/libgo/go/internal/syscall/unix/getrandom_linux_m68k.go 
b/libgo/go/internal/syscall/unix/getrandom_linux_m68k.go
new file mode 100644
index 00..5559d30d33
--- /dev/null
+++ b/libgo/go/internal/syscall/unix/getrandom_linux_m68k.go
@@ -0,0 +1,9 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package unix
+
+// Linux getrandom system call number.
+// See GetRandom in getrandom_linux.go.
+const randomTrap uintptr = 352
-- 
2.12.1


-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Re: [PATCH] Fix gimplification of const var initialization from COND_EXPR (PR c++/80129)

2017-03-22 Thread Jakub Jelinek
On Wed, Mar 22, 2017 at 09:59:09AM +0100, Richard Biener wrote:
> Yeah, changing it to VAR_P and expanding the comment so it says
> it avoids incorrect promotion to readonly-static.  (so it _is_
> fishy that we have multiple assignments to TREE_READONLY objects
> given that code looks at a single assignment only)

So like this?

2017-03-22  Jakub Jelinek  

PR c++/80129
* gimplify.c (gimplify_modify_expr_rhs) : Clear
TREE_READONLY on result if writing it more than once.

* g++.dg/torture/pr80129.C: New test.

--- gcc/gimplify.c.jj   2017-03-21 07:56:55.0 +0100
+++ gcc/gimplify.c  2017-03-21 13:37:45.555612652 +0100
@@ -5098,6 +5098,14 @@ gimplify_modify_expr_rhs (tree *expr_p,
  if (ret != GS_ERROR)
ret = GS_OK;
 
+ /* If we are going to write RESULT more than once, clear
+TREE_READONLY flag, otherwise we might incorrectly promote
+the variable to static const and initialize it at compile
+time in one of the branches.  */
+ if (VAR_P (result)
+ && TREE_TYPE (TREE_OPERAND (cond, 1)) != void_type_node
+ && TREE_TYPE (TREE_OPERAND (cond, 2)) != void_type_node)
+   TREE_READONLY (result) = 0;
  if (TREE_TYPE (TREE_OPERAND (cond, 1)) != void_type_node)
TREE_OPERAND (cond, 1)
  = build2 (code, void_type_node, result,
--- gcc/testsuite/g++.dg/torture/pr80129.C.jj   2017-03-21 13:40:04.179852313 
+0100
+++ gcc/testsuite/g++.dg/torture/pr80129.C  2017-03-21 13:41:32.121735570 
+0100
@@ -0,0 +1,14 @@
+// PR c++/80129
+// { dg-do run }
+// { dg-options "-std=c++11" }
+
+struct A { bool a; int b; };
+
+int
+main ()
+{
+  bool c = false;
+  const A x = c ? A {true, 1} : A {false, 0};
+  if (x.a)
+__builtin_abort ();
+}

Jakub


Re: [PATCH] Fix gimplification of const var initialization from COND_EXPR (PR c++/80129)

2017-03-22 Thread Richard Biener
On Wed, 22 Mar 2017, Jakub Jelinek wrote:

> On Wed, Mar 22, 2017 at 09:59:09AM +0100, Richard Biener wrote:
> > Yeah, changing it to VAR_P and expanding the comment so it says
> > it avoids incorrect promotion to readonly-static.  (so it _is_
> > fishy that we have multiple assignments to TREE_READONLY objects
> > given that code looks at a single assignment only)
> 
> So like this?

Yes.

Thanks,
Richard.

> 2017-03-22  Jakub Jelinek  
> 
>   PR c++/80129
>   * gimplify.c (gimplify_modify_expr_rhs) : Clear
>   TREE_READONLY on result if writing it more than once.
> 
>   * g++.dg/torture/pr80129.C: New test.
> 
> --- gcc/gimplify.c.jj 2017-03-21 07:56:55.0 +0100
> +++ gcc/gimplify.c2017-03-21 13:37:45.555612652 +0100
> @@ -5098,6 +5098,14 @@ gimplify_modify_expr_rhs (tree *expr_p,
> if (ret != GS_ERROR)
>   ret = GS_OK;
>  
> +   /* If we are going to write RESULT more than once, clear
> +  TREE_READONLY flag, otherwise we might incorrectly promote
> +  the variable to static const and initialize it at compile
> +  time in one of the branches.  */
> +   if (VAR_P (result)
> +   && TREE_TYPE (TREE_OPERAND (cond, 1)) != void_type_node
> +   && TREE_TYPE (TREE_OPERAND (cond, 2)) != void_type_node)
> + TREE_READONLY (result) = 0;
> if (TREE_TYPE (TREE_OPERAND (cond, 1)) != void_type_node)
>   TREE_OPERAND (cond, 1)
> = build2 (code, void_type_node, result,
> --- gcc/testsuite/g++.dg/torture/pr80129.C.jj 2017-03-21 13:40:04.179852313 
> +0100
> +++ gcc/testsuite/g++.dg/torture/pr80129.C2017-03-21 13:41:32.121735570 
> +0100
> @@ -0,0 +1,14 @@
> +// PR c++/80129
> +// { dg-do run }
> +// { dg-options "-std=c++11" }
> +
> +struct A { bool a; int b; };
> +
> +int
> +main ()
> +{
> +  bool c = false;
> +  const A x = c ? A {true, 1} : A {false, 0};
> +  if (x.a)
> +__builtin_abort ();
> +}
> 
>   Jakub
> 
> 

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


[PATCH] Fix PR80029

2017-03-22 Thread Cesar Philippidis
In addition to resolving the memory leak involving OpenACC delare
clauses, this patch also corrects an ICE involving VLA variables as data
clause arguments used in acc declare constructs. More details can be
found here .

Is this OK for trunk?

Cesar
2017-03-22  Cesar Philippidis  

	PR c++/80029

	gcc/
	* gimplify.c (is_oacc_declared): New function.
	(oacc_default_clause): Use it to set default flags for acc declared
	variables inside parallel regions.
	(gimplify_scan_omp_clauses): Strip firstprivate pointers for acc
	declared variables.
	(gimplify_oacc_declare): Gimplify the declare clauses.  Add the
	declare attribute to any decl as necessary.

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/declare-vla.c: New test.


diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index fbf136f..26d35d1 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6787,6 +6787,16 @@ device_resident_p (tree decl)
   return false;
 }
 
+/* Return true if DECL has an ACC DECLARE attribute.  */
+
+static bool
+is_oacc_declared (tree decl)
+{
+  tree t = TREE_CODE (decl) == MEM_REF ? TREE_OPERAND (decl, 0) : decl;
+  tree declared = lookup_attribute ("oacc declare target", DECL_ATTRIBUTES (t));
+  return declared != NULL_TREE;
+}
+
 /* Determine outer default flags for DECL mentioned in an OMP region
but not declared in an enclosing clause.
 
@@ -6887,6 +6897,7 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
 {
   const char *rkind;
   bool on_device = false;
+  bool declared = is_oacc_declared (decl);
   tree type = TREE_TYPE (decl);
 
   if (lang_hooks.decls.omp_privatize_by_reference (decl))
@@ -6917,7 +6928,7 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
 
 case ORT_ACC_PARALLEL:
   {
-	if (on_device || AGGREGATE_TYPE_P (type))
+	if (on_device || AGGREGATE_TYPE_P (type) || declared)
 	  /* Aggregates default to 'present_or_copy'.  */
 	  flags |= GOVD_MAP;
 	else
@@ -7346,6 +7357,7 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
   case OMP_TARGET_DATA:
   case OMP_TARGET_ENTER_DATA:
   case OMP_TARGET_EXIT_DATA:
+  case OACC_DECLARE:
   case OACC_HOST_DATA:
 	ctx->target_firstprivatize_array_bases = true;
   default:
@@ -9231,18 +9243,26 @@ gimplify_oacc_declare (tree *expr_p, gimple_seq *pre_p)
 {
   tree expr = *expr_p;
   gomp_target *stmt;
-  tree clauses, t;
+  tree clauses, t, decl;
 
   clauses = OACC_DECLARE_CLAUSES (expr);
 
   gimplify_scan_omp_clauses (&clauses, pre_p, ORT_TARGET_DATA, OACC_DECLARE);
+  gimplify_adjust_omp_clauses (pre_p, NULL, &clauses, OACC_DECLARE);
 
   for (t = clauses; t; t = OMP_CLAUSE_CHAIN (t))
 {
-  tree decl = OMP_CLAUSE_DECL (t);
+  decl = OMP_CLAUSE_DECL (t);
 
   if (TREE_CODE (decl) == MEM_REF)
-	continue;
+	decl = TREE_OPERAND (decl, 0);
+
+  if (VAR_P (decl) && !is_oacc_declared (decl))
+	{
+	  tree attr = get_identifier ("oacc declare target");
+	  DECL_ATTRIBUTES (decl) = tree_cons (attr, NULL_TREE,
+	  DECL_ATTRIBUTES (decl));
+	}
 
   if (VAR_P (decl)
 	  && !is_global_var (decl)
@@ -9258,7 +9278,8 @@ gimplify_oacc_declare (tree *expr_p, gimple_seq *pre_p)
 	}
 	}
 
-  omp_add_variable (gimplify_omp_ctxp, decl, GOVD_SEEN);
+  if (gimplify_omp_ctxp)
+	omp_add_variable (gimplify_omp_ctxp, decl, GOVD_SEEN);
 }
 
   stmt = gimple_build_omp_target (NULL, GF_OMP_TARGET_KIND_OACC_DECLARE,
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-vla.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-vla.c
new file mode 100644
index 000..3ea148e
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-vla.c
@@ -0,0 +1,25 @@
+/* Verify that acc declare accept VLA variables.  */
+
+#include 
+
+int
+main ()
+{
+  int N = 1000;
+  int i, A[N];
+#pragma acc declare copy(A)
+
+  for (i = 0; i < N; i++)
+A[i] = -i;
+
+#pragma acc kernels
+  for (i = 0; i < N; i++)
+A[i] = i;
+
+#pragma acc update host(A)
+
+  for (i = 0; i < N; i++)
+assert (A[i] == i);
+
+  return 0;
+}


Re: [PATCH] Fix -fsanitize=thread with -fnon-call-exceptions (PR sanitizer/80110)

2017-03-22 Thread Richard Biener
On Wed, 22 Mar 2017, Jakub Jelinek wrote:

> On Tue, Mar 21, 2017 at 09:26:49AM +0100, Richard Biener wrote:
> > On Tue, 21 Mar 2017, Jakub Jelinek wrote:
> > 
> > > On Tue, Mar 21, 2017 at 09:12:51AM +0100, Richard Biener wrote:
> > > > > libtsan atomics aren't throwing, so if we transform atomics which
> > > > > are throwing with -fnon-call-exceptions, we need to clean up EH stuff.
> > > > > 
> > > > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> > > > 
> > > > Huh, but this means with TSAN we create wrong-code with 
> > > > -fnon-call-exceptions and programs will crash instead of properly
> > > > catching things like null-pointer accesses?
> > > 
> > > True.  I think it is only about atomics, normal loads/stores are done
> > > inline with extra calls before/after that just tell the library about
> > > those loads/stores (though not sure what the library code will do with
> > > invalid or NULL pointers, if it won't crash on them).
> > > The question is what we could do about it and if it is worth bothering,
> > > I guess we'd need to build tsan_interface_atomics.cc with
> > > -fnon-call-exceptions and the question would be if it doesn't slow it
> > > down for the common case where -fnon-call-exceptions isn't used.
> > > Another option would be to add another set of __tsan_atomic* entrypoints
> > > for -fnon-call-exceptions.
> > > 
> > > > We should at least document this or reject sanitize=thread with
> > > > -fnon-call-exceptions.
> > > 
> > > Rejecting would mean that even code that doesn't use the atomics or 
> > > doesn't
> > > use atomics on invalid pointers would not be allowed.
> > 
> > Indeed.  So maybe just document it then.  I suppose sanitizing in
> > general has the issue that its events are not properly raising
> > exceptions (of whatever kind), so documenting that programs relying
> > on async EH to be reliably delivered may not work as expected with
> > sanitization would be good.
> 
> So like this in addition to the posted patch?

Looks good.

Thanks,
Richard.

> 2017-03-22  Jakub Jelinek  
> 
>   PR sanitizer/80110
>   * doc/invoke.texi (-fsanitize=thread): Document that with
>   -fnon-call-exceptions atomics are not able to throw
>   exceptions.
> 
> --- gcc/doc/invoke.texi.jj2017-03-19 11:57:08.0 +0100
> +++ gcc/doc/invoke.texi   2017-03-22 14:22:40.737505684 +0100
> @@ -10761,6 +10761,10 @@ supported options.
>  The option can't be combined with @option{-fsanitize=address},
>  @option{-fsanitize=leak} and/or @option{-fcheck-pointer-bounds}.
>  
> +Note that sanitized atomic builtins cannot throw exceptions when
> +operating on invalid memory addresses with non-call exceptions
> +(@option{-fnon-call-exceptions}).
> +
>  @item -fsanitize=leak
>  @opindex fsanitize=leak
>  Enable LeakSanitizer, a memory leak detector.
> 
> 
>   Jakub
> 
> 

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


Re: [PATCH] Fix PR80029

2017-03-22 Thread Cesar Philippidis
On 03/22/2017 06:42 AM, Jakub Jelinek wrote:

>> 2017-03-22  Cesar Philippidis  
>>
>>  PR c++/80029
>>
>>  gcc/
>>  * gimplify.c (is_oacc_declared): New function.
>>  (oacc_default_clause): Use it to set default flags for acc declared
>>  variables inside parallel regions.
>>  (gimplify_scan_omp_clauses): Strip firstprivate pointers for acc
>>  declared variables.
>>  (gimplify_oacc_declare): Gimplify the declare clauses.  Add the
>>  declare attribute to any decl as necessary.
>>
>>  libgomp/
>>  * testsuite/libgomp.oacc-c-c++-common/declare-vla.c: New test.
> 
> Ok if testing passed.

Yes it did. By the way, is there a way to automate valgrind testing, or
is that something that require manual inspection?

Cesar



Re: [PATCH] Fix PR80029

2017-03-22 Thread Jakub Jelinek
On Wed, Mar 22, 2017 at 06:40:03AM -0700, Cesar Philippidis wrote:
> In addition to resolving the memory leak involving OpenACC delare
> clauses, this patch also corrects an ICE involving VLA variables as data
> clause arguments used in acc declare constructs. More details can be
> found here .
> 
> Is this OK for trunk?
> 
> Cesar

> 2017-03-22  Cesar Philippidis  
> 
>   PR c++/80029
> 
>   gcc/
>   * gimplify.c (is_oacc_declared): New function.
>   (oacc_default_clause): Use it to set default flags for acc declared
>   variables inside parallel regions.
>   (gimplify_scan_omp_clauses): Strip firstprivate pointers for acc
>   declared variables.
>   (gimplify_oacc_declare): Gimplify the declare clauses.  Add the
>   declare attribute to any decl as necessary.
> 
>   libgomp/
>   * testsuite/libgomp.oacc-c-c++-common/declare-vla.c: New test.

Ok if testing passed.

Jakub


Re: [PATCH] Fix PR80029

2017-03-22 Thread Jakub Jelinek
On Wed, Mar 22, 2017 at 06:48:09AM -0700, Cesar Philippidis wrote:
> On 03/22/2017 06:42 AM, Jakub Jelinek wrote:
> 
> >> 2017-03-22  Cesar Philippidis  
> >>
> >>PR c++/80029
> >>
> >>gcc/
> >>* gimplify.c (is_oacc_declared): New function.
> >>(oacc_default_clause): Use it to set default flags for acc declared
> >>variables inside parallel regions.
> >>(gimplify_scan_omp_clauses): Strip firstprivate pointers for acc
> >>declared variables.
> >>(gimplify_oacc_declare): Gimplify the declare clauses.  Add the
> >>declare attribute to any decl as necessary.
> >>
> >>libgomp/
> >>* testsuite/libgomp.oacc-c-c++-common/declare-vla.c: New test.
> > 
> > Ok if testing passed.
> 
> Yes it did. By the way, is there a way to automate valgrind testing, or
> is that something that require manual inspection?

--enable-checking=valgrind if you have enough CPU time to burn (like a
weekend for a single bootstrap+regtest).

Jakub


Re: [PATCH] Fix -fsanitize=thread with -fnon-call-exceptions (PR sanitizer/80110)

2017-03-22 Thread Jakub Jelinek
On Tue, Mar 21, 2017 at 09:26:49AM +0100, Richard Biener wrote:
> On Tue, 21 Mar 2017, Jakub Jelinek wrote:
> 
> > On Tue, Mar 21, 2017 at 09:12:51AM +0100, Richard Biener wrote:
> > > > libtsan atomics aren't throwing, so if we transform atomics which
> > > > are throwing with -fnon-call-exceptions, we need to clean up EH stuff.
> > > > 
> > > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> > > 
> > > Huh, but this means with TSAN we create wrong-code with 
> > > -fnon-call-exceptions and programs will crash instead of properly
> > > catching things like null-pointer accesses?
> > 
> > True.  I think it is only about atomics, normal loads/stores are done
> > inline with extra calls before/after that just tell the library about
> > those loads/stores (though not sure what the library code will do with
> > invalid or NULL pointers, if it won't crash on them).
> > The question is what we could do about it and if it is worth bothering,
> > I guess we'd need to build tsan_interface_atomics.cc with
> > -fnon-call-exceptions and the question would be if it doesn't slow it
> > down for the common case where -fnon-call-exceptions isn't used.
> > Another option would be to add another set of __tsan_atomic* entrypoints
> > for -fnon-call-exceptions.
> > 
> > > We should at least document this or reject sanitize=thread with
> > > -fnon-call-exceptions.
> > 
> > Rejecting would mean that even code that doesn't use the atomics or doesn't
> > use atomics on invalid pointers would not be allowed.
> 
> Indeed.  So maybe just document it then.  I suppose sanitizing in
> general has the issue that its events are not properly raising
> exceptions (of whatever kind), so documenting that programs relying
> on async EH to be reliably delivered may not work as expected with
> sanitization would be good.

So like this in addition to the posted patch?

2017-03-22  Jakub Jelinek  

PR sanitizer/80110
* doc/invoke.texi (-fsanitize=thread): Document that with
-fnon-call-exceptions atomics are not able to throw
exceptions.

--- gcc/doc/invoke.texi.jj  2017-03-19 11:57:08.0 +0100
+++ gcc/doc/invoke.texi 2017-03-22 14:22:40.737505684 +0100
@@ -10761,6 +10761,10 @@ supported options.
 The option can't be combined with @option{-fsanitize=address},
 @option{-fsanitize=leak} and/or @option{-fcheck-pointer-bounds}.
 
+Note that sanitized atomic builtins cannot throw exceptions when
+operating on invalid memory addresses with non-call exceptions
+(@option{-fnon-call-exceptions}).
+
 @item -fsanitize=leak
 @opindex fsanitize=leak
 Enable LeakSanitizer, a memory leak detector.


Jakub


Go patch committed: check backend alignment for memequalNN functions

2017-03-22 Thread Ian Lance Taylor
The Go frontend was assuming the usual required alignment for the
memequalNN functions (16 bits for int16, 32 for int32, etc.). However,
on m68k the required alignment of int32 is only 16 bits. Assuming the
memequalNN alignment caused the compiler to incorrectly decide that
int32 required a specially generated function rather than calling
memequal32. This then crashed if the type descriptor were generated
after type-specific functions had been written.

Bootstrapped and ran Go tests on x86_64-pc-linux-gnu.  Committed to mainline.

This fixes GCC PR 80128.

Ian
Index: gcc/go/gofrontend/types.h
===
--- gcc/go/gofrontend/types.h   (revision 245745)
+++ gcc/go/gofrontend/types.h   (working copy)
@@ -993,6 +993,9 @@ class Type
const std::string& equal_name,
Function_type* equal_fntype);
 
+  // Return the alignment required by the memequalN function.
+  static int64_t memequal_align(Gogo*, int size);
+
   // Export the type.
   void
   export_type(Export* exp) const
Index: gcc/go/gofrontend/types.cc
===
--- gcc/go/gofrontend/types.cc  (revision 245745)
+++ gcc/go/gofrontend/types.cc  (working copy)
@@ -1580,6 +1580,42 @@ Type::make_type_descriptor_ptr_type()
   return ret;
 }
 
+// Return the alignment required by the memequalN function.  N is a
+// type size: 16, 32, 64, or 128.  The memequalN functions are defined
+// in libgo/go/runtime/alg.go.
+
+int64_t
+Type::memequal_align(Gogo* gogo, int size)
+{
+  const char* tn;
+  switch (size)
+{
+case 16:
+  tn = "int16";
+  break;
+case 32:
+  tn = "int32";
+  break;
+case 64:
+  tn = "int64";
+  break;
+case 128:
+  // The code uses [2]int64, which must have the same alignment as
+  // int64.
+  tn = "int64";
+  break;
+default:
+  go_unreachable();
+}
+
+  Type* t = Type::lookup_integer_type(tn);
+
+  int64_t ret;
+  if (!t->backend_type_align(gogo, &ret))
+go_unreachable();
+  return ret;
+}
+
 // Return whether this type needs specially built type functions.
 // This returns true for types that are comparable and either can not
 // use an identity comparison, or are a non-standard size.
@@ -1614,14 +1650,13 @@ Type::needs_specific_type_functions(Gogo
 case 0:
 case 1:
 case 2:
-  return align < 2;
+  return align < Type::memequal_align(gogo, 16);
 case 4:
-  return align < 4;
+  return align < Type::memequal_align(gogo, 32);
 case 8:
-  return align < 8;
+  return align < Type::memequal_align(gogo, 64);
 case 16:
-  // 8, not 16, because of how runtime.memequal128 is written.
-  return align < 8;
+  return align < Type::memequal_align(gogo, 128);
 default:
   return true;
 }
@@ -1713,7 +1748,7 @@ Type::type_functions(Gogo* gogo, Named_t
  equal_fnname = "runtime.memequal8";
  break;
case 2:
- if (align < 2)
+ if (align < Type::memequal_align(gogo, 16))
build_functions = true;
  else
{
@@ -1722,7 +1757,7 @@ Type::type_functions(Gogo* gogo, Named_t
}
  break;
case 4:
- if (align < 4)
+ if (align < Type::memequal_align(gogo, 32))
build_functions = true;
  else
{
@@ -1731,7 +1766,7 @@ Type::type_functions(Gogo* gogo, Named_t
}
  break;
case 8:
- if (align < 8)
+ if (align < Type::memequal_align(gogo, 64))
build_functions = true;
  else
{
@@ -1740,8 +1775,7 @@ Type::type_functions(Gogo* gogo, Named_t
}
  break;
case 16:
- // 8, not 16, because of how runtime.memequal128 is written.
- if (align < 8)
+ if (align < Type::memequal_align(gogo, 128))
build_functions = true;
  else
{


Backport to GCC6 (part 2)

2017-03-22 Thread Martin Liška
Hello.

There are 4 patches I'm going to install.
Patches can bootstrap on x86_64-linux-gnu and survives regression tests.

Martin
>From d0337d6690f925a323f6b271e9a138ae463c9e7e Mon Sep 17 00:00:00 2001
From: marxin 
Date: Fri, 3 Feb 2017 15:22:47 +
Subject: [PATCH 1/4] Backport r245155

gcc/ChangeLog:

2017-02-03  Martin Liska  

	PR lto/66295
	* multiple_target.c (create_dispatcher_calls): Redirect edge
	from a caller of a dispatcher.
	(expand_target_clones): Make the clones local.
	(ipa_target_clone): Do both target clones and resolvers.
	(ipa_dispatcher_calls): Remove the pass.
	(pass_dispatcher_calls::gate): Likewise.
	(make_pass_dispatcher_calls): Likewise.
	* passes.def (pass_target_clone): Put as very first IPA early
	pass.

gcc/testsuite/ChangeLog:

2017-02-03  Martin Liska  

	PR lto/66295
	* gcc.target/i386/mvc9.c: New test.
---
 gcc/multiple_target.c| 71 +---
 gcc/passes.def   |  3 +-
 gcc/testsuite/gcc.target/i386/mvc9.c | 28 ++
 3 files changed, 39 insertions(+), 63 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/mvc9.c

diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c
index 5edd8bb2ced..11e3fe7bc7b 100644
--- a/gcc/multiple_target.c
+++ b/gcc/multiple_target.c
@@ -94,6 +94,7 @@ create_dispatcher_calls (struct cgraph_node *node)
 	inode->resolve_alias (cgraph_node::get (resolver_decl));
 
   e->redirect_callee (inode);
+  e->redirect_call_stmt_to_callee ();
   /*  Since REDIRECT_CALLEE modifies NEXT_CALLER field we move to
 	  previously set NEXT_CALLER.  */
   e = NULL;
@@ -290,6 +291,7 @@ expand_target_clones (struct cgraph_node *node, bool definition)
   create_new_asm_name (attr, suffix);
   /* Create new target clone.  */
   cgraph_node *new_node = create_target_clone (node, definition, suffix);
+  new_node->local.local = false;
   XDELETEVEC (suffix);
 
   /* Set new attribute for the clone.  */
@@ -341,17 +343,19 @@ expand_target_clones (struct cgraph_node *node, bool definition)
   return ret;
 }
 
-static bool target_clone_pass;
-
 static unsigned int
 ipa_target_clone (void)
 {
   struct cgraph_node *node;
 
-  target_clone_pass = false;
+  bool target_clone_pass = false;
   FOR_EACH_FUNCTION (node)
-if (node->definition)
-  target_clone_pass |= expand_target_clones (node, true);
+target_clone_pass |= expand_target_clones (node, node->definition);
+
+  if (target_clone_pass)
+FOR_EACH_FUNCTION (node)
+  create_dispatcher_calls (node);
+
   return 0;
 }
 
@@ -367,7 +371,7 @@ const pass_data pass_data_target_clone =
   0,/* properties_provided */
   0,/* properties_destroyed */
   0,/* todo_flags_start */
-  0/* todo_flags_finish */
+  TODO_update_ssa		/* todo_flags_finish */
 };
 
 class pass_target_clone : public simple_ipa_opt_pass
@@ -395,58 +399,3 @@ make_pass_target_clone (gcc::context *ctxt)
 {
   return new pass_target_clone (ctxt);
 }
-
-static unsigned int
-ipa_dispatcher_calls (void)
-{
-  struct cgraph_node *node;
-
-  FOR_EACH_FUNCTION (node)
-if (!node->definition)
-  target_clone_pass |= expand_target_clones (node, false);
-  if (target_clone_pass)
-FOR_EACH_FUNCTION (node)
-  create_dispatcher_calls (node);
-  return 0;
-}
-
-namespace {
-
-const pass_data pass_data_dispatcher_calls =
-{
-  SIMPLE_IPA_PASS,		/* type */
-  "dispachercalls",		/* name */
-  OPTGROUP_NONE,		/* optinfo_flags */
-  TV_NONE,			/* tv_id */
-  ( PROP_ssa | PROP_cfg ),	/* properties_required */
-  0,/* properties_provided */
-  0,/* properties_destroyed */
-  0,/* todo_flags_start */
-  0/* todo_flags_finish */
-};
-
-class pass_dispatcher_calls : public simple_ipa_opt_pass
-{
-public:
-  pass_dispatcher_calls (gcc::context *ctxt)
-: simple_ipa_opt_pass (pass_data_dispatcher_calls, ctxt)
-  {}
-
-  /* opt_pass methods: */
-  virtual bool gate (function *);
-  virtual unsigned int execute (function *) { return ipa_dispatcher_calls (); }
-};
-
-bool
-pass_dispatcher_calls::gate (function *)
-{
-  return true;
-}
-
-} // anon namespace
-
-simple_ipa_opt_pass *
-make_pass_dispatcher_calls (gcc::context *ctxt)
-{
-  return new pass_dispatcher_calls (ctxt);
-}
diff --git a/gcc/passes.def b/gcc/passes.def
index 7aed1444542..7db9c9577cf 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -132,6 +132,7 @@ along with GCC; see the file COPYING3.  If not see
   POP_INSERT_PASSES ()
   POP_INSERT_PASSES ()
 
+  NEXT_PASS (pass_target_clone);
   NEXT_PASS (pass_ipa_chkp_produce_thunks);
   NEXT_PASS (pass_ipa_auto_profile);
   NEXT_PASS (pass_ipa_free_inline_summary);
@@ -151,7 +152,6 @@ along with GCC; see the file COPYING3.  If not see
   NEXT_PASS (pass_ipa_devirt);
   NEXT_PASS (pass_ipa_cp);
   NEXT_PASS (pass_ipa_cdtor_merge);
-  NEXT_PASS (pass_target_clone);
   NEXT_PASS (pass_ipa_hsa);
   NEXT_PASS (pass_ipa_inline);
   NEXT_PASS (pass_ipa_pure_const);
@@ -169,7 +169,6 @@ along w

Backport to GCC5 (part 2)

2017-03-22 Thread Martin Liška
And there's a single patch that I'll install after bootstrap and
regression tests.

Martin
>From cc7922d08b8b5234758e31e2d91557fd7f6cac9b Mon Sep 17 00:00:00 2001
From: marxin 
Date: Wed, 22 Feb 2017 09:45:42 +
Subject: [PATCH] Backport r245647

gcc/ChangeLog:

2017-02-22  Martin Liska  

	PR lto/79587
	* data-streamer-in.c (streamer_read_gcov_count): Remove assert.
	* data-streamer-out.c (streamer_write_gcov_count_stream):
	Likewise.
	* value-prof.c (stream_out_histogram_value): Make assert more
	precise based on type of counter.

gcc/testsuite/ChangeLog:

2017-02-22  Martin Liska  

	PR lto/79587
	* gcc.dg/tree-prof/pr79587.c: New test.
---
 gcc/data-streamer-in.c   |  1 -
 gcc/data-streamer-out.c  |  1 -
 gcc/testsuite/gcc.dg/tree-prof/pr79587.c | 26 ++
 gcc/value-prof.c | 12 +++-
 4 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-prof/pr79587.c

diff --git a/gcc/data-streamer-in.c b/gcc/data-streamer-in.c
index 424d52295fa..fec20ea59c4 100644
--- a/gcc/data-streamer-in.c
+++ b/gcc/data-streamer-in.c
@@ -206,6 +206,5 @@ gcov_type
 streamer_read_gcov_count (struct lto_input_block *ib)
 {
   gcov_type ret = streamer_read_hwi (ib);
-  gcc_assert (ret >= 0);
   return ret;
 }
diff --git a/gcc/data-streamer-out.c b/gcc/data-streamer-out.c
index caee0c6a464..ac2c1d64bcd 100644
--- a/gcc/data-streamer-out.c
+++ b/gcc/data-streamer-out.c
@@ -363,7 +363,6 @@ streamer_write_hwi_stream (struct lto_output_stream *obs, HOST_WIDE_INT work)
 void
 streamer_write_gcov_count_stream (struct lto_output_stream *obs, gcov_type work)
 {
-  gcc_assert (work >= 0);
   gcc_assert ((HOST_WIDE_INT) work == work);
   streamer_write_hwi_stream (obs, work);
 }
diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr79587.c b/gcc/testsuite/gcc.dg/tree-prof/pr79587.c
new file mode 100644
index 000..517e0819919
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/pr79587.c
@@ -0,0 +1,26 @@
+/* { dg-require-effective-target lto } */
+/* { dg-options "-O2 -flto" } */
+
+unsigned long global = -12345;
+
+unsigned long
+__attribute__((noinline))
+test(unsigned long v, unsigned long v2)
+{
+  unsigned long x = v % v2;
+
+  return x;
+}
+
+int main(int argc, char **argv)
+{
+  unsigned long r = 0;
+
+  for (int i = 0; i < 100; i++)
+r += test(argc, global);
+
+  if (r != 100)
+__builtin_abort ();
+
+  return 0;
+}
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index b16bce8746a..9d04ee2d6bd 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -431,7 +431,17 @@ stream_out_histogram_value (struct output_block *ob, histogram_value hist)
   break;
 }
   for (i = 0; i < hist->n_counters; i++)
-streamer_write_gcov_count (ob, hist->hvalue.counters[i]);
+{
+  /* When user uses an unsigned type with a big value, constant converted
+	 to gcov_type (a signed type) can be negative.  */
+  gcov_type value = hist->hvalue.counters[i];
+  if (hist->type == HIST_TYPE_SINGLE_VALUE && i == 0)
+	;
+  else
+	gcc_assert (value >= 0);
+
+  streamer_write_gcov_count (ob, value);
+}
   if (hist->hvalue.next)
 stream_out_histogram_value (ob, hist->hvalue.next);
 }
-- 
2.12.0



[patch, fortran, committed] Fix PR 80162, warning about missing location information

2017-03-22 Thread Thomas Koenig

Hello world,

I have committed the attached patch as obvious and simple
after regression-testing, as rev. 246388.

This is a case where the location checking pass did its job
and found a place where the location information was indeed
missing.

Regards

Thomas

2017-03-22  Thomas Koenig  

PR fortran/80142
* frontend-passes.c (combine_array_constructor): Take
location of new expression from constructor expression instead
of constructor.

2017-03-22  Thomas Koenig  

PR fortran/80142
* gfortran.dg/any_loc.f90: New test case.
Index: frontend-passes.c
===
--- frontend-passes.c	(Revision 245760)
+++ frontend-passes.c	(Arbeitskopie)
@@ -1381,7 +1381,7 @@ combine_array_constructor (gfc_expr *e)
   new_expr->ts = e->ts;
   new_expr->expr_type = EXPR_OP;
   new_expr->rank = c->expr->rank;
-  new_expr->where = c->where;
+  new_expr->where = c->expr->where;
   new_expr->value.op.op = e->value.op.op;
 
   if (scalar_first)
! { dg-do compile }
! { dg-options "-ffrontend-optimize" }
! PR fortran/80142 - the location on the expression of the
! unrolled any statement was not correctly set.
! Test case by Harald Anlauf.
MODULE gfcbug140
  implicit none
  integer ,parameter :: WV_NONE=  1
  integer, parameter :: WV_CDV_4   =  23
  integer, parameter :: WV_CDV_8   =  24
  integer, parameter :: wv_CDV_list(2) = [ WV_CDV_4, WV_CDV_8 ]
  integer:: basis  = WV_NONE
contains
  subroutine wave_1d (x)
real, intent(inout) :: x(:,:)
integer :: oldbase
oldbase = basis
if (any (basis == wv_CDV_list(:))) then
end if
basis = oldbase
  end subroutine wave_1d
  !-
  subroutine mr_gp_mat (A)
real, intent(inout) :: A (:,:)
call wave_1d (A)
  end subroutine mr_gp_mat
end module gfcbug140


Re: [PATCH][PR sanitizer/77631] Support separate debug info in libbacktrace

2017-03-22 Thread Denis Khalikov

Hello everyone,
I've fixed some issues and implemented functionality
to search debug file by build-id.
Can someone please review my patch.

> As far as I know all the debuglink code is ELF-specific.  I would do
> it all in elf.c.  While reading the sections of the executable, look
> for a debuglink section, and use it if present.  Keep the readlink
> code in posix.c, I suppose.  Apologies if this doesn't make sense.

I've moved backtrace_open_debugfile() function into elf.c.
This function checks debug sections (build-id/debuglink),
and if one of them exist - the function starts to search and open debug 
files.


Also I'll be very appreciated if someone give me advise about issues:
1.
| Skimming over the patch I noticed you duplicate libiberties xcrc32
| functionality.

To verify that debug file is valid, we should
verify crc32 sum, I took that algorithm from gdb, and
put it in the libbacktrace sources. However
this functionality is implemented by libiberty.
In case if libbactrace is being built as a static library,
I can't just link libbacktrace against static libbiberty.
Libtool can do it with objects which has "la" suffix,
but in time when libbacktrace build process happens
libiberty.la already removed.
Should i extract *.o files from the libiberty archive
and create libbacktrace archive with crc32.o from
libiberty or just keep this code in libbacktrace ?


2.
> > +clean_separate:glinktest.debug
> > + rm -f glinktest.debug
> > +
> > +separate: glinktest
> > + if test -n "$(OBJCOPY)" &&  test -n "$(STRIP)";  \
> > + then \
> > + $(OBJCOPY) --only-keep-debug glinktest glinktest.debug;\
> > + $(STRIP) glinktest;\
> > + $(OBJCOPY) --add-gnu-debuglink=glinktest.debug glinktest;\
> > + fi;
>
> |As far as I know "separate" is not a special thing in automake.  We
> | should always run (and clean) this test if the necessary objcopy
> | option is available.
>
In the attached patch I overrode default target check-TESTS
to use objcopy and strip, before test suite will run.
But the solution to move all test suite code from Makefile.in to 
Makefile.am seems not really good.
I searched for default target, which can be run before test suite logic, 
but can't find it for Makefile.am.

Should I keep current solution, or we have better alternative?

Thanks.


On 03/14/2017 04:49 PM, Ian Lance Taylor wrote:

On Mon, Mar 13, 2017 at 10:16 AM, Denis Khalikov
 wrote:

Hello everyone, i have a patch for this issue.

List of implemented functionality:

1.Reading .gnu_debuglink section from ELF file:
 a. Reading name of debug info file.
 b. Verifying crc32 sum.

2. Searching for separate debug info file from paths:
 a. /usr/lib/debug/path/to/executable
 b. /path/to/executable
 c. /path/to/executable/.debug

Assumed that debug info file generated by objcopy from binutils.

objcopy --only-keep-debug foo foo.debug
strip -g foo
objcopy --add-gnu-debuglink=foo.debug foo



+clean_separate:glinktest.debug
+ rm -f glinktest.debug
+
+separate: glinktest
+ if test -n "$(OBJCOPY)" &&  test -n "$(STRIP)";  \
+ then \
+ $(OBJCOPY) --only-keep-debug glinktest glinktest.debug;\
+ $(STRIP) glinktest;\
+ $(OBJCOPY) --add-gnu-debuglink=glinktest.debug glinktest;\
+ fi;


As far as I know "separate" is not a special thing in automake.  We
should always run (and clean) this test if the necessary objcopy
option is available.


+glinktest.lo: (INCDIR)/filenames.h backtrace.h backtrace-supported.h


Missing '$'  in "$(INCDIR)".


+/* Return 1 if header is valid and -1 on fail */


This comment does not explain what the function actually does.


+/* Return the pointer to char array with data from .gnudebuglink section 
inside.  */


Line too long, we use 80 column lines.


+unsigned char *
+elf_gnu_debuglink_section (struct backtrace_state *state, int descriptor,
+   backtrace_error_callback error_callback, void *data,
+   int exe, int *gnulink_data_len_out)


This should be static.  I see that you are calling it elsewhere, but
it doesn't make sense to call an "elf" function outside of elf.c.
This library is used on non-ELF systems.


+  /* Look for for the .gnu_debuglink section  */


Period at end of sentence.


   /* To translate PC to file/line when using DWARF, we need to find
- the .debug_info and .debug_line sections.  */
+   the .debug_info and .debug_line sections.  */


Why change the indentation like this?  I think the original was correct.


-  descriptor = backtrace_open (info->dlpi_name, pd->error_callback,
-   pd->data, &does_not_exist);
+  descriptor
+ = backtrace_open_debugfile (info->dlpi_name, pd->error_callback, pd->data,
+&debugfile_does_not_exist, pd->state, 0);
+  if (descriptor < 0)
+  descriptor = backtrace_open (info->dlpi_name, pd->error_callback,
+   pd->data, &does_not_exist);


This seems like unnecessary work.  Shouldn't we only try to open the
debug file if we find a .gnu_debuglink section?


+/*Just a simple test copied from btest.c, but in this case we don't have debug
+ * info in the executabl

Re: [PATCH] Decrease compile time memory with heavy find_base_{value,term} on i?86/x86_64 (PR rtl-optimization/63191, take 2)

2017-03-22 Thread Uros Bizjak
On Mon, Mar 20, 2017 at 12:15 PM, Jakub Jelinek  wrote:
> Hi!
>
> On Fri, Mar 10, 2017 at 07:57:39PM +0100, Jakub Jelinek wrote:
>> On Fri, Mar 10, 2017 at 07:52:37PM +0100, Bernd Schmidt wrote:
>> > On 03/10/2017 06:53 PM, Jakub Jelinek wrote:
>> > > +
>> > > +template 
>> > > +static inline rtx
>> > > +ix86_delegitimize_address_tmpl (rtx x)
>> > >  {
>> >
>> > Why is this a template and not a function arg?
>>
>> That was just an attempt to ensure that the compiler actually
>> either inlines it, or doesn't share code between the two versions, so the
>> base_term_p argument isn't checked at runtime.
>> But, as I said, I have no problem changing that, i.e.
>> remove the template line, s/_tmpl/_1/, add , bool base_term_p
>> and tweak both callers.
>
> Here is the other variant of the patch with inline function instead of
> template.  Also bootstrapped/regtested on x86_64-linux and i686-linux, ok
> for trunk (or is the other patch ok)?
>
> 2017-03-20  Jakub Jelinek  
>
> PR rtl-optimization/63191
> * config/i386/i386.c (ix86_delegitimize_address): Turn into small
> wrapper function, moved the whole old content into ...
> (ix86_delegitimize_address_1): ... this.  New inline function.
> (ix86_find_base_term): Use ix86_delegitimize_address_1 with
> true as last argument instead of ix86_delegitimize_address.

LGTM, but I don't want to step on Bernd's toes, so let's wait for his opinion.

Thanks,
Uros.

> --- gcc/config/i386/i386.c.jj   2017-03-07 20:04:52.0 +0100
> +++ gcc/config/i386/i386.c  2017-03-10 14:46:24.351775710 +0100
> @@ -17255,10 +17255,16 @@ ix86_delegitimize_tls_address (rtx orig_
> has a different PIC label for each routine but the DWARF debugging
> information is not associated with any particular routine, so it's
> necessary to remove references to the PIC label from RTL stored by
> -   the DWARF output code.  */
> +   the DWARF output code.
>
> -static rtx
> -ix86_delegitimize_address (rtx x)
> +   This helper is used in the normal ix86_delegitimize_address
> +   entrypoint (e.g. used in the target delegitimization hook) and
> +   in ix86_find_base_term.  As compile time memory optimization, we
> +   avoid allocating rtxes that will not change anything on the outcome
> +   of the callers (find_base_value and find_base_term).  */
> +
> +static inline rtx
> +ix86_delegitimize_address_1 (rtx x, bool base_term_p)
>  {
>rtx orig_x = delegitimize_mem_from_attrs (x);
>/* addend is NULL or some rtx if x is something+GOTOFF where
> @@ -17285,6 +17291,10 @@ ix86_delegitimize_address (rtx x)
>&& GET_CODE (XEXP (XEXP (x, 0), 0)) == UNSPEC
>&& XINT (XEXP (XEXP (x, 0), 0), 1) == UNSPEC_PCREL)
>  {
> + /* find_base_{value,term} only care about MEMs with arg_pointer_rtx
> +base.  A CONST can't be arg_pointer_rtx based.  */
> + if (base_term_p && MEM_P (orig_x))
> +   return orig_x;
>   rtx x2 = XVECEXP (XEXP (XEXP (x, 0), 0), 0, 0);
>   x = gen_rtx_PLUS (Pmode, XEXP (XEXP (x, 0), 1), x2);
>   if (MEM_P (orig_x))
> @@ -17361,7 +17371,9 @@ ix86_delegitimize_address (rtx x)
>if (! result)
>  return ix86_delegitimize_tls_address (orig_x);
>
> -  if (const_addend)
> +  /* For (PLUS something CONST_INT) both find_base_{value,term} just
> + recurse on the first operand.  */
> +  if (const_addend && !base_term_p)
>  result = gen_rtx_CONST (Pmode, gen_rtx_PLUS (Pmode, result, 
> const_addend));
>if (reg_addend)
>  result = gen_rtx_PLUS (Pmode, reg_addend, result);
> @@ -17399,6 +17411,14 @@ ix86_delegitimize_address (rtx x)
>return result;
>  }
>
> +/* The normal instantiation of the above template.  */
> +
> +static rtx
> +ix86_delegitimize_address (rtx x)
> +{
> +  return ix86_delegitimize_address_1 (x, false);
> +}
> +
>  /* If X is a machine specific address (i.e. a symbol or label being
> referenced as a displacement from the GOT implemented using an
> UNSPEC), then return the base term.  Otherwise return X.  */
> @@ -17424,7 +17444,7 @@ ix86_find_base_term (rtx x)
>return XVECEXP (term, 0, 0);
>  }
>
> -  return ix86_delegitimize_address (x);
> +  return ix86_delegitimize_address_1 (x, true);
>  }
>
>  static void
>
>
> Jakub


[wwwdocs] ARC's gcc7.x release notes

2017-03-22 Thread Claudiu Zissulescu
Hi,
 
I would like to add the attached patch to GCC7.x release notes. It contains the 
news on ARC backend.

Ok to apply?
Claudiu


changes.html.patch
Description: changes.html.patch


[PATCH v3] Fix PR79908 (and PR80136)

2017-03-22 Thread Bill Schmidt
Hi,

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79908 shows a case where
pass_stdarg ICEs attempting to gimplify a COMPLEX_EXPR with side
effects as an lvalue.  This occurs when the LHS of a VA_ARG has been
cast away.  The previous patch (reverted) used force_gimple_operand 
to instantiate the necessary side effects rather than gimplify_expr 
using is_gimple_lvalue.  This proved to cause problems on some targets
where the gimple expression produced by targetm.gimplify_va_arg_expr 
contains un-gimplified side effects using raw var_decls (see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80136).  After some
investigation, the right fix seems to be to just call
gimplify_and_add on the expression.

I've bootstrapped and tested this on powerpc64le-unknown-linux-gnu
with no regressions.  I've also built a ppc64le->aarch64 cross and
verified that Christophe's original report from PR80136 is now
fixed.  I don't have immediate access to an aarch64 native system
(compile farm authentication issues), so I would appreciate it if
James could run a native bootstrap to see if his issues are
resolved.

Provided there are no issues uncovered with aarch64 native bootstrap,
is this ok for trunk?

Thanks,
Bill


[gcc]

2017-03-21  Bill Schmidt  
Richard Biener  

PR tree-optimization/79908
PR tree-optimization/80136
* tree-stdarg.c (expand_ifn_va_arg_1): For a VA_ARG whose LHS has
been cast away, gimplify_and_add suffices.

[gcc/testsuite]

2017-03-21  Bill Schmidt  
Richard Biener  

PR tree-optimization/79908
PR tree-optimization/80136
* gcc.dg/torture/pr79908.c: New file.


Index: gcc/testsuite/gcc.dg/torture/pr79908.c
===
--- gcc/testsuite/gcc.dg/torture/pr79908.c  (revision 246334)
+++ gcc/testsuite/gcc.dg/torture/pr79908.c  (working copy)
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+/* Used to fail in the stdarg pass before fix for PR79908.  */
+
+typedef __builtin_va_list __gnuc_va_list;
+typedef __gnuc_va_list va_list;
+
+void testva (int n, ...)
+{
+  va_list ap;
+  _Complex int i = __builtin_va_arg (ap, _Complex int);
+}
Index: gcc/tree-stdarg.c
===
--- gcc/tree-stdarg.c   (revision 246334)
+++ gcc/tree-stdarg.c   (working copy)
@@ -1058,7 +1058,7 @@ expand_ifn_va_arg_1 (function *fun)
gimplify_assign (lhs, expr, &pre);
  }
else
- gimplify_expr (&expr, &pre, &post, is_gimple_lvalue, fb_lvalue);
+ gimplify_and_add (expr, &pre);
 
input_location = saved_location;
pop_gimplify_context (NULL);



[PATCHv2 0/5] OpenMP/PTX: improve correctness in SIMD regions

2017-03-22 Thread Alexander Monakov
Hello,

This patchset implements privatization of addressable variables in OpenMP SIMD
regions lowered for SIMT targets (i.e. NVPTX) via the approach identified in
the review of the previous submission.

Now instead of explicitly privatizing those variables as fields of an
allocated struct up front, we keep them as normal variables in the IR until
after IPA passes.  After that, the ompdevlow pass rewrites the IR to make
privatization explicit (patch 3/5).

Inlining is taught to privatize variables this way (patch 4), and when a
variable no longer has its address taken, it can be promoted to a gimple
register and no longer be subject to special privatization (patch 5).

Post-omplow IR looks like this:

  void *simtrec;
  int priv1 __attribute__((omp simt private));

  simduid.n_2 = GOMP_SIMT_ENTER (simduid.n_1, &priv1, &priv2, ...);
  simtrec = GOMP_SIMT_ENTER_ALLOC (simduid.n_2);

  for (...) { foo (&priv1); }

  priv1 = {CLOBBER};
  GOMP_SIMT_EXIT (simtrec);

And post-ompdevlow IR looks like this:

  struct {
int priv1;
  } *simtrec;
  int priv1 [value-expr: simtrec->priv1];
  /* priv1 is no longer itself present in IR */

  simduid.n_2 = simduid.n_1;
  simtrec = GOMP_SIMT_ENTER_ALLOC (sizeof *simtrec, alignof *simtrec);

  for (...) { foo (&simtrec->priv1); }

  *simtrec = {CLOBBER};
  GOMP_SIMT_EXIT (simtrec);

Thanks.
Alexander


[PATCH 3/5] omp-offload: implement SIMT privatization, part 2

2017-03-22 Thread Alexander Monakov
This patch implements rewriting of SIMT private variables as fields of a
struct by setting DECL_VALUE_EXPR on them and regimplifying statements.

* omp-offload.c: Include langhooks.h, tree-nested.h, stor-layout.h.
(ompdevlow_adjust_simt_enter): New.
(find_simtpriv_var_op): New.
(execute_omp_device_lower): Handle IFN_GOMP_SIMT_ENTER,
IFN_GOMP_SIMT_ENTER_ALLOC, IFN_GOMP_SIMT_EXIT.
---
 gcc/omp-offload.c | 115 ++
 1 file changed, 115 insertions(+)

diff --git a/gcc/omp-offload.c b/gcc/omp-offload.c
index d73955c..de27942 100644
--- a/gcc/omp-offload.c
+++ b/gcc/omp-offload.c
@@ -33,12 +33,15 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic-core.h"
 #include "fold-const.h"
 #include "internal-fn.h"
+#include "langhooks.h"
 #include "gimplify.h"
 #include "gimple-iterator.h"
 #include "gimplify-me.h"
 #include "gimple-walk.h"
 #include "tree-cfg.h"
 #include "tree-into-ssa.h"
+#include "tree-nested.h"
+#include "stor-layout.h"
 #include "common/common-target.h"
 #include "omp-general.h"
 #include "omp-offload.h"
@@ -1669,6 +1672,93 @@ make_pass_oacc_device_lower (gcc::context *ctxt)
   return new pass_oacc_device_lower (ctxt);
 }
 
+
+
+/* Rewrite GOMP_SIMT_ENTER_ALLOC call given by GSI and remove the preceding
+   GOMP_SIMT_ENTER call identifying the privatized variables, which are
+   turned to structure fields and receive a DECL_VALUE_EXPR accordingly.
+   Set *REGIMPLIFY to true, except if no privatized variables were seen.  */
+
+static void
+ompdevlow_adjust_simt_enter (gimple_stmt_iterator *gsi, bool *regimplify)
+{
+  gimple *alloc_stmt = gsi_stmt (*gsi);
+  tree simtrec = gimple_call_lhs (alloc_stmt);
+  tree simduid = gimple_call_arg (alloc_stmt, 0);
+  gimple *enter_stmt = SSA_NAME_DEF_STMT (simduid);
+  gcc_assert (gimple_call_internal_p (enter_stmt, IFN_GOMP_SIMT_ENTER));
+  tree rectype = lang_hooks.types.make_type (RECORD_TYPE);
+  TYPE_ARTIFICIAL (rectype) = TYPE_NAMELESS (rectype) = 1;
+  TREE_ADDRESSABLE (rectype) = 1;
+  TREE_TYPE (simtrec) = build_pointer_type (rectype);
+  for (unsigned i = 1; i < gimple_call_num_args (enter_stmt); i++)
+{
+  tree *argp = gimple_call_arg_ptr (enter_stmt, i);
+  if (*argp == null_pointer_node)
+   continue;
+  gcc_assert (TREE_CODE (*argp) == ADDR_EXPR
+ && VAR_P (TREE_OPERAND (*argp, 0)));
+  tree var = TREE_OPERAND (*argp, 0);
+
+  tree field = build_decl (DECL_SOURCE_LOCATION (var), FIELD_DECL,
+  DECL_NAME (var), TREE_TYPE (var));
+  SET_DECL_ALIGN (field, DECL_ALIGN (var));
+  DECL_USER_ALIGN (field) = DECL_USER_ALIGN (var);
+  TREE_THIS_VOLATILE (field) = TREE_THIS_VOLATILE (var);
+
+  insert_field_into_struct (rectype, field);
+
+  tree t = build_simple_mem_ref (simtrec);
+  t = build3 (COMPONENT_REF, TREE_TYPE (var), t, field, NULL);
+  TREE_THIS_VOLATILE (t) = TREE_THIS_VOLATILE (var);
+  SET_DECL_VALUE_EXPR (var, t);
+  DECL_HAS_VALUE_EXPR_P (var) = 1;
+  *regimplify = true;
+}
+  layout_type (rectype);
+  tree size = TYPE_SIZE_UNIT (rectype);
+  tree align = build_int_cst (TREE_TYPE (size), TYPE_ALIGN_UNIT (rectype));
+
+  alloc_stmt
+= gimple_build_call_internal (IFN_GOMP_SIMT_ENTER_ALLOC, 2, size, align);
+  gimple_call_set_lhs (alloc_stmt, simtrec);
+  gsi_replace (gsi, alloc_stmt, false);
+  gimple_stmt_iterator enter_gsi = gsi_for_stmt (enter_stmt);
+  enter_stmt = gimple_build_assign (simduid, gimple_call_arg (enter_stmt, 0));
+  gsi_replace (&enter_gsi, enter_stmt, false);
+
+  use_operand_p use;
+  gimple *exit_stmt;
+  if (single_imm_use (simtrec, &use, &exit_stmt))
+{
+  gcc_assert (gimple_call_internal_p (exit_stmt, IFN_GOMP_SIMT_EXIT));
+  gimple_stmt_iterator exit_gsi = gsi_for_stmt (exit_stmt);
+  tree clobber = build_constructor (rectype, NULL);
+  TREE_THIS_VOLATILE (clobber) = 1;
+  exit_stmt = gimple_build_assign (build_simple_mem_ref (simtrec), 
clobber);
+  gsi_insert_before (&exit_gsi, exit_stmt, GSI_SAME_STMT);
+}
+  else
+gcc_checking_assert (has_zero_uses (simtrec));
+}
+
+/* Callback for walk_gimple_stmt used to scan for SIMT-privatized variables.  
*/
+
+static tree
+find_simtpriv_var_op (tree *tp, int *walk_subtrees, void *)
+{
+  tree t = *tp;
+
+  if (VAR_P (t)
+  && DECL_HAS_VALUE_EXPR_P (t)
+  && lookup_attribute ("omp simt private", DECL_ATTRIBUTES (t)))
+{
+  *walk_subtrees = 0;
+  return t;
+}
+  return NULL_TREE;
+}
+
 /* Cleanup uses of SIMT placeholder internal functions: on non-SIMT targets,
VF is 1 and LANE is 0; on SIMT targets, VF is folded to a constant, and
LANE is kept to be expanded to RTL later on.  Also cleanup all other SIMT
@@ -1679,6 +1769,7 @@ static unsigned int
 execute_omp_device_lower ()
 {
   int vf = targetm.simt.vf ? targetm.simt.vf () : 1;
+  bool regimplify = false;
   basic_block bb;
 

[PATCH 1/5] nvptx: implement SIMT enter/exit insns

2017-03-22 Thread Alexander Monakov
This patch adds handling of new omp_simt_enter/omp_simt_exit named insns
in the NVPTX backend.

* config/nvptx/nvptx-protos.h (nvptx_output_simt_enter): Declare.
(nvptx_output_simt_exit): Declare.
* config/nvptx/nvptx.c (nvptx_init_unisimt_predicate): Use
cfun->machine->unisimt_location.  Handle NULL unisimt_predicate.
(init_softstack_frame): Move initialization of crtl->is_leaf to...
(nvptx_declare_function_name): ...here.  Emit declaration of local
memory space buffer for omp_simt_enter insn.
(nvptx_output_unisimt_switch): New.
(nvptx_output_softstack_switch): New.
(nvptx_output_simt_enter): New.
(nvptx_output_simt_exit): New.
* config/nvptx/nvptx.h (struct machine_function): New fields
has_simtreg, unisimt_location, simt_stack_size, simt_stack_align.
* config/nvptx/nvptx.md (UNSPECV_SIMT_ENTER): New unspec.
(UNSPECV_SIMT_EXIT): Ditto.
(omp_simt_enter_insn): New insn.
(omp_simt_enter): New expansion.
(omp_simt_exit): New insn.
* config/nvptx/nvptx.opt (msoft-stack-reserve-local): New option.


---
 gcc/config/nvptx/nvptx-protos.h |   2 +
 gcc/config/nvptx/nvptx.c| 163 +++-
 gcc/config/nvptx/nvptx.h|   6 ++
 gcc/config/nvptx/nvptx.md   |  39 ++
 gcc/config/nvptx/nvptx.opt  |   4 +
 5 files changed, 196 insertions(+), 18 deletions(-)

diff --git a/gcc/config/nvptx/nvptx-protos.h b/gcc/config/nvptx/nvptx-protos.h
index aaea3ba..16b316f 100644
--- a/gcc/config/nvptx/nvptx-protos.h
+++ b/gcc/config/nvptx/nvptx-protos.h
@@ -53,5 +53,7 @@ extern const char *nvptx_output_mov_insn (rtx, rtx);
 extern const char *nvptx_output_call_insn (rtx_insn *, rtx, rtx);
 extern const char *nvptx_output_return (void);
 extern const char *nvptx_output_set_softstack (unsigned);
+extern const char *nvptx_output_simt_enter (rtx, rtx, rtx);
+extern const char *nvptx_output_simt_exit (rtx);
 #endif
 #endif
diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 647855c..83f4610 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -1048,11 +1048,6 @@ init_softstack_frame (FILE *file, unsigned alignment, 
HOST_WIDE_INT size)
   fprintf (file, "\t\tsub.u%d %s, %s, " HOST_WIDE_INT_PRINT_DEC ";\n",
   bits, reg_stack, reg_frame, size);
 
-  /* Usually 'crtl->is_leaf' is computed during register allocator
- initialization (which is not done on NVPTX) or for pressure-sensitive
- optimizations.  Initialize it here, except if already set.  */
-  if (!crtl->is_leaf)
-crtl->is_leaf = leaf_function_p ();
   if (!crtl->is_leaf)
 fprintf (file, "\t\tst.shared.u%d [%s], %s;\n",
 bits, reg_sspslot, reg_stack);
@@ -1080,24 +1075,29 @@ nvptx_init_axis_predicate (FILE *file, int regno, const 
char *name)
 static void
 nvptx_init_unisimt_predicate (FILE *file)
 {
+  cfun->machine->unisimt_location = gen_reg_rtx (Pmode);
+  int loc = REGNO (cfun->machine->unisimt_location);
   int bits = POINTER_SIZE;
-  int master = REGNO (cfun->machine->unisimt_master);
-  int pred = REGNO (cfun->machine->unisimt_predicate);
+  fprintf (file, "\t.reg.u%d %%r%d;\n", bits, loc);
   fprintf (file, "\t{\n");
   fprintf (file, "\t\t.reg.u32 %%ustmp0;\n");
   fprintf (file, "\t\t.reg.u%d %%ustmp1;\n", bits);
-  fprintf (file, "\t\t.reg.u%d %%ustmp2;\n", bits);
   fprintf (file, "\t\tmov.u32 %%ustmp0, %%tid.y;\n");
   fprintf (file, "\t\tmul%s.u32 %%ustmp1, %%ustmp0, 4;\n",
   bits == 64 ? ".wide" : ".lo");
-  fprintf (file, "\t\tmov.u%d %%ustmp2, __nvptx_uni;\n", bits);
-  fprintf (file, "\t\tadd.u%d %%ustmp2, %%ustmp2, %%ustmp1;\n", bits);
-  fprintf (file, "\t\tld.shared.u32 %%r%d, [%%ustmp2];\n", master);
-  fprintf (file, "\t\tmov.u32 %%ustmp0, %%tid.x;\n");
-  /* Compute 'master lane index' as 'tid.x & __nvptx_uni[tid.y]'.  */
-  fprintf (file, "\t\tand.b32 %%r%d, %%r%d, %%ustmp0;\n", master, master);
-  /* Compute predicate as 'tid.x == master'.  */
-  fprintf (file, "\t\tsetp.eq.u32 %%r%d, %%r%d, %%ustmp0;\n", pred, master);
+  fprintf (file, "\t\tmov.u%d %%r%d, __nvptx_uni;\n", bits, loc);
+  fprintf (file, "\t\tadd.u%d %%r%d, %%r%d, %%ustmp1;\n", bits, loc, loc);
+  if (cfun->machine->unisimt_predicate)
+{
+  int master = REGNO (cfun->machine->unisimt_master);
+  int pred = REGNO (cfun->machine->unisimt_predicate);
+  fprintf (file, "\t\tld.shared.u32 %%r%d, [%%r%d];\n", master, loc);
+  fprintf (file, "\t\tmov.u32 %%ustmp0, %%laneid;\n");
+  /* Compute 'master lane index' as 'laneid & __nvptx_uni[tid.y]'.  */
+  fprintf (file, "\t\tand.b32 %%r%d, %%r%d, %%ustmp0;\n", master, master);
+  /* Compute predicate as 'tid.x == master'.  */
+  fprintf (file, "\t\tsetp.eq.u32 %%r%d, %%r%d, %%ustmp0;\n", pred, 
master);
+}
   fprintf (file, "\t}\n");
   need_unisimt_decl = true;
 }
@@ -1224,6 +1224,12 @@ nvptx_declare_function_name (FILE *fi

[PATCH 2/5] omp-low: implement SIMT privatization, part 1

2017-03-22 Thread Alexander Monakov
This patch adjusts privatization in OpenMP SIMD loops lowered for SIMT targets.
At lowering time, private variables receive "omp simt private" attribute, get
mentioned in argument list of GOMP_SIMT_ENTER function, and get a clobbering
assignment just prior to GOMP_SIMT_EXIT function.

The following patch will implement the second step: privatized variables are
converted to fields of a struct allocated by a call to GOMP_SIMT_ENTER_ALLOC.
This function is similar to __builtin_alloca_with_align, except that it
obtains per-SIMT-lane storage and implicitly performs target-specific actions;
on NVPTX that means a transition to per-lane softstacks and inverting the
uniform-simt mask.


* internal-fn.c (expand_GOMP_SIMT_ENTER): New.
(expand_GOMP_SIMT_ENTER_ALLOC): New.
(expand_GOMP_SIMT_EXIT): New.
* internal-fn.def (GOMP_SIMT_ENTER): New internal function.
(GOMP_SIMT_ENTER_ALLOC): Ditto.
(GOMP_SIMT_EXIT): Ditto.
* target-insns.def (omp_simt_enter): New insn.
(omp_simt_exit): Ditto.
* omp-low.c (struct omplow_simd_context): New fields simt_eargs,
simt_dlist.
(lower_rec_simd_input_clauses): Implement SIMT privatization.
(lower_rec_input_clauses): Likewise.
(lower_lastprivate_clauses): Handle SIMT privatization.

---
 gcc/internal-fn.c|  42 
 gcc/internal-fn.def  |   3 ++
 gcc/omp-low.c| 133 +--
 gcc/target-insns.def |   2 +
 4 files changed, 143 insertions(+), 37 deletions(-)

diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
index df7b930..75fe027 100644
--- a/gcc/internal-fn.c
+++ b/gcc/internal-fn.c
@@ -166,6 +166,48 @@ expand_GOMP_USE_SIMT (internal_fn, gcall *)
   gcc_unreachable ();
 }
 
+/* This should get expanded in omp_device_lower pass.  */
+
+static void
+expand_GOMP_SIMT_ENTER (internal_fn, gcall *)
+{
+  gcc_unreachable ();
+}
+
+/* Allocate per-lane storage and begin non-uniform execution region.  */
+
+static void
+expand_GOMP_SIMT_ENTER_ALLOC (internal_fn, gcall *stmt)
+{
+  rtx target;
+  tree lhs = gimple_call_lhs (stmt);
+  if (lhs)
+target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
+  else
+target = gen_reg_rtx (Pmode);
+  rtx size = expand_normal (gimple_call_arg (stmt, 0));
+  rtx align = expand_normal (gimple_call_arg (stmt, 1));
+  struct expand_operand ops[3];
+  create_output_operand (&ops[0], target, Pmode);
+  create_input_operand (&ops[1], size, Pmode);
+  create_input_operand (&ops[2], align, Pmode);
+  gcc_assert (targetm.have_omp_simt_enter ());
+  expand_insn (targetm.code_for_omp_simt_enter, 3, ops);
+}
+
+/* Deallocate per-lane storage and leave non-uniform execution region.  */
+
+static void
+expand_GOMP_SIMT_EXIT (internal_fn, gcall *stmt)
+{
+  gcc_checking_assert (!gimple_call_lhs (stmt));
+  rtx arg = expand_normal (gimple_call_arg (stmt, 0));
+  struct expand_operand ops[1];
+  create_input_operand (&ops[0], arg, Pmode);
+  gcc_assert (targetm.have_omp_simt_exit ());
+  expand_insn (targetm.code_for_omp_simt_exit, 1, ops);
+}
+
 /* Lane index on SIMT targets: thread index in the warp on NVPTX.  On targets
without SIMT execution this should be expanded in omp_device_lower pass.  */
 
diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def
index 2ba69c9..e162d81 100644
--- a/gcc/internal-fn.def
+++ b/gcc/internal-fn.def
@@ -142,6 +142,9 @@ DEF_INTERNAL_INT_FN (PARITY, ECF_CONST, parity, unary)
 DEF_INTERNAL_INT_FN (POPCOUNT, ECF_CONST, popcount, unary)
 
 DEF_INTERNAL_FN (GOMP_USE_SIMT, ECF_NOVOPS | ECF_LEAF | ECF_NOTHROW, NULL)
+DEF_INTERNAL_FN (GOMP_SIMT_ENTER, ECF_LEAF | ECF_NOTHROW, NULL)
+DEF_INTERNAL_FN (GOMP_SIMT_ENTER_ALLOC, ECF_LEAF | ECF_NOTHROW, NULL)
+DEF_INTERNAL_FN (GOMP_SIMT_EXIT, ECF_LEAF | ECF_NOTHROW, NULL)
 DEF_INTERNAL_FN (GOMP_SIMT_LANE, ECF_NOVOPS | ECF_LEAF | ECF_NOTHROW, NULL)
 DEF_INTERNAL_FN (GOMP_SIMT_VF, ECF_NOVOPS | ECF_LEAF | ECF_NOTHROW, NULL)
 DEF_INTERNAL_FN (GOMP_SIMT_LAST_LANE, ECF_NOVOPS | ECF_LEAF | ECF_NOTHROW, 
NULL)
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index c2c69cb..4199668 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -3457,6 +3457,8 @@ omp_clause_aligned_alignment (tree clause)
 struct omplow_simd_context {
   tree idx;
   tree lane;
+  vec simt_eargs;
+  gimple_seq simt_dlist;
   int max_vf;
   bool is_simt;
 };
@@ -3492,18 +3494,39 @@ lower_rec_simd_input_clauses (tree new_var, omp_context 
*ctx,
   if (sctx->max_vf == 1)
 return false;
 
-  tree atype = build_array_type_nelts (TREE_TYPE (new_var), sctx->max_vf);
-  tree avar = create_tmp_var_raw (atype);
-  if (TREE_ADDRESSABLE (new_var))
-TREE_ADDRESSABLE (avar) = 1;
-  DECL_ATTRIBUTES (avar)
-= tree_cons (get_identifier ("omp simd array"), NULL,
-DECL_ATTRIBUTES (avar));
-  gimple_add_tmp_var (avar);
-  ivar = build4 (ARRAY_REF, TREE_TYPE (new_var), avar, sctx->idx,
-NULL_TREE, NULL_TREE);
-  lvar = build4 (ARRAY_REF, TREE_TY

[PATCH 5/5] address-taken: optimize SIMT privatized variables

2017-03-22 Thread Alexander Monakov
This patch implements promotion of SIMT private variables if GOMP_SIMT_ENTER
is the only remaining statement where their address is taken, by handling it
similar to ASAN_MARK.

To avoid rebuilding GOMP_SIMT_ENTER statement from scratch, set argument
slot to a null pointer when the corresponding variable is optimized.

* tree-ssa.c (execute_update_addresses_taken): Handle GOMP_SIMT_ENTER.

---
 gcc/tree-ssa.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 831fd61..42e708e 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -1654,7 +1654,8 @@ execute_update_addresses_taken (void)
  gimple_ior_addresses_taken (addresses_taken, stmt);
  gimple_call_set_arg (stmt, 1, arg);
}
- else if (is_asan_mark_p (stmt))
+ else if (is_asan_mark_p (stmt)
+  || gimple_call_internal_p (stmt, IFN_GOMP_SIMT_ENTER))
;
  else
gimple_ior_addresses_taken (addresses_taken, stmt);
@@ -1940,6 +1941,18 @@ execute_update_addresses_taken (void)
continue;
  }
  }
+   else if (gimple_call_internal_p (stmt, IFN_GOMP_SIMT_ENTER))
+ for (i = 1; i < gimple_call_num_args (stmt); i++)
+   {
+ tree *argp = gimple_call_arg_ptr (stmt, i);
+ if (*argp == null_pointer_node)
+   continue;
+ gcc_assert (TREE_CODE (*argp) == ADDR_EXPR
+ && VAR_P (TREE_OPERAND (*argp, 0)));
+ tree var = TREE_OPERAND (*argp, 0);
+ if (bitmap_bit_p (suitable_for_renaming, DECL_UID (var)))
+   *argp = null_pointer_node;
+   }
for (i = 0; i < gimple_call_num_args (stmt); ++i)
  {
tree *argp = gimple_call_arg_ptr (stmt, i);
-- 
1.8.3.1



[PATCH 4/5] tree-inline: implement SIMT privatization, part 3

2017-03-22 Thread Alexander Monakov
This patch implements privatization for SIMT during inlining.  We need to
discover if the call being inlined belongs to a SIMT region (by looking at
simduid of the containing loop), and if so, treat them similar to OpenMP-SIMD
privatization: add the "omp simt private" attribute and mention them among
arguments of GOMP_SIMT_ENTER.

OpenMP-SIMD privatization also adds a clobber at the end of the region; I'm
not sure if it's required here: in the example I've looked at, inlined code
already contained a clobber.

* tree-inline.h (struct copy_body_data): New field dst_simt_vars.
* tree-inline.c (expand_call_inline): Handle SIMT privatization.
(copy_decl_for_dup_finish): Ditto.
---
 gcc/tree-inline.c | 59 ---
 gcc/tree-inline.h |  4 
 2 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 6b6d489..56817e4 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4385,6 +4385,11 @@ expand_call_inline (basic_block bb, gimple *stmt, 
copy_body_data *id)
   gcall *call_stmt;
   unsigned int i;
   unsigned int prop_mask, src_properties;
+  struct function *dst_cfun;
+  tree simduid;
+  use_operand_p use;
+  gimple *simtenter_stmt = NULL;
+  hash_set *simtvars_st = NULL;
 
   /* The gimplifier uses input_location in too many places, such as
  internal_get_tmp_var ().  */
@@ -4588,15 +4593,26 @@ expand_call_inline (basic_block bb, gimple *stmt, 
copy_body_data *id)
   id->src_cfun = DECL_STRUCT_FUNCTION (fn);
   id->call_stmt = call_stmt;
 
+  /* When inlining into an OpenMP SIMD-on-SIMT loop, arrange for new automatic
+ variables to be added to IFN_GOMP_SIMT_ENTER argument list.  */
+  dst_cfun = DECL_STRUCT_FUNCTION (id->dst_fn);
+  if (!(dst_cfun->curr_properties & PROP_gimple_lomp_dev)
+  && (simduid = bb->loop_father->simduid) != NULL_TREE
+  && (simduid = ssa_default_def (dst_cfun, simduid)) != NULL_TREE
+  && single_imm_use (simduid, &use, &simtenter_stmt)
+  && is_gimple_call (simtenter_stmt)
+  && gimple_call_internal_p (simtenter_stmt, IFN_GOMP_SIMT_ENTER))
+{
+  simtvars_st = id->dst_simt_vars;
+  id->dst_simt_vars = new hash_set;
+}
+
   /* If the src function contains an IFN_VA_ARG, then so will the dst
  function after inlining.  Likewise for IFN_GOMP_USE_SIMT.  */
   prop_mask = PROP_gimple_lva | PROP_gimple_lomp_dev;
   src_properties = id->src_cfun->curr_properties & prop_mask;
   if (src_properties != prop_mask)
-{
-  struct function *dst_cfun = DECL_STRUCT_FUNCTION (id->dst_fn);
-  dst_cfun->curr_properties &= src_properties | ~prop_mask;
-}
+dst_cfun->curr_properties &= src_properties | ~prop_mask;
 
   gcc_assert (!id->src_cfun->after_inlining);
 
@@ -4730,6 +4746,25 @@ expand_call_inline (basic_block bb, gimple *stmt, 
copy_body_data *id)
   if (cfun->gimple_df)
 pt_solution_reset (&cfun->gimple_df->escaped);
 
+  /* Add new automatic variables to IFN_GOMP_SIMT_ENTER arguments.  */
+  if (id->dst_simt_vars)
+{
+  size_t nargs = gimple_call_num_args (simtenter_stmt);
+  hash_set *vars = id->dst_simt_vars;
+  auto_vec newargs (nargs + vars->elements ());
+  for (size_t i = 0; i < nargs; i++)
+   newargs.quick_push (gimple_call_arg (simtenter_stmt, i));
+  for (hash_set::iterator i = vars->begin (); i != vars->end (); ++i)
+   newargs.quick_push (build1 (ADDR_EXPR,
+   build_pointer_type (TREE_TYPE (*i)), *i));
+  gcall *g = gimple_build_call_internal_vec (IFN_GOMP_SIMT_ENTER, newargs);
+  gimple_call_set_lhs (g, gimple_call_lhs (simtenter_stmt));
+  gimple_stmt_iterator gsi = gsi_for_stmt (simtenter_stmt);
+  gsi_replace (&gsi, g, false);
+  delete id->dst_simt_vars;
+  id->dst_simt_vars = simtvars_st;
+}
+
   /* Clean up.  */
   if (id->debug_map)
 {
@@ -5453,9 +5488,19 @@ copy_decl_for_dup_finish (copy_body_data *id, tree decl, 
tree copy)
function.  */
 ;
   else
-/* Ordinary automatic local variables are now in the scope of the
-   new function.  */
-DECL_CONTEXT (copy) = id->dst_fn;
+{
+  /* Ordinary automatic local variables are now in the scope of the
+new function.  */
+  DECL_CONTEXT (copy) = id->dst_fn;
+  if (VAR_P (copy) && id->dst_simt_vars && !is_gimple_reg (copy))
+   {
+ if (!lookup_attribute ("omp simt private", DECL_ATTRIBUTES (copy)))
+   DECL_ATTRIBUTES (copy)
+ = tree_cons (get_identifier ("omp simt private"), NULL,
+  DECL_ATTRIBUTES (copy));
+ id->dst_simt_vars->add (copy);
+   }
+}
 
   return copy;
 }
diff --git a/gcc/tree-inline.h b/gcc/tree-inline.h
index 88b3286..cf46fa5 100644
--- a/gcc/tree-inline.h
+++ b/gcc/tree-inline.h
@@ -145,6 +145,10 @@ struct copy_body_data
  equivalents in the function into which it is being inlined.  */
   hash_map *dependenc

[PATCH gfortran] Fix PRs 79602, 79844, 79853, 79859, and 80011.

2017-03-22 Thread Dominique d'Humières
Th attached patch fixes some of the diagnostic issues reported by Roland Illig. 
Ok for trunk?

2017-03-22  Dominique d'Humieres  

PR fortran/79602
* decl.c: Replace '%s' with %qs.
* expr.c: Likewise.
* interface.c: Likewise.
* match.c: Likewise.
* primary.c: Likewise.
* resolve.c: Likewise.

PR fortran/79844
PR fortran/80011
* io.c: Remove trailing spaces.
* match.c: Likewise.
* openmp.c: Likewise.
* resolve.c: Likewise.
* trans-intrinsic.c: Likewise.

PR fortran/79853
* expr.c: Remove a double spaces.

PR fortran/79859
* primary.c: Remove spurious quotes around %qs.

TIA

Dominique



patch-79602d
Description: Binary data


Re: [wwwdocs] ARC's gcc7.x release notes

2017-03-22 Thread Gerald Pfeifer
Hi Claudiu,

On Wed, 22 Mar 2017, Claudiu Zissulescu wrote:
> I would like to add the attached patch to GCC7.x release notes. It 
> contains the news on ARC backend.

s/cpu/CPU/g through, and then good to commit.

By the way, any ARC maintainer or reviewer can approve such
changes (and in the case of reviewers, really self approve
web changes like this). :-)  So you did not require approval,
though always happy to help review.

Gerald


[PATCH] Add deduction guides for C++17 (P0433R2, partial)

2017-03-22 Thread Jonathan Wakely

This adds some of the C++17 deduction guides, all except for the
allocator-aware containers and basic_regex. I have patches adding
those guide too, but am still working on the tests (some cases I
expected to  work are ill-formed, so I'm still looking into why).

* include/bits/shared_ptr.h (shared_ptr, weak_ptr): Add deduction
guides for C++17.
* include/bits/std_function.h (function): Likewise.
* include/bits/stl_pair.h (pair): Likewise.
* include/debug/array (__gnu_debug::array): Likewise.
* include/std/array (array): Likewise.
* include/std/functional (make_default_searcher)
(make_boyer_moore_searcher, make_boyer_moore_horspool_searcher):
Remove generator functions.
* include/std/tuple (tuple): Add deduction guides.
* include/std/valarray (valarray): Likewise.
* testsuite/20_util/function_objects/searchers.cc: Adjust to use
class template argument deduction instead of generator functions.
* testsuite/20_util/function/cons/deduction.cc: New test.
* testsuite/20_util/optional/cons/deduction_guide.cc: Rename to ...
* testsuite/20_util/optional/cons/deduction.cc: ... here.
* testsuite/20_util/pair/cons/deduction.cc: New test.
* testsuite/20_util/shared_ptr/cons/deduction.cc: New test.
* testsuite/20_util/tuple/cons/deduction.cc: New test.
* testsuite/20_util/tuple/element_access/get_neg.cc: Adjust dg-error.
* testsuite/20_util/unique_ptr/cons/deduction_neg.cc: New test.
* testsuite/20_util/weak_ptr/cons/deduction.cc: New test.
* testsuite/23_containers/array/cons/deduction.cc: New test.
* testsuite/23_containers/array/cons/deduction_neg.cc: New test.
* testsuite/23_containers/array/tuple_interface/get_debug_neg.cc:
Adjust dg-error.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Likewise.
* testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc:
Likewise.
* testsuite/26_numerics/valarray/deduction.cc: New test.
* testsuite/30_threads/lock_guard/cons/deduction.cc: New test.
* testsuite/30_threads/scoped_lock/cons/deduction.cc: New test.
* testsuite/30_threads/unique_lock/cons/deduction.cc: New test.

Tested powerpc64le-linux, comitted to trunk.

commit beffaa9ede39cc8b9993685caa8820c1fc55382b
Author: Jonathan Wakely 
Date:   Wed Mar 22 15:37:23 2017 +

Add deduction guides for C++17 (P0433R2, partial)

* include/bits/shared_ptr.h (shared_ptr, weak_ptr): Add deduction
guides for C++17.
* include/bits/std_function.h (function): Likewise.
* include/bits/stl_pair.h (pair): Likewise.
* include/debug/array (__gnu_debug::array): Likewise.
* include/std/array (array): Likewise.
* include/std/functional (make_default_searcher)
(make_boyer_moore_searcher, make_boyer_moore_horspool_searcher):
Remove generator functions.
* include/std/tuple (tuple): Add deduction guides.
* include/std/valarray (valarray): Likewise.
* testsuite/20_util/function_objects/searchers.cc: Adjust to use
class template argument deduction instead of generator functions.
* testsuite/20_util/function/cons/deduction.cc: New test.
* testsuite/20_util/optional/cons/deduction_guide.cc: Rename to ...
* testsuite/20_util/optional/cons/deduction.cc: ... here.
* testsuite/20_util/pair/cons/deduction.cc: New test.
* testsuite/20_util/shared_ptr/cons/deduction.cc: New test.
* testsuite/20_util/tuple/cons/deduction.cc: New test.
* testsuite/20_util/tuple/element_access/get_neg.cc: Adjust dg-error.
* testsuite/20_util/unique_ptr/cons/deduction_neg.cc: New test.
* testsuite/20_util/weak_ptr/cons/deduction.cc: New test.
* testsuite/23_containers/array/cons/deduction.cc: New test.
* testsuite/23_containers/array/cons/deduction_neg.cc: New test.
* testsuite/23_containers/array/tuple_interface/get_debug_neg.cc:
Adjust dg-error.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Likewise.
* testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc:
Likewise.
* testsuite/26_numerics/valarray/deduction.cc: New test.
* testsuite/30_threads/lock_guard/cons/deduction.cc: New test.
* testsuite/30_threads/scoped_lock/cons/deduction.cc: New test.
* testsuite/30_threads/unique_lock/cons/deduction.cc: New test.

diff --git a/libstdc++-v3/include/bits/shared_ptr.h 
b/libstdc++-v3/include/bits/shared_ptr.h
index 851f9cf..fe933ff 100644
--- a/libstdc++-v3/include/bits/shared_ptr.h
+++ b/libstdc++-v3/include/bits/shared_ptr.h
@@ -355,6 +355,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   friend class weak_ptr<_Tp>;
 };
 
+#if __cpp_deduction_guides >= 201606
+  template
+shared_ptr(weak_ptr<_Tp>) ->  s

Re: [PATCH gfortran] Fix PRs 79602, 79844, 79853, 79859, and 80011.

2017-03-22 Thread Thomas Koenig

Hi Dominique,


Th attached patch fixes some of the diagnostic issues reported by Roland Illig. 
Ok for trunk?


Yes, OK.  Thanks for the patch!

Regards

Thomas



RE: [wwwdocs] ARC's gcc7.x release notes

2017-03-22 Thread Claudiu Zissulescu
> By the way, any ARC maintainer or reviewer can approve such
> changes (and in the case of reviewers, really self approve
> web changes like this). :-)  So you did not require approval,
> though always happy to help review.
> 

That's great news, thank you Gerald for the quick review. I still have one 
question, as I never worked with wwwdocs, do I need to perform extra operations 
(like updating a ChangeLog kind of file) before committing my patch to cvs 
trunk?

Thank you,
Claudiu


Re: [PATCH gfortran] Fix PRs 79602, 79844, 79853, 79859, and 80011.

2017-03-22 Thread Dominique d'Humières
Committed as revision r246391.

Thanks for the quick review.

Dominique

> Le 22 mars 2017 à 17:08, Thomas Koenig  a écrit :
> 
> Hi Dominique,
> 
>> Th attached patch fixes some of the diagnostic issues reported by Roland 
>> Illig. Ok for trunk?
> 
> Yes, OK.  Thanks for the patch!
> 
> Regards
> 
>   Thomas



Re: [patch, libgfortran] PR78881 [F03] reading from string with DTIO procedure does not work properly

2017-03-22 Thread Dominique d'Humières
The patch works as expected. Note that the line

! { dg-final { cleanup-modules "t_m" } }
in  dtio_26.f03 and  dtio_27.f03 can/should be removed IIRC.

Cheers,

Dominique



Re: [build,darwin] Fix toplevel configure test for LTO on darwin

2017-03-22 Thread Mike Stump
On Mar 17, 2017, at 3:36 AM, FX  wrote:
> 
> When LTO was introduced, on macOS it needed darwin9 to work. Over time, most 
> tests for “*-apple-darwin9” in the toplevel configure were changed to also 
> include later darwin versions: *-darwin[[912]]*  However, the check for LTO 
> was not updated. As far as I know, this is merely an oversight: LTO works 
> fine on Darwin, and most vendors (homebrew, macports, etc.) have been 
> shipping with --enable-lto for years.
> 
> The attached patch makes it build LTO by default on darwin >= 9. I realize 
> it’s late but I hope the very restricted nature (and ultra-low risk) of the 
> patch make it a candidate for inclusion in trunk nonetheless.
> 
> Bootstrapped and regtested on x86_64-apple-darwin16. OK to commit?

Ok.



Re: [PATCH] Fix r242743 change of gcc/system.h

2017-03-22 Thread Gunther Nikl
Paolo Bonzini :
> 
> On 19/03/2017 22:17, Gunther Nikl wrote:
> > Hello Paolo!
> > 
> > Building older GCC releases with clang tends to issue warnings. This
> > can be annoying especially when they originate from a header. While
> > backporting r242743 I noticed that the non-C++ cases of the changed
> > macro definitions in gcc/system.h are broken. Since GCC trunk is
> > build in C++ mode this is not an issue, but should be fixed
> > nevertheless I think.
> > 
> > Regards,
> > Gunther
> 
> Of course!  If you have commit access, you can commit this as obvious
> I think.

No, I don't have commit access. Please commit the patch for me. Thanks.

> What is the warning like?

Sorry, I don't have the warning available :-/ I noticed that there
appears to be a problem because of a patch to the FreeBSD sources back
in September of the last year.

Regards,
Gunther

> > gcc:
> > 2017-03-XX  Gunther Nikl  
> > 
> > * system.h (HAVE_DESIGNATED_INITIALIZERS,
> > HAVE_DESIGNATED_UNION_INITIALIZERS): Fix non C++ case.
> > 
> > 
> > Index: gcc/system.h
> > ===
> > --- gcc/system.h(revision 246106)
> > +++ gcc/system.h(working copy)
> > @@ -581,7 +581,7 @@ extern int vsnprintf (char *, size_t, const
> > char * #define HAVE_DESIGNATED_INITIALIZERS 0
> >  #else
> >  #define HAVE_DESIGNATED_INITIALIZERS \
> > -  (((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L))
> > +  ((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L))
> >  #endif
> >  #endif
> >  
> > @@ -590,7 +590,7 @@ extern int vsnprintf (char *, size_t, const
> > char * #define HAVE_DESIGNATED_UNION_INITIALIZERS (GCC_VERSION >=
> > 4007) #else
> >  #define HAVE_DESIGNATED_UNION_INITIALIZERS \
> > -  (((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L))
> > +  ((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L))
> >  #endif
> >  #endif


[PING][PATCH][PR79542][Ada] Fix ICE in dwarf2out.c with nested func. inlining

2017-03-22 Thread Pierre-Marie de Rodat

Hello,

This is a ping for the patch I posted there: 
. Thank you!


--
Pierre-Marie de Rodat


Re: [wwwdocs] gcc-8/porting_to.html

2017-03-22 Thread Thomas Preudhomme

Hi JonY,

Sorry for the delay. Please find updated patch as per Gerald and you suggestion.

Is this ok for wwwdocs once [1] is committed in GCC 8 cycle?

[1] https://gcc.gnu.org/ml/gcc-patches/2017-02/msg01153.html

Best regards,

Thomas

On 12/03/17 23:51, JonY wrote:

On 03/12/2017 02:07 PM, Gerald Pfeifer wrote:

On Thu, 9 Mar 2017, Thomas Preudhomme wrote:

JonY: what about the attached patch to document the change of behavior
of GCC on Windows depending on the configure option used?


+MinGW issues
+
+GCC on Microsoft Windows can now be configured via
+--enable-mingw-wildcard or
--disable-mingw-wildcard
+to force a specific behavior for GCC itself with regards to supporting or
+not the wildcard character. Prior versions of GCC would follow the

Perhaps put "(or not)" in parentheses?

+configuration of MinGW runtime. This behavior can still be obtained by not
+using the above options or by using
+--enable-mingw-wildcard=platform.

Is this really going to be a question for the Porting Guide, or more
something you'd put into the release notes (aka changes.html)?  I am
thinking more the latter.

This patch is approved for gcc-8/changes.html once GCC 7 has branched
and gcc-8/changes.html be put in place (though I may be doing that pro-
actively later today ;-).

Gerald



It should be part of the release notes since it only affects GCC itself,
not the actual generated output.


cvs diff: Diffing .
cvs diff: Diffing bin
cvs diff: Diffing cgi-bin
cvs diff: Diffing htdocs
cvs diff: Diffing htdocs/benchmarks
cvs diff: Diffing htdocs/bugs
cvs diff: Diffing htdocs/bzkanban
cvs diff: Diffing htdocs/egcs-1.0
cvs diff: Diffing htdocs/egcs-1.1
cvs diff: Diffing htdocs/fortran
cvs diff: Diffing htdocs/gcc-2.95
cvs diff: Diffing htdocs/gcc-3.0
cvs diff: Diffing htdocs/gcc-3.1
cvs diff: Diffing htdocs/gcc-3.2
cvs diff: Diffing htdocs/gcc-3.3
cvs diff: Diffing htdocs/gcc-3.4
cvs diff: Diffing htdocs/gcc-4.0
cvs diff: Diffing htdocs/gcc-4.1
cvs diff: Diffing htdocs/gcc-4.2
cvs diff: Diffing htdocs/gcc-4.3
cvs diff: Diffing htdocs/gcc-4.4
cvs diff: Diffing htdocs/gcc-4.5
cvs diff: Diffing htdocs/gcc-4.6
cvs diff: Diffing htdocs/gcc-4.7
cvs diff: Diffing htdocs/gcc-4.8
cvs diff: Diffing htdocs/gcc-4.9
cvs diff: Diffing htdocs/gcc-5
cvs diff: Diffing htdocs/gcc-6
cvs diff: Diffing htdocs/gcc-7
cvs diff: Diffing htdocs/gcc-8
Index: htdocs/gcc-8/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-8/changes.html,v
retrieving revision 1.2
diff -u -r1.2 changes.html
--- htdocs/gcc-8/changes.html	12 Mar 2017 14:25:34 -	1.2
+++ htdocs/gcc-8/changes.html	21 Mar 2017 10:59:46 -
@@ -135,7 +135,16 @@
 
 
 
-
+Windows
+   
+ GCC on Microsoft Windows can now be configured via
+   --enable-mingw-wildcard or
+   --disable-mingw-wildcard to force a specific behavior for
+   GCC itself with regards to supporting or not the wildcard character.
+   Prior versions of GCC would follow the configuration of MinGW runtime.
+   This behavior can still be obtained by not using the above options or by
+   using --enable-mingw-wildcard=platform.
+   
 
 
 
cvs diff: Diffing htdocs/git
cvs diff: Diffing htdocs/img
cvs diff: Diffing htdocs/install
cvs diff: Diffing htdocs/java
cvs diff: Diffing htdocs/libstdc++
cvs diff: Diffing htdocs/news
cvs diff: Diffing htdocs/onlinedocs
cvs diff: Diffing htdocs/onlinedocs/4.6.0
cvs diff: Diffing htdocs/onlinedocs/4.6.1
cvs diff: Diffing htdocs/onlinedocs/4.6.2
cvs diff: Diffing htdocs/onlinedocs/4.6.3
cvs diff: Diffing htdocs/onlinedocs/4.6.4
cvs diff: Diffing htdocs/onlinedocs/4.7.0
cvs diff: Diffing htdocs/onlinedocs/4.7.1
cvs diff: Diffing htdocs/onlinedocs/4.7.2
cvs diff: Diffing htdocs/onlinedocs/4.7.3
cvs diff: Diffing htdocs/onlinedocs/4.7.4
cvs diff: Diffing htdocs/onlinedocs/4.8.0
cvs diff: Diffing htdocs/onlinedocs/4.8.1
cvs diff: Diffing htdocs/onlinedocs/4.8.2
cvs diff: Diffing htdocs/onlinedocs/4.8.3
cvs diff: Diffing htdocs/onlinedocs/4.8.4
cvs diff: Diffing htdocs/onlinedocs/4.8.5
cvs diff: Diffing htdocs/onlinedocs/4.9.0
cvs diff: Diffing htdocs/onlinedocs/4.9.1
cvs diff: Diffing htdocs/onlinedocs/4.9.2
cvs diff: Diffing htdocs/onlinedocs/4.9.3
cvs diff: Diffing htdocs/onlinedocs/4.9.4
cvs diff: Diffing htdocs/onlinedocs/5.1.0
cvs diff: Diffing htdocs/onlinedocs/5.2.0
cvs diff: Diffing htdocs/onlinedocs/5.3.0
cvs diff: Diffing htdocs/onlinedocs/5.4.0
cvs diff: Diffing htdocs/onlinedocs/6.1.0
cvs diff: Diffing htdocs/onlinedocs/6.2.0
cvs diff: Diffing htdocs/onlinedocs/6.3.0
cvs diff: Diffing htdocs/projects
cvs diff: Diffing htdocs/projects/bp
cvs diff: Diffing htdocs/projects/cxx-reflection
cvs diff: Diffing htdocs/projects/gomp
cvs diff: Diffing htdocs/projects/lto
cvs diff: Diffing htdocs/projects/strees
cvs diff: Diffing htdocs/projects/tree-ssa
cvs diff: Diffing htdocs/testing


[PATCH,rs6000] Handle conflicting target options -mno-power9-vector and -mcpu=power9

2017-03-22 Thread Kelvin Nilsen

Internal testing recently revealed that use of the -mno-power9-vector
target option in combination with the -mcpu=power9 target option
results in termination of gcc with the error message:

  power9-dform requires power9-vector

This same problem is seen if the -mno-power9-vector target option is
specified to a gcc which was built using --with-cpu=power9 as an
argument to configure.

In both cases, the preferred behavior is that the target option
-mno-power9-vector causes power9-dform to be automatically disabled.
 This patch implements the preferred behavior and adds a test case to
demonstrate the fix.

The patch has been bootstrapped and tested with no regressions on both
powerpc64-unknown-linux-gnu and powerpc64le-unknown-linux-gnu.  Is this
ok for the trunk?

gcc/testsuite/ChangeLog:

2017-03-21  Kelvin Nilsen  

* gcc.target/powerpc/p9-options-1.c: New test.

gcc/ChangeLog:

2017-03-21  Kelvin Nilsen  

* config/rs6000/rs6000.c (rs6000_option_override_internal): Change
handling of certain combinations of target options, including the
combinations -mpower8-vector vs. -mno-vsx, -mpower8-vector vs.
-mno-power8-vector, and -mpower9_dform vs. -mno-power9-vector.

Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 246212)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -4246,9 +4246,22 @@ rs6000_option_override_internal (bool global_init_
 
   if (TARGET_P8_VECTOR && !TARGET_VSX)
 {
-  if (rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR)
+  if ((rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR)
+ && (rs6000_isa_flags_explicit & OPTION_MASK_VSX))
error ("-mpower8-vector requires -mvsx");
-  rs6000_isa_flags &= ~OPTION_MASK_P8_VECTOR;
+  else if ((rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR) == 0)
+   {
+ rs6000_isa_flags &= ~OPTION_MASK_P8_VECTOR;
+ if (rs6000_isa_flags_explicit & OPTION_MASK_VSX)
+   rs6000_isa_flags_explicit |= OPTION_MASK_P8_VECTOR;
+   }
+  else
+   {
+ /* OPTION_MASK_P8_VECTOR is explicit, and OPTION_MASK_VSX is
+not explicit.  */
+ rs6000_isa_flags |= OPTION_MASK_VSX;
+ rs6000_isa_flags_explicit |= OPTION_MASK_VSX;
+   }
 }
 
   if (TARGET_VSX_TIMODE && !TARGET_VSX)
@@ -4448,9 +4461,22 @@ rs6000_option_override_internal (bool global_init_
 error messages.  However, if users have managed to select
 power9-vector without selecting power8-vector, they
 already know about undocumented flags.  */
-  if (rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR)
+  if ((rs6000_isa_flags_explicit & OPTION_MASK_P9_VECTOR) &&
+ (rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR))
error ("-mpower9-vector requires -mpower8-vector");
-  rs6000_isa_flags &= ~OPTION_MASK_P9_VECTOR;
+  else if ((rs6000_isa_flags_explicit & OPTION_MASK_P9_VECTOR) == 0)
+   {
+ rs6000_isa_flags &= ~OPTION_MASK_P9_VECTOR;
+ if (rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR)
+   rs6000_isa_flags_explicit |= OPTION_MASK_P9_VECTOR;
+   }
+  else
+   {
+ /* OPTION_MASK_P9_VECTOR is explicit and
+OPTION_MASK_P8_VECTOR is not explicit.  */
+ rs6000_isa_flags |= OPTION_MASK_P8_VECTOR;
+ rs6000_isa_flags_explicit |= OPTION_MASK_P8_VECTOR;
+   }
 }
 
   /* -mpower9-dform turns on both -mpower9-dform-scalar and
@@ -4479,10 +4505,25 @@ rs6000_option_override_internal (bool global_init_
 error messages.  However, if users have managed to select
 power9-dform without selecting power9-vector, they
 already know about undocumented flags.  */
-  if (rs6000_isa_flags_explicit & OPTION_MASK_P9_VECTOR)
+  if ((rs6000_isa_flags_explicit & OPTION_MASK_P9_VECTOR)
+ && (rs6000_isa_flags_explicit & (OPTION_MASK_P9_DFORM_SCALAR
+  | OPTION_MASK_P9_DFORM_VECTOR)))
error ("-mpower9-dform requires -mpower9-vector");
-  rs6000_isa_flags &= ~(OPTION_MASK_P9_DFORM_SCALAR
-   | OPTION_MASK_P9_DFORM_VECTOR);
+  else if (rs6000_isa_flags_explicit & OPTION_MASK_P9_VECTOR)
+   {
+ rs6000_isa_flags &=
+   ~(OPTION_MASK_P9_DFORM_SCALAR | OPTION_MASK_P9_DFORM_VECTOR);
+ rs6000_isa_flags_explicit |=
+   (OPTION_MASK_P9_DFORM_SCALAR | OPTION_MASK_P9_DFORM_VECTOR);
+   }
+  else
+   {
+ /* We know that OPTION_MASK_P9_VECTOR is not explicit and
+OPTION_MASK_P9_DFORM_SCALAR or OPTION_MASK_P9_DORM_VECTOR
+may be explicit.  */
+ rs6000_isa_flags |= OPTION_MASK_P9_VECTOR;
+ rs6000_isa_flags_explicit |= OPTION_MASK_P9_VECTOR;
+   }
 }
 
   if (TARGET_P9_DFORM_SCALAR && !TARGET_UPPER_REGS_DF)
Index: gcc/testsuite/gcc.target/powerpc/p9-options-1.c

Re: [PATCH] Decrease compile time memory with heavy find_base_{value,term} on i?86/x86_64 (PR rtl-optimization/63191, take 2)

2017-03-22 Thread Bernd Schmidt

On 03/22/2017 04:38 PM, Uros Bizjak wrote:


LGTM, but I don't want to step on Bernd's toes, so let's wait for his opinion.


I was waiting for yours really, that's the one that counts.


Bernd



[committed] Cherry-pick libtsan atomic fix (PR sanitizer/78158)

2017-03-22 Thread Jakub Jelinek
Hi!

I've committed the following cherry-pick of upstream change for tsan
atomics after bootstrapping/regtesting it on x86_64-linux and i686-linux.

2017-03-22  Jakub Jelinek  

PR sanitizer/78158
* tsan/tsan_interface_atomic.cc: Cherry-pick upstream r298378.

--- libsanitizer/tsan/tsan_interface_atomic.cc  (revision 298377)
+++ libsanitizer/tsan/tsan_interface_atomic.cc  (revision 298378)
@@ -448,10 +448,27 @@ static void AtomicFence(ThreadState *thr
 
 // C/C++
 
+static morder covert_morder(morder mo) {
+  if (flags()->force_seq_cst_atomics)
+return (morder)mo_seq_cst;
+
+  // Filter out additional memory order flags:
+  // MEMMODEL_SYNC= 1 << 15
+  // __ATOMIC_HLE_ACQUIRE = 1 << 16
+  // __ATOMIC_HLE_RELEASE = 1 << 17
+  //
+  // HLE is an optimization, and we pretend that elision always fails.
+  // MEMMODEL_SYNC is used when lowering __sync_ atomics,
+  // since we use __sync_ atomics for actual atomic operations,
+  // we can safely ignore it as well. It also subtly affects semantics,
+  // but we don't model the difference.
+  return (morder)(mo & 0x7fff);
+}
+
 #define SCOPED_ATOMIC(func, ...) \
 const uptr callpc = (uptr)__builtin_return_address(0); \
 uptr pc = StackTrace::GetCurrentPc(); \
-mo = flags()->force_seq_cst_atomics ? (morder)mo_seq_cst : mo; \
+mo = covert_morder(mo); \
 ThreadState *const thr = cur_thread(); \
 if (thr->ignore_interceptors) \
   return NoTsanAtomic##func(__VA_ARGS__); \

Jakub


[PATCH] Fix reassoc very large TU handlng (PR tree-optimization/80072)

2017-03-22 Thread Jakub Jelinek
Hi!

On the huge testcase from the PR (not really reduceable) we run into
reassoc ranks bigger than INT_MAX (bb_rank is multiples of 65536,
so it might be enough to have just 32768+ basic blocks to reach that).
Rank is unsigned int, but we were returning (int) (oeb->rank - oea->rank);
from the comparison function, which means when unlucky enough it could sort
entries with huge rank e.g. after entries with 0 rank.  Rest of reassoc
relies on the constants (rank 0) being sorted last though.

The patch also applies similar changes to other fields, that are far less
likely to be huge, but could be in theory.

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

2017-03-22  Jakub Jelinek  

PR tree-optimization/80072
* tree-ssa-reassoc.c (struct operand_entry): Change id field type
to unsigned int.
(next_operand_entry_id): Change type to unsigned int.
(sort_by_operand_rank): Make sure to return the right return value
even if unsigned fields are bigger than INT_MAX.
(struct oecount): Change cnt and id type to unsigned int.
(oecount_hasher::equal): Formatting fix.
(oecount_cmp): Make sure to return the right return value
even if unsigned fields are bigger than INT_MAX.
(undistribute_ops_list): Change next_oecount_id type to unsigned int.

--- gcc/tree-ssa-reassoc.c.jj   2017-02-10 09:46:50.0 +0100
+++ gcc/tree-ssa-reassoc.c  2017-03-22 13:57:00.476928949 +0100
@@ -193,7 +193,7 @@ static struct
 struct operand_entry
 {
   unsigned int rank;
-  int id;
+  unsigned int id;
   tree op;
   unsigned int count;
   gimple *stmt_to_insert;
@@ -204,7 +204,7 @@ static object_allocator o
 
 /* This is used to assign a unique ID to each struct operand_entry
so that qsort results are identical on different hosts.  */
-static int next_operand_entry_id;
+static unsigned int next_operand_entry_id;
 
 /* Starting rank number for a given basic block, so that we can rank
operations using unmovable instructions in that BB based on the bb
@@ -505,12 +505,12 @@ sort_by_operand_rank (const void *pa, co
   else
/* To make sorting result stable, we use unique IDs to determine
   order.  */
-return oeb->id - oea->id;
+   return oeb->id > oea->id ? 1 : -1;
 }
 
   /* Lastly, make sure the versions that are the same go next to each
  other.  */
-  if ((oeb->rank - oea->rank == 0)
+  if (oeb->rank == oea->rank
   && TREE_CODE (oea->op) == SSA_NAME
   && TREE_CODE (oeb->op) == SSA_NAME)
 {
@@ -543,15 +543,15 @@ sort_by_operand_rank (const void *pa, co
}
 
   if (SSA_NAME_VERSION (oeb->op) != SSA_NAME_VERSION (oea->op))
-   return SSA_NAME_VERSION (oeb->op) - SSA_NAME_VERSION (oea->op);
+   return SSA_NAME_VERSION (oeb->op) > SSA_NAME_VERSION (oea->op) ? 1 : -1;
   else
-   return oeb->id - oea->id;
+   return oeb->id > oea->id ? 1 : -1;
 }
 
   if (oeb->rank != oea->rank)
-return oeb->rank - oea->rank;
+return oeb->rank > oea->rank ? 1 : -1;
   else
-return oeb->id - oea->id;
+return oeb->id > oea->id ? 1 : -1;
 }
 
 /* Add an operand entry to *OPS for the tree operand OP.  */
@@ -1055,8 +1055,8 @@ static void linearize_expr_tree (vecoecode == c2->oecode
- && c1->op == c2->op);
+  return c1->oecode == c2->oecode && c1->op == c2->op;
 }
 
 /* Comparison function for qsort sorting oecount elements by count.  */
@@ -1102,10 +1101,10 @@ oecount_cmp (const void *p1, const void
   const oecount *c1 = (const oecount *)p1;
   const oecount *c2 = (const oecount *)p2;
   if (c1->cnt != c2->cnt)
-return c1->cnt - c2->cnt;
+return c1->cnt > c2->cnt ? 1 : -1;
   else
 /* If counts are identical, use unique IDs to stabilize qsort.  */
-return c1->id - c2->id;
+return c1->id > c2->id ? 1 : -1;
 }
 
 /* Return TRUE iff STMT represents a builtin call that raises OP
@@ -1559,7 +1558,7 @@ undistribute_ops_list (enum tree_code op
   sbitmap_iterator sbi0;
   vec *subops;
   bool changed = false;
-  int next_oecount_id = 0;
+  unsigned int next_oecount_id = 0;
 
   if (length <= 1
   || opcode != PLUS_EXPR)

Jakub


[committed] Fix OpenMP ICE with templates (PR c++/80141)

2017-03-22 Thread Jakub Jelinek
Hi!

As can be seen on the testcase, apparently it is a bad idea to call
maybe_constant_value when processing_template_decl, e.g. the 2 && 2
is at that point still 2 && 2 rather than true && true and constexpr
code is unhappy about that.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk so far.

2017-03-22  Jakub Jelinek  

PR c++/80141
* semantics.c (finish_omp_clause) : Call maybe_constant_value only when not
processing_template_decl.

* g++.dg/gomp/pr80141.C: New test.

--- gcc/cp/semantics.c.jj   2017-02-27 15:19:14.0 +0100
+++ gcc/cp/semantics.c  2017-03-22 15:46:34.003442833 +0100
@@ -6416,9 +6416,9 @@ finish_omp_clauses (tree clauses, enum c
  else
{
  t = mark_rvalue_use (t);
- t = maybe_constant_value (t);
  if (!processing_template_decl)
{
+ t = maybe_constant_value (t);
  if (TREE_CODE (t) != INTEGER_CST
  || tree_int_cst_sgn (t) != 1)
{
@@ -6586,9 +6586,9 @@ finish_omp_clauses (tree clauses, enum c
  else
{
  t = mark_rvalue_use (t);
- t = maybe_constant_value (t);
  if (!processing_template_decl)
{
+ t = maybe_constant_value (t);
  if (TREE_CODE (t) != INTEGER_CST
  || tree_int_cst_sgn (t) != 1)
{
--- gcc/testsuite/g++.dg/gomp/pr80141.C.jj  2017-03-22 17:37:52.445284214 
+0100
+++ gcc/testsuite/g++.dg/gomp/pr80141.C 2017-03-22 17:35:53.0 +0100
@@ -0,0 +1,8 @@
+// PR c++/80141
+// { dg-do compile }
+
+#pragma omp declare simd aligned (p : 2 && 2)
+template void foo (int *p);
+
+#pragma omp declare simd simdlen (2 && 2)
+template void bar (int *p);

Jakub


Go patch committed: initialize gogo fields

2017-03-22 Thread Ian Lance Taylor
A few of the Gogo data fields were not being initialized correctly,
causing Valgrind failures and possible confusion.  This patch by Than
McIntosh fixes the problem.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/go.cc
===
--- gcc/go/gofrontend/go.cc (revision 245745)
+++ gcc/go/gofrontend/go.cc (working copy)
@@ -34,10 +34,8 @@ go_create_gogo(const struct go_create_go
 
   if (args->relative_import_path != NULL)
 ::gogo->set_relative_import_path(args->relative_import_path);
-  if (args->check_divide_by_zero)
-::gogo->set_check_divide_by_zero(args->check_divide_by_zero);
-  if (args->check_divide_overflow)
-::gogo->set_check_divide_overflow(args->check_divide_overflow);
+  ::gogo->set_check_divide_by_zero(args->check_divide_by_zero);
+  ::gogo->set_check_divide_overflow(args->check_divide_overflow);
   if (args->compiling_runtime)
 ::gogo->set_compiling_runtime(args->compiling_runtime);
   if (args->c_header != NULL)
Index: gcc/go/gofrontend/gogo.cc
===
--- gcc/go/gofrontend/gogo.cc   (revision 245745)
+++ gcc/go/gofrontend/gogo.cc   (working copy)
@@ -50,6 +50,11 @@ Gogo::Gogo(Backend* backend, Linemap* li
 pkgpath_from_option_(false),
 prefix_from_option_(false),
 relative_import_path_(),
+c_header_(),
+check_divide_by_zero_(true),
+check_divide_overflow_(true),
+compiling_runtime_(false),
+debug_escape_level_(0),
 verify_types_(),
 interface_types_(),
 specific_type_functions_(),


Re: [PATCH] Fix reassoc very large TU handlng (PR tree-optimization/80072)

2017-03-22 Thread Richard Biener
On March 22, 2017 7:52:40 PM GMT+01:00, Jakub Jelinek  wrote:
>Hi!
>
>On the huge testcase from the PR (not really reduceable) we run into
>reassoc ranks bigger than INT_MAX (bb_rank is multiples of 65536,
>so it might be enough to have just 32768+ basic blocks to reach that).
>Rank is unsigned int, but we were returning (int) (oeb->rank -
>oea->rank);
>from the comparison function, which means when unlucky enough it could
>sort
>entries with huge rank e.g. after entries with 0 rank.  Rest of reassoc
>relies on the constants (rank 0) being sorted last though.
>
>The patch also applies similar changes to other fields, that are far
>less
>likely to be huge, but could be in theory.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Richard.

>2017-03-22  Jakub Jelinek  
>
>   PR tree-optimization/80072
>   * tree-ssa-reassoc.c (struct operand_entry): Change id field type
>   to unsigned int.
>   (next_operand_entry_id): Change type to unsigned int.
>   (sort_by_operand_rank): Make sure to return the right return value
>   even if unsigned fields are bigger than INT_MAX.
>   (struct oecount): Change cnt and id type to unsigned int.
>   (oecount_hasher::equal): Formatting fix.
>   (oecount_cmp): Make sure to return the right return value
>   even if unsigned fields are bigger than INT_MAX.
>   (undistribute_ops_list): Change next_oecount_id type to unsigned int.
>
>--- gcc/tree-ssa-reassoc.c.jj  2017-02-10 09:46:50.0 +0100
>+++ gcc/tree-ssa-reassoc.c 2017-03-22 13:57:00.476928949 +0100
>@@ -193,7 +193,7 @@ static struct
> struct operand_entry
> {
>   unsigned int rank;
>-  int id;
>+  unsigned int id;
>   tree op;
>   unsigned int count;
>   gimple *stmt_to_insert;
>@@ -204,7 +204,7 @@ static object_allocator o
> 
> /* This is used to assign a unique ID to each struct operand_entry
>so that qsort results are identical on different hosts.  */
>-static int next_operand_entry_id;
>+static unsigned int next_operand_entry_id;
> 
> /* Starting rank number for a given basic block, so that we can rank
>operations using unmovable instructions in that BB based on the bb
>@@ -505,12 +505,12 @@ sort_by_operand_rank (const void *pa, co
>   else
>   /* To make sorting result stable, we use unique IDs to determine
>  order.  */
>-return oeb->id - oea->id;
>+  return oeb->id > oea->id ? 1 : -1;
> }
> 
>   /* Lastly, make sure the versions that are the same go next to each
>  other.  */
>-  if ((oeb->rank - oea->rank == 0)
>+  if (oeb->rank == oea->rank
>   && TREE_CODE (oea->op) == SSA_NAME
>   && TREE_CODE (oeb->op) == SSA_NAME)
> {
>@@ -543,15 +543,15 @@ sort_by_operand_rank (const void *pa, co
>   }
> 
>   if (SSA_NAME_VERSION (oeb->op) != SSA_NAME_VERSION (oea->op))
>-  return SSA_NAME_VERSION (oeb->op) - SSA_NAME_VERSION (oea->op);
>+  return SSA_NAME_VERSION (oeb->op) > SSA_NAME_VERSION (oea->op) ? 1 :
>-1;
>   else
>-  return oeb->id - oea->id;
>+  return oeb->id > oea->id ? 1 : -1;
> }
> 
>   if (oeb->rank != oea->rank)
>-return oeb->rank - oea->rank;
>+return oeb->rank > oea->rank ? 1 : -1;
>   else
>-return oeb->id - oea->id;
>+return oeb->id > oea->id ? 1 : -1;
> }
> 
> /* Add an operand entry to *OPS for the tree operand OP.  */
>@@ -1055,8 +1055,8 @@ static void linearize_expr_tree (vec 
> /* Structure for tracking and counting operands.  */
> struct oecount {
>-  int cnt;
>-  int id;
>+  unsigned int cnt;
>+  unsigned int id;
>   enum tree_code oecode;
>   tree op;
> };
>@@ -1090,8 +1090,7 @@ oecount_hasher::equal (int p1, int p2)
> {
>   const oecount *c1 = &cvec[p1 - 42];
>   const oecount *c2 = &cvec[p2 - 42];
>-  return (c1->oecode == c2->oecode
>-&& c1->op == c2->op);
>+  return c1->oecode == c2->oecode && c1->op == c2->op;
> }
> 
>/* Comparison function for qsort sorting oecount elements by count.  */
>@@ -1102,10 +1101,10 @@ oecount_cmp (const void *p1, const void
>   const oecount *c1 = (const oecount *)p1;
>   const oecount *c2 = (const oecount *)p2;
>   if (c1->cnt != c2->cnt)
>-return c1->cnt - c2->cnt;
>+return c1->cnt > c2->cnt ? 1 : -1;
>   else
> /* If counts are identical, use unique IDs to stabilize qsort.  */
>-return c1->id - c2->id;
>+return c1->id > c2->id ? 1 : -1;
> }
> 
> /* Return TRUE iff STMT represents a builtin call that raises OP
>@@ -1559,7 +1558,7 @@ undistribute_ops_list (enum tree_code op
>   sbitmap_iterator sbi0;
>   vec *subops;
>   bool changed = false;
>-  int next_oecount_id = 0;
>+  unsigned int next_oecount_id = 0;
> 
>   if (length <= 1
>   || opcode != PLUS_EXPR)
>
>   Jakub



Re: [wwwdocs] gcc-8/porting_to.html

2017-03-22 Thread JonY
On 03/22/2017 05:39 PM, Thomas Preudhomme wrote:
> Hi JonY,
> 
> Sorry for the delay. Please find updated patch as per Gerald and you
> suggestion.
> 
> Is this ok for wwwdocs once [1] is committed in GCC 8 cycle?
> 
> [1] https://gcc.gnu.org/ml/gcc-patches/2017-02/msg01153.html
> 
> Best regards,
> 
> Thomas

Looks good to me, thanks.






signature.asc
Description: OpenPGP digital signature


Re: [PATCH,rs6000] Handle conflicting target options -mno-power9-vector and -mcpu=power9

2017-03-22 Thread Segher Boessenkool
On Wed, Mar 22, 2017 at 11:44:49AM -0600, Kelvin Nilsen wrote:
> Internal testing recently revealed that use of the -mno-power9-vector
> target option in combination with the -mcpu=power9 target option
> results in termination of gcc with the error message:
> 
>   power9-dform requires power9-vector

> In both cases, the preferred behavior is that the target option
> -mno-power9-vector causes power9-dform to be automatically disabled.
>  This patch implements the preferred behavior and adds a test case to
> demonstrate the fix.

Or it could do -mpower9-dform-scalar but disable -mpower9-dform-vector?
That seems more reasonable.

Ideally none of the -mpower9-dform* or -mpower9-vector options would
exist at all, of course.

> 2017-03-21  Kelvin Nilsen  
> 
>   * config/rs6000/rs6000.c (rs6000_option_override_internal): Change
>   handling of certain combinations of target options, including the
>   combinations -mpower8-vector vs. -mno-vsx, -mpower8-vector vs.
>   -mno-power8-vector, and -mpower9_dform vs. -mno-power9-vector.

Those other changes are independent?


Segher


Re: [PATCH] internal/syscall/unix: fix syscalls for m68k

2017-03-22 Thread Ian Lance Taylor
On Wed, Mar 22, 2017 at 6:17 AM, Andreas Schwab  wrote:
> ---
>  libgo/go/internal/syscall/unix/getrandom_linux_m68k.go | 9 +
>  1 file changed, 9 insertions(+)
>  create mode 100644 libgo/go/internal/syscall/unix/getrandom_linux_m68k.go
>
> diff --git a/libgo/go/internal/syscall/unix/getrandom_linux_m68k.go 
> b/libgo/go/internal/syscall/unix/getrandom_linux_m68k.go
> new file mode 100644
> index 00..5559d30d33
> --- /dev/null
> +++ b/libgo/go/internal/syscall/unix/getrandom_linux_m68k.go
> @@ -0,0 +1,9 @@
> +// Copyright 2017 The Go Authors. All rights reserved.
> +// Use of this source code is governed by a BSD-style
> +// license that can be found in the LICENSE file.
> +
> +package unix
> +
> +// Linux getrandom system call number.
> +// See GetRandom in getrandom_linux.go.
> +const randomTrap uintptr = 352

Thanks.  Committed to mainline.

Ian


Re: [PATCH,rs6000] Handle conflicting target options -mno-power9-vector and -mcpu=power9

2017-03-22 Thread Kelvin Nilsen


On 03/22/2017 05:35 PM, Segher Boessenkool wrote:
> On Wed, Mar 22, 2017 at 11:44:49AM -0600, Kelvin Nilsen wrote:
>> Internal testing recently revealed that use of the -mno-power9-vector
>> target option in combination with the -mcpu=power9 target option
>> results in termination of gcc with the error message:
>>
>>   power9-dform requires power9-vector
> 
>> In both cases, the preferred behavior is that the target option
>> -mno-power9-vector causes power9-dform to be automatically disabled.
>>  This patch implements the preferred behavior and adds a test case to
>> demonstrate the fix.
> 
> Or it could do -mpower9-dform-scalar but disable -mpower9-dform-vector?
> That seems more reasonable.

The internal problem report sent to me said "-mno-power9-vector should
override power9-dform unless the latter has been deliberately specified
by the user."  I'm just following orders.  If you think it preferable to
only override -mpower-dform-vector, I'll make that modification.

> 
> Ideally none of the -mpower9-dform* or -mpower9-vector options would
> exist at all, of course.
> 
>> 2017-03-21  Kelvin Nilsen  
>>
>>  * config/rs6000/rs6000.c (rs6000_option_override_internal): Change
>>  handling of certain combinations of target options, including the
>>  combinations -mpower8-vector vs. -mno-vsx, -mpower8-vector vs.
>>  -mno-power8-vector, and -mpower9_dform vs. -mno-power9-vector.
> 
> Those other changes are independent?

Actually, these other changes are not independent.  My initial attempt
at a patch only changed the behavior of -mpower9_dform vs.
-mno-power9-vector.  But this actually resulted in a regression of an
existing test.  To "properly" handle the new case without impacting
existing "established" behavior (as represented in the existing dejagnu
testsuite), I had to make these other changes as well.


> 
> 
> Segher
> 
> 

-- 
Kelvin Nilsen, Ph.D.  kdnil...@linux.vnet.ibm.com
home office: 801-756-4821, cell: 520-991-6727
IBM Linux Technology Center - PPC Toolchain



Re: [PATCH,rs6000] Handle conflicting target options -mno-power9-vector and -mcpu=power9

2017-03-22 Thread Segher Boessenkool
On Wed, Mar 22, 2017 at 05:55:53PM -0600, Kelvin Nilsen wrote:
> > Or it could do -mpower9-dform-scalar but disable -mpower9-dform-vector?
> > That seems more reasonable.
> 
> The internal problem report sent to me said "-mno-power9-vector should
> override power9-dform unless the latter has been deliberately specified
> by the user."  I'm just following orders.

Heh :-)

> If you think it preferable to
> only override -mpower-dform-vector, I'll make that modification.

It is more logical.  Or so I though.  But as it turns out,
-mpower9-dform-scalar is about vector registers as well.

So the patch is approved for trunk as-is.  Thanks!

> >>* config/rs6000/rs6000.c (rs6000_option_override_internal): Change
> >>handling of certain combinations of target options, including the
> >>combinations -mpower8-vector vs. -mno-vsx, -mpower8-vector vs.
> >>-mno-power8-vector, and -mpower9_dform vs. -mno-power9-vector.
> > 
> > Those other changes are independent?
> 
> Actually, these other changes are not independent.  My initial attempt
> at a patch only changed the behavior of -mpower9_dform vs.
> -mno-power9-vector.  But this actually resulted in a regression of an
> existing test.  To "properly" handle the new case without impacting
> existing "established" behavior (as represented in the existing dejagnu
> testsuite), I had to make these other changes as well.

Too many options :-(


Segher


Re: [wwwdocs] gcc-8/porting_to.html

2017-03-22 Thread Gerald Pfeifer

Hi Thomas,

On Wed, 22 Mar 2017, Thomas Preudhomme wrote:

Is this ok for wwwdocs once [1] is committed in GCC 8 cycle?


+ GCC on Microsoft Windows can now be configured via
+   --enable-mingw-wildcard or
+   --disable-mingw-wildcard to force a specific behavior for
+   GCC itself with regards to supporting or not the wildcard character.

Here I would omit the "or not" which I believe does not work well
in English.

+   Prior versions of GCC would follow the configuration of MinGW runtime.

And here add "the" before "MinGW".

This looks fine to me with these two minor changes, thank you.

Gerald