Re: [PATCH] RX: Add rx-*-linux target

2019-06-02 Thread Yoshinori Sato
On Fri, 31 May 2019 09:16:18 +0900,
Jeff Law wrote:
> 
> On 5/29/19 12:27 PM, Jeff Law wrote:
> > On 5/23/19 6:05 AM, Yoshinori Sato wrote:
> >> I ported linux kernel to Renesas RX.
> >>
> >> rx-*-elf target output a binary different from the standard ELF.
> >> It has the same format as the Renesas compiler.
> >>
> >> But the linux kernel requires the standard ELF format.
> >> I want to define a rx-*-linux target so that I can generate
> >> a standard ELF binary.
> > Presumably you're resubmitting after your assignment got recorded (I
> > think I saw that fly by recently).
> > 
> > I'll construct a ChangeLog and install this on the trunk.
> So this is causing libgcc to fail to build for rx-elf.  The problem is
> the DF=SF #define.  I think you need so split that out so that it's only
> used for rx-linux.
> 
> Jeff

OK. fix it.
I tried build rx-elf target. it success.

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 7122c8ed1c8..b547ab1d1cb 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2799,6 +2799,11 @@ rl78-*-elf*)
 rx-*-elf*)
tm_file="dbxelf.h elfos.h newlib-stdint.h ${tm_file}"
tmake_file="${tmake_file} rx/t-rx"
+   extra_options="${extra_options} rx/elf.opt"
+   ;;
+rx-*-linux*)
+   tm_file="elfos.h linux.h glibc-stdint.h rx/linux.h 
../../libgcc/config/rx/rx-abi.h"
+   tmake_file="${tmake_file} rx/t-linux"
;;
 s390-*-linux*)
tm_file="s390/s390.h dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h 
s390/linux.h"
diff --git a/gcc/config/rx/elf.opt b/gcc/config/rx/elf.opt
new file mode 100644
index 000..907e030df8e
--- /dev/null
+++ b/gcc/config/rx/elf.opt
@@ -0,0 +1,44 @@
+; Command line options for the Renesas RX port of GCC.
+; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+; Contributed by Red Hat.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; .
+;---
+
+; elf target extra options
+
+msim
+Target
+Use the simulator runtime.
+
+;---
+
+mas100-syntax
+Target Mask(AS100_SYNTAX) Report
+Generate assembler output that is compatible with the Renesas AS100 assembler. 
 This may restrict some of the compiler's capabilities.  The default is to 
generate GAS compatable syntax.
+
+;---
+
+mint-register=
+Target RejectNegative Joined UInteger Var(rx_interrupt_registers) Init(0)
+Specifies the number of registers to reserve for interrupt handlers.
+
+;---
+
+msave-acc-in-interrupts
+Target Mask(SAVE_ACC_REGISTER)
+Specifies whether interrupt functions should save and restore the accumulator 
register.
diff --git a/gcc/config/rx/linux.h b/gcc/config/rx/linux.h
new file mode 100644
index 000..df3fdd41092
--- /dev/null
+++ b/gcc/config/rx/linux.h
@@ -0,0 +1,231 @@
+/* GCC backend definitions for the rx-linux
+   Copyright (C) 2019 Yoshinori Sato
+   Based on rx.h
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   .  */
+
+
+#include "config/rx/rx.h"
+
+#undef TARGET_CPU_CPP_BUILTINS
+#define TARGET_CPU_CPP_BUILTINS()   \
+  do\
+{   \
+  builtin_define ("__RX__");   \
+  builtin_assert ("cpu=RX");   \
+  if (rx_cpu_type == RX610)\
+builtin_assert ("machine=RX610");  \
+ else  \
+builtin_assert ("machine=RX600");  \
+   \
+  if (TARGET_BIG_ENDIAN_DATA)  \
+   builtin_define ("__RX_BIG_ENDIAN__");   \
+  else

New Swedish PO file for 'gcc' (version 9.1.0)

2019-06-02 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.

A revised PO file for textual domain 'gcc' has been submitted
by the Swedish team of translators.  The file is available at:

https://translationproject.org/latest/gcc/sv.po

(This file, 'gcc-9.1.0.sv.po', has just now been sent to you in
a separate email.)

All other PO files for your package are available in:

https://translationproject.org/latest/gcc/

Please consider including all of these in your next release, whether
official or a pretest.

Whenever you have a new distribution with a new version number ready,
containing a newer POT file, please send the URL of that distribution
tarball to the address below.  The tarball may be just a pretest or a
snapshot, it does not even have to compile.  It is just used by the
translators when they need some extra translation context.

The following HTML page has been updated:

https://translationproject.org/domain/gcc.html

If any question arises, please contact the translation coordinator.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.




Re: [PATCH] RX: Add rx-*-linux target

2019-06-02 Thread Oleg Endo
On Sun, 2019-06-02 at 20:26 +0900, Yoshinori Sato wrote:
> On Fri, 31 May 2019 09:16:18 +0900,
> Jeff Law wrote:
> > 
> > On 5/29/19 12:27 PM, Jeff Law wrote:
> > > On 5/23/19 6:05 AM, Yoshinori Sato wrote:
> > > > I ported linux kernel to Renesas RX.
> > > > 
> > > > rx-*-elf target output a binary different from the standard
> > > > ELF.
> > > > It has the same format as the Renesas compiler.
> > > > 
> > > > But the linux kernel requires the standard ELF format.
> > > > I want to define a rx-*-linux target so that I can generate
> > > > a standard ELF binary.
> > > 
> > > Presumably you're resubmitting after your assignment got recorded
> > > (I
> > > think I saw that fly by recently).
> > > 
> > > I'll construct a ChangeLog and install this on the trunk.
> > 
> > So this is causing libgcc to fail to build for rx-elf.  The problem
> > is
> > the DF=SF #define.  I think you need so split that out so that it's
> > only
> > used for rx-linux.
> > 
> > Jeff
> 
> OK. fix it.
> I tried build rx-elf target. it success.
> 

Setting DF=SF is the wrong thing to do IMHO.  RX can do DF just fine in
software.  If this is hardcoded like that in the roots of the
toolchain, it will make compiling packages that actually need real DF
completely impossible, won't it?  We also don't set DI = SI just
because the hardware is bad at SI ... 

Just my 2 cents.

Cheers,
Oleg



[patch, fortran] Two tweaks to argument repacking

2019-06-02 Thread Thomas Koenig

Hello world,

this patch adds two tweaks to the argument repacking.

First, when the size of an argument is known to be one, as in a(n1:n1),
we can directly pass a pointer - the stride may not be one, but it
does not matter.

Second, the case where the array passed is actually contiguous is
more likely in practice, so it should get the fast path. I have
done this by defining a new predictor and setting the estimated
likelyhood at 75%, which ensured a path without jumps when the
arguments passed to bar were contiguous:

module y
contains
  subroutine bar(a,b)
real, dimension(:) :: a,b
call foo(a,b,size(a))
  end subroutine bar
end module y

Test case is only for the first part - making one for the second
part would have been a bit too much.

Regression-tested. OK for trunk?

Regards

Thomas

2019-06-02  Thomas Koenig  

PR fortran/90539
* trans-expr.c (gfc_conv_subref_array_arg): If the size of the
expression can be determined to be one, treat it as contiguous.
Set likelyhood of presence of an actual argument according to
PRED_FORTRAN_ABSENT_DUMMY and likelyhood of being contiguous
according to PRED_FORTRAN_CONTIGUOUS.

2019-06-02  Thomas Koenig  

PR fortran/90539
* predict.def (PRED_FORTRAN_CONTIGUOUS): New predictor.
Index: fortran/trans-expr.c
===
--- fortran/trans-expr.c	(Revision 271751)
+++ fortran/trans-expr.c	(Arbeitskopie)
@@ -4922,16 +4922,36 @@ class_array_fcn:
 	  gfc_se cont_se, array_se;
 	  stmtblock_t if_block, else_block;
 	  tree if_stmt, else_stmt;
+	  mpz_t size;
+	  bool size_set;
 
 	  cont_var = gfc_create_var (boolean_type_node, "contiguous");
 
-	  /* cont_var = is_contiguous (expr); .  */
-	  gfc_init_se (&cont_se, parmse);
-	  gfc_conv_is_contiguous_expr (&cont_se, expr);
-	  gfc_add_block_to_block (&se->pre, &(&cont_se)->pre);
-	  gfc_add_modify (&se->pre, cont_var, cont_se.expr);
-	  gfc_add_block_to_block (&se->pre, &(&cont_se)->post);
+	  /* If the size is known to be one at compile-time, set
+	 cont_var to true unconditionally.  This may look
+	 inelegant, but we're only doing this during
+	 optimization, so the statements will be optimized away,
+	 and this saves complexity here.  */
 
+	  size_set = gfc_array_size (expr, &size);
+	  if (size_set && mpz_cmp_ui (size, 1) == 0)
+	{
+	  gfc_add_modify (&se->pre, cont_var,
+			  build_one_cst (boolean_type_node));
+	}
+	  else
+	{
+	  /* cont_var = is_contiguous (expr); .  */
+	  gfc_init_se (&cont_se, parmse);
+	  gfc_conv_is_contiguous_expr (&cont_se, expr);
+	  gfc_add_block_to_block (&se->pre, &(&cont_se)->pre);
+	  gfc_add_modify (&se->pre, cont_var, cont_se.expr);
+	  gfc_add_block_to_block (&se->pre, &(&cont_se)->post);
+	}
+
+	  if (size_set)
+	mpz_clear (size);
+
 	  /* arrayse->expr = descriptor of a.  */
 	  gfc_init_se (&array_se, se);
 	  gfc_conv_expr_descriptor (&array_se, expr);
@@ -4953,7 +4973,9 @@ class_array_fcn:
 
 	  /* And put the above into an if statement.  */
 	  pre_stmts = fold_build3_loc (input_location, COND_EXPR, void_type_node,
-  cont_var, if_stmt, else_stmt);
+   gfc_likely (cont_var,
+		   PRED_FORTRAN_CONTIGUOUS),
+   if_stmt, else_stmt);
 	}
   else
 	{
@@ -4976,11 +4998,11 @@ class_array_fcn:
 	  gfc_add_modify (&else_block, pointer, build_int_cst (type, 0));
 	  else_stmt = gfc_finish_block (&else_block);
 
-	  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, present_var,
+	  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ gfc_likely (present_var,
+	 PRED_FORTRAN_ABSENT_DUMMY),
  pre_stmts, else_stmt);
 	  gfc_add_expr_to_block (&se->pre, tmp);
-
-
 	}
   else
 	gfc_add_expr_to_block (&se->pre, pre_stmts);
@@ -4995,9 +5017,16 @@ class_array_fcn:
 	  tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
  cont_var,
  build_zero_cst (boolean_type_node));
+	  tmp = gfc_unlikely (tmp, PRED_FORTRAN_CONTIGUOUS);
+
 	  if (pass_optional)
-	post_cond = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
-	 boolean_type_node, present_var, tmp);
+	{
+	  tree present_likely = gfc_likely (present_var,
+		PRED_FORTRAN_ABSENT_DUMMY);
+	  post_cond = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
+	   boolean_type_node, present_likely,
+	   tmp);
+	}
 	  else
 	post_cond = tmp;
 	}
Index: predict.def
===
--- predict.def	(Revision 271629)
+++ predict.def	(Arbeitskopie)
@@ -229,3 +229,10 @@ DEF_PREDICTOR (PRED_FORTRAN_ABSENT_DUMMY, "Fortran
to be very likely.  */
 DEF_PREDICTOR (PRED_FORTRAN_LOOP_PREHEADER, "Fortran loop preheader", \
 	   HITRATE (99), 0)
+
+/* Fortran assumed size arrays can be non-contiguous, so they need
+   to be repacked.  */
+
+DEF_PREDICTOR (PRED_FORTR

Re: [patch, fortran] Two tweaks to argument repacking

2019-06-02 Thread Paul Richard Thomas
Hi Thomas,

It looks good to me. OK for trunk.

Thanks

Paul

On Sun, 2 Jun 2019 at 14:34, Thomas Koenig  wrote:
>
> Hello world,
>
> this patch adds two tweaks to the argument repacking.
>
> First, when the size of an argument is known to be one, as in a(n1:n1),
> we can directly pass a pointer - the stride may not be one, but it
> does not matter.
>
> Second, the case where the array passed is actually contiguous is
> more likely in practice, so it should get the fast path. I have
> done this by defining a new predictor and setting the estimated
> likelyhood at 75%, which ensured a path without jumps when the
> arguments passed to bar were contiguous:
>
> module y
> contains
>subroutine bar(a,b)
>  real, dimension(:) :: a,b
>  call foo(a,b,size(a))
>end subroutine bar
> end module y
>
> Test case is only for the first part - making one for the second
> part would have been a bit too much.
>
> Regression-tested. OK for trunk?
>
> Regards
>
> Thomas
>
> 2019-06-02  Thomas Koenig  
>
> PR fortran/90539
> * trans-expr.c (gfc_conv_subref_array_arg): If the size of the
> expression can be determined to be one, treat it as contiguous.
> Set likelyhood of presence of an actual argument according to
> PRED_FORTRAN_ABSENT_DUMMY and likelyhood of being contiguous
> according to PRED_FORTRAN_CONTIGUOUS.
>
> 2019-06-02  Thomas Koenig  
>
> PR fortran/90539
> * predict.def (PRED_FORTRAN_CONTIGUOUS): New predictor.



-- 
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein


Re: [PATCH] RX: Add rx-*-linux target

2019-06-02 Thread Segher Boessenkool
On Sun, Jun 02, 2019 at 10:12:37PM +0900, Oleg Endo wrote:
> On Sun, 2019-06-02 at 20:26 +0900, Yoshinori Sato wrote:
> > On Fri, 31 May 2019 09:16:18 +0900,
> > Jeff Law wrote:
> > > 
> > > On 5/29/19 12:27 PM, Jeff Law wrote:
> > > > On 5/23/19 6:05 AM, Yoshinori Sato wrote:
> > > > > I ported linux kernel to Renesas RX.
> > > > > 
> > > > > rx-*-elf target output a binary different from the standard
> > > > > ELF.
> > > > > It has the same format as the Renesas compiler.
> > > > > 
> > > > > But the linux kernel requires the standard ELF format.
> > > > > I want to define a rx-*-linux target so that I can generate
> > > > > a standard ELF binary.
> > > > 
> > > > Presumably you're resubmitting after your assignment got recorded
> > > > (I
> > > > think I saw that fly by recently).
> > > > 
> > > > I'll construct a ChangeLog and install this on the trunk.
> > > 
> > > So this is causing libgcc to fail to build for rx-elf.  The problem
> > > is
> > > the DF=SF #define.  I think you need so split that out so that it's
> > > only
> > > used for rx-linux.
> > > 
> > > Jeff
> > 
> > OK. fix it.
> > I tried build rx-elf target. it success.
> > 
> 
> Setting DF=SF is the wrong thing to do IMHO.  RX can do DF just fine in
> software.  If this is hardcoded like that in the roots of the
> toolchain, it will make compiling packages that actually need real DF
> completely impossible, won't it?  We also don't set DI = SI just
> because the hardware is bad at SI ... 

This is -m64bit-doubles/-m32bit-doubles, and t-rx already multilibs that?
And the default is 32-bit.  So why does rx-linux need something different?
You could make a point for wanting 64-bit doubles as default, even;
disabling it completely does not seem like a good plan.

(This patch seems to have broken rx-elf btw?)


Segher


Re: [PATCH] Clean up non-conforming names

2019-06-02 Thread Thomas Rodgers


Jonathan Wakely writes:

> On 31/05/19 17:15 -0700, Thomas Rodgers wrote:
>>
>>Revising previous version of this patch to pick another missed
>>uglification.
>
> OK for trunk, thanks.
>
> I also see this one:
>
> include/pstl/parallel_backend_tbb.h:__buffer(std::size_t n) : 
> _M_allocator(), _M_ptr(_M_allocator.allocate(n)), _M_buf_size(n) {}

Ok, I'll clean that one up and commit along with these changes.


Re: [PATCH] rs6000: Add undocumented switch -mprefixed-addr

2019-06-02 Thread Segher Boessenkool
On Thu, May 30, 2019 at 12:01:45PM -0400, Michael Meissner wrote:
> On Wed, May 29, 2019 at 03:26:27PM -0500, Bill Schmidt wrote:
> > On 5/29/19 8:16 AM, Segher Boessenkool wrote:
> > >> +/* ISA masks setting fusion options.  */
> > >> +#define OTHER_FUSION_MASKS  (OPTION_MASK_P8_FUSION  
> > >> \
> > >> + | OPTION_MASK_P8_FUSION_SIGN)
> > > Or merge the two masks into one?
> > 
> > I'll ask Mike to explain this, as I don't know why there are two masks.
> 
> The intention is to allow for using the numeric prefixed instructions without
> pc-relative.  I.e.

[ snip ]

I was suggesting merging these two P8_FUSION{,_SIGN} into one.  But, we'll
get to that some day, it doesn't have to be now.

> > >> @@ -36379,6 +36391,7 @@ static struct rs6000_opt_mask const 
> > >> rs6000_opt_masks[] =
> > >>{ "power9-vector",OPTION_MASK_P9_VECTOR,  false, 
> > >> true  },
> > >>{ "powerpc-gfxopt",   OPTION_MASK_PPC_GFXOPT, false, 
> > >> true  },
> > >>{ "powerpc-gpopt",OPTION_MASK_PPC_GPOPT,  false, 
> > >> true  },
> > >> +  { "prefixed-addr",OPTION_MASK_PREFIXED_ADDR,  false, 
> > >> true  },
> > > Do we want this?  Why?
> > 
> > Performance folks are using it for testing purposes.  Eventually this
> > will probably drop out, but for now I think it's best to have the
> > undocumented switch.
> 
> I use that table with -mdebug=reg so I can make sure exactly what options are
> on or off.  Please add any undocumented switch to the table.

It's not very nice to have to edit everything in two completely separate
places like this.


Segher


[PATCH] parisc: Use lpa instruction to load physical addresses in driver code

2019-06-02 Thread John David Anglin
Most I/O in the kernel is done using the kernel offset mapping.  However, there
is one API that uses aliased kernel address ranges:

> The final category of APIs is for I/O to deliberately aliased address
> ranges inside the kernel.  Such aliases are set up by use of the
> vmap/vmalloc API.  Since kernel I/O goes via physical pages, the I/O
> subsystem assumes that the user mapping and kernel offset mapping are
> the only aliases.  This isn't true for vmap aliases, so anything in
> the kernel trying to do I/O to vmap areas must manually manage
> coherency.  It must do this by flushing the vmap range before doing
> I/O and invalidating it after the I/O returns.

For this reason, we should use the hardware lpa instruction to load the 
physical address
of kernel virtual addresses in the driver code.

I believe we only use the vmap/vmalloc API with old PA 1.x processors which 
don't have
a sba, so we don't hit this problem.

Tested on c3750, c8000 and rp3440.

This patch includes the previous change to use implicit space register access 
in loading
the coherence index as the two changes conflict.

Signed-off-by: John David Anglin 
---

diff --git a/arch/parisc/include/asm/special_insns.h 
b/arch/parisc/include/asm/special_insns.h
index 3d4dd68e181b..a303ae9a77f4 100644
--- a/arch/parisc/include/asm/special_insns.h
+++ b/arch/parisc/include/asm/special_insns.h
@@ -2,6 +2,30 @@
 #ifndef __PARISC_SPECIAL_INSNS_H
 #define __PARISC_SPECIAL_INSNS_H

+#define lpa(va)({  \
+   unsigned long pa;   \
+   __asm__ __volatile__(   \
+   "copy %%r0,%0\n\t"  \
+   "lpa %%r0(%1),%0"   \
+   : "=r" (pa) \
+   : "r" (va)  \
+   : "memory"  \
+   );  \
+   pa; \
+})
+
+#define lpa_user(va)   ({  \
+   unsigned long pa;   \
+   __asm__ __volatile__(   \
+   "copy %%r0,%0\n\t"  \
+   "lpa %%r0(%%sr3,%1),%0" \
+   : "=r" (pa) \
+   : "r" (va)  \
+   : "memory"  \
+   );  \
+   pa; \
+})
+
 #define mfctl(reg) ({  \
unsigned long cr;   \
__asm__ __volatile__(   \
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 121f7603a595..217f15aafa4a 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -562,14 +562,12 @@ ccio_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned 
long vba,
/* We currently only support kernel addresses */
BUG_ON(sid != KERNEL_SPACE);

-   mtsp(sid,1);
-
/*
** WORD 1 - low order word
** "hints" parm includes the VALID bit!
** "dep" clobbers the physical address offset bits as well.
*/
-   pa = virt_to_phys(vba);
+   pa = lpa(vba);
asm volatile("depw  %1,31,12,%0" : "+r" (pa) : "r" (hints));
((u32 *)pdir_ptr)[1] = (u32) pa;

@@ -594,7 +592,7 @@ ccio_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned 
long vba,
** Grab virtual index [0:11]
** Deposit virt_idx bits into I/O PDIR word
*/
-   asm volatile ("lci %%r0(%%sr1, %1), %0" : "=r" (ci) : "r" (vba));
+   asm volatile ("lci %%r0(%1), %0" : "=r" (ci) : "r" (vba));
asm volatile ("extru %1,19,12,%0" : "+r" (ci) : "r" (ci));
asm volatile ("depw  %1,15,12,%0" : "+r" (pa) : "r" (ci));

diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index 8a9ea9bd050c..296668caf7e5 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -569,11 +569,10 @@ sba_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned 
long vba,
u64 pa; /* physical address */
register unsigned ci; /* coherent index */

-   pa = virt_to_phys(vba);
+   pa = lpa(vba);
pa &= IOVP_MASK;

-   mtsp(sid,1);
-   asm("lci 0(%%sr1, %1), %0" : "=r" (ci) : "r" (vba));
+   asm("lci 0(%1), %0" : "=r" (ci) : "r" (vba));
pa |= (ci >> PAGE_SHIFT) & 0xff;  /* move CI (8 bits) into lowest byte 
*/

pa |= SBA_PDIR_VALID_BIT;   /* set "valid" bit */


Re: [Contrib PATCH] Add scripts to convert GCC repo from SVN to Git

2019-06-02 Thread Segher Boessenkool
On Fri, May 31, 2019 at 12:05:41AM +, Joseph Myers wrote:
> On Wed, 29 May 2019, Segher Boessenkool wrote:
> 
> > On Wed, May 29, 2019 at 12:53:30AM +, Joseph Myers wrote:
> > > On Fri, 24 May 2019, Segher Boessenkool wrote:
> > > 
> > > > IMO the best we can do is use what we already have: what CVS or SVN used
> > > > as the committer identity.  *That* info is *correct* at least.
> > > 
> > > CVS and SVN have a local identity.  git has a global identity.  I 
> > > consider 
> > 
> > Git has an identity (well, two) _per commit_, and there is no way you can
> > reconstruct people's prefered name and email address (at any point in time,
> > for every commit separately) correctly.  IMO it is much better to not even
> > try.  We already *have* enough info for anyone to trivially look up who 
> > wrote
> > what, and what might be that person's email address at the time.  But
> > pretending that is more than a guess is just wrong.
> 
> I think not doing a best-effort identification (name+email) is just as 

And I think guessing is not a "best effort", but just wrong.

> wrong as converting a CVS repository to a changeset-based system without 
> doing a best-effort unification of commits to different files around the 
> same time with the same log message into changesets.  Both are the same 

These are not similar situations at all.  Converting something to an SVN-
like data model is necessary for the resulting repo to work acceptably;
guessing person's names and email addresses is just nice-to-have in the
best case, and misleading in other cases.

> sort of heuristic conversion of data to the form idiomatic for a different 
> version control system based around different concepts.  Neither is 

It's single short line of text in SVN.  It is a single short line of text
in Git.  Both just show who wrote a patch, or who committed it.

Good luck finding out who was the primary author of every commit, btw.

> perfect, but the most useful conversion tries to combine CVS commits to 
> different files into changesets, and the most useful conversion tries to 
> identify authors in the way idiomatic for git using the information we 
> have about what person (globally) a given username on a given system 
> corresponds to.

We don't have that information.  This information can change over time,
and we never did track people's email addresses properly either.


Segher


[PATCH V3] A jump threading opportunity for condition branch

2019-06-02 Thread Jiufu Guo


Hi,

This patch implements a new opportunity of jump threading for PR77820.
In this optimization, conditional jumps are merged with unconditional
jump. And then moving CMP result to GPR is eliminated.

This version is based on the proposal of Richard, Jeff and Andrew on
previous versions, and refined to incorporate comments.
Thanks for the reviews!

Bootstrapped and tested on powerpc64le, powerpc64 and sh (with help
from Jeff) with no regressions (two cases are improved and updated
to keep original test coverage) and new testcases are added.
Is this ok for trunk?

Example of this opportunity looks like below:

  
  p0 = a CMP b
  goto ;

  
  p1 = c CMP d
  goto ;

  
  # phi = PHI 
  if (phi != 0) goto ; else goto ;

Could be transformed to:

  
  p0 = a CMP b
  if (p0 != 0) goto ; else goto ;

  
  p1 = c CMP d
  if (p1 != 0) goto ; else goto ;


This optimization eliminates:
1. saving CMP result: p0 = a CMP b. 
2. additional CMP on branch: if (phi != 0).
3. converting CMP result if there is phi = (INT) p0 if there is.

Thanks!
Jiufu Guo

[gcc]
2019-05-31  Jiufu Guo  
Lijia He  

PR tree-optimization/77820
* tree-ssa-threadedge.c
(edge_forwards_cmp_to_conditional_jump_through_empty_bb_p): New
function.
(thread_across_edge): Add call to
edge_forwards_cmp_to_conditional_jump_through_empty_bb_p.

[gcc/testsuite]
2019-05-31  Jiufu Guo  
Lijia He  

PR tree-optimization/77820
* gcc.dg/tree-ssa/phi_on_compare-1.c: New testcase.
* gcc.dg/tree-ssa/phi_on_compare-2.c: New testcase.
* gcc.dg/tree-ssa/phi_on_compare-3.c: New testcase.
* gcc.dg/tree-ssa/phi_on_compare-4.c: New testcase.
* gcc.dg/tree-ssa/split-path-6.c: Update testcase.
* gcc.target/sh/pr51244-20.c: Update testcase.


---
 gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-1.c | 30 ++
 gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-2.c | 23 
 gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-3.c | 25 
 gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-4.c | 40 +
 gcc/testsuite/gcc.dg/tree-ssa/split-path-6.c |  2 +-
 gcc/testsuite/gcc.target/sh/pr51244-20.c |  2 +-
 gcc/tree-ssa-threadedge.c| 73 +++-
 7 files changed, 190 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-1.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-2.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-3.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-4.c

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-1.c 
b/gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-1.c
new file mode 100644
index 000..5227c87
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-1.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast -fdump-tree-vrp1" } */
+
+void g (int);
+void g1 (int);
+
+void
+f (long a, long b, long c, long d, long x)
+{
+  _Bool t;
+  if (x)
+{
+  g (a + 1);
+  t = a < b;
+  c = d + x;
+}
+  else
+{
+  g (b + 1);
+  a = c + d;
+  t = c > d;
+}
+
+  if (t)
+g1 (c);
+
+  g (a);
+}
+
+/* { dg-final { scan-tree-dump-times "Removing basic block" 1 "vrp1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-2.c 
b/gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-2.c
new file mode 100644
index 000..eaf89bb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-2.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast -fdump-tree-vrp1" } */
+
+void g (void);
+void g1 (void);
+
+void
+f (long a, long b, long c, long d, int x)
+{
+  _Bool t;
+  if (x)
+t = c < d;
+  else
+t = a < b;
+
+  if (t)
+{
+  g1 ();
+  g ();
+}
+}
+
+/* { dg-final { scan-tree-dump-times "Removing basic block" 1 "vrp1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-3.c 
b/gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-3.c
new file mode 100644
index 000..d5a1e0b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-3.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast -fdump-tree-vrp1" } */
+
+void g (void);
+void g1 (void);
+
+void
+f (long a, long b, long c, long d, int x)
+{
+  int t;
+  if (x)
+t = a < b;
+  else if (d == x)
+t = c < b;
+  else
+t = d > c;
+
+  if (t)
+{
+  g1 ();
+  g ();
+}
+}
+
+/* { dg-final { scan-tree-dump-times "Removing basic block" 1 "vrp1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-4.c 
b/gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-4.c
new file mode 100644
index 000..53acabc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi_on_compare-4.c
@@ -0,0 +1,40 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast -fdump-tree-vrp1" } */
+
+void g (int);
+void g1 (int);
+
+void
+f (long a, long b, long c, long d, int x)
+{
+  int t;
+  _Bool l1 = 0, l2 = 0;
+  i

Re: [Patch] Fix ix86_expand_sse_comi_round (PR Target/89750, PR Target/86444)

2019-06-02 Thread Hongtao Liu
On Sat, Jun 1, 2019 at 6:08 AM Jeff Law  wrote:
>
> On 5/30/19 2:53 AM, Hongtao Liu wrote:
> > On Thu, May 30, 2019 at 3:23 AM Jeff Law  wrote:
> >> On 5/9/19 10:54 PM, Hongtao Liu wrote:
> >>> On Fri, May 10, 2019 at 3:55 AM Jeff Law  wrote:
>  On 5/6/19 11:38 PM, Hongtao Liu wrote:
> > Hi Uros and GCC:
> >   This patch is to fix ix86_expand_sse_comi_round whose implementation
> > was not correct.
> >   New implentation aligns with _mm_cmp_round_s[sd]_mask.
> >
> > Bootstrap and regression tests for x86 is fine.
> > Ok for trunk?
> >
> >
> > ChangeLog:
> > gcc/
> >* config/i386/i386-expand.c (ix86_expand_sse_comi_round):
> >Modified, original implementation isn't correct.
> >
> > gcc/testsuite
> >* gcc.target/i386/avx512f-vcomisd-2.c: New runtime tests.
> >* gcc.target/i386/avx512f-vcomisd-2.c: Likewise.
>  So you'll have to bear with me, I'm not really familiar with this code,
>  but in the absence of a maintainer I'll try to work through it.
> 
> 
> > -- BR, Hongtao
> >
> >
> > 0001-Fix-ix86_expand_sse_comi_round.patch
> >
> > Index: gcc/ChangeLog
> > ===
> > --- gcc/ChangeLog (revision 270933)
> > +++ gcc/ChangeLog (working copy)
> > @@ -1,3 +1,11 @@
> > +2019-05-06  H.J. Lu  
> > + Hongtao Liu  
> > +
> > + PR Target/89750
> > + PR Target/86444
> > + * config/i386/i386-expand.c (ix86_expand_sse_comi_round):
> > + Modified, original implementation isn't correct.
> > +
> >  2019-05-06  Segher Boessenkool  
> >
> >   * config/rs6000/rs6000.md (FIRST_ALTIVEC_REGNO, 
> > LAST_ALTIVEC_REGNO)
> > Index: gcc/config/i386/i386-expand.c
> > ===
> > --- gcc/config/i386/i386-expand.c (revision 270933)
> > +++ gcc/config/i386/i386-expand.c (working copy)
> > @@ -9853,18 +9853,24 @@
> >const struct insn_data_d *insn_p = &insn_data[icode];
> >machine_mode mode0 = insn_p->operand[0].mode;
> >machine_mode mode1 = insn_p->operand[1].mode;
> > -  enum rtx_code comparison = UNEQ;
> > -  bool need_ucomi = false;
> >
> >/* See avxintrin.h for values.  */
> > -  enum rtx_code comi_comparisons[32] =
> > +  static const enum rtx_code comparisons[32] =
>  So I assume the comment refers to the _CMP_* #defines in avxintrin.h?
> 
> >>>   Yes.
> >  {
> > -  UNEQ, GT, GE, UNORDERED, LTGT, UNLE, UNLT, ORDERED, UNEQ, UNLT,
> > -  UNLE, LT, LTGT, GE, GT, LT, UNEQ, GT, GE, UNORDERED, LTGT, UNLE,
> > -  UNLT, ORDERED, UNEQ, UNLT, UNLE, LT, LTGT, GE, GT, LT
> > +  EQ, LT, LE, UNORDERED, NE, UNGE, UNGT, ORDERED,
> > +  EQ, UNLT, UNLE, UNORDERED, LTGT, GE, GT, ORDERED,
> > +  EQ, LT, LE, UNORDERED, NE, UNGE, UNGT, ORDERED,
> > +  EQ, UNLT, UNLE, UNORDERED, LTGT, GE, GT, ORDERED
> >  };
>  For CMP_EQ_UQ aren't we looking for an unordered comparison, so UNEQ
>  seems right, but you're using EQ.  Can you double-check this?  If it's
>  wrong, then please make sure we cover this case with a test.
> 
> >>> Avx512f-vcomis[sd]-2.c covers all 32 compare predicates.
> >>> UNEQ and EQ behave differently when either operand is NAN, besides
> >>> they're the same.
> >>> Since NAN operands are handled separtely, so EQ/UNEQ makes no
> >>> difference, That why this passes cover tests.
> >>> I'll correct it.
> >> Ah.  Thanks.  FWIW my approach was to walk through the _CMP_* defines in
> >> avxintrin.h and map that to what I thought the comparison ought to be.
> >> Then I reviewed my result against your patch.  I got a couple wrong, but
> >> could easily see my mistake.  The only one I couldn't reconcile was the
> >> CMP_EQ_UQ.  Knowing the NaNs are handled separately makes it clear.
> >> Thanks gain.
> >>
> >>
> >>
> 
> 
> > @@ -9932,11 +10021,37 @@
> >  }
> >
> >emit_insn (pat);
> > +
> > +  /* XXX: Set CCFPmode and check a different CCmode.  Does it work
> > + correctly?  */
> > +  if (GET_MODE (set_dst) != mode)
> > +set_dst = gen_rtx_REG (mode, REGNO (set_dst));
>  This looks worrisome, even without the cryptic comment.  I don't think
>  you can just blindly change the mode like that.  Unless you happen to
>  know that the only things you test in the new mode were set in precisely
>  the same way as the old mode.
> 
> >>> Modified as:
> >>> +  /* NB: Set CCFPmode and check a different CCmode.  */
> >>> +  if (GET_MODE (set_dst) != mode)
> >>> +set_dst = gen_rtx_REG (mode, FLAGS_REG);
> >> That might actually be worse.  The mode carries semantic information
> >> about where to find the various condition codes within the flags
> >> register and which 

Re: [RFC][PR88838][SVE] Use 32-bit WHILELO in LP64 mode

2019-06-02 Thread Kugan Vivekanandarajah
Hi Richard,

Thanks for the review,

On Fri, 31 May 2019 at 19:43, Richard Sandiford
 wrote:
>
> Kugan Vivekanandarajah  writes:
> > @@ -609,8 +615,14 @@ vect_set_loop_masks_directly (struct loop *loop, 
> > loop_vec_info loop_vinfo,
> >
> >/* Get the mask value for the next iteration of the loop.  */
> >next_mask = make_temp_ssa_name (mask_type, NULL, "next_mask");
> > -  gcall *call = vect_gen_while (next_mask, test_index, 
> > this_test_limit);
> > -  gsi_insert_before (test_gsi, call, GSI_SAME_STMT);
> > +  tree test_index_cmp_type = make_ssa_name (compare_type);
> > +  gimple *conv_stmt = gimple_build_assign (test_index_cmp_type,
> > +NOP_EXPR,
> > +test_index);
> > +  gsi_insert_before (test_gsi, conv_stmt, GSI_NEW_STMT);
>
> We only need to convert once, so this should happen before the
> FOR_EACH_VEC_ELT_REVERSE loop.  Would be better as:
>
>   gimple_seq test_seq = NULL;
>   test_index = gimple_convert (&test_seq, compare_type, text_index);
>   gimple_insert_seq_before (test_gsi, test_seq, GSI_SAME_STMT);

Ok.
>
> so that we don't generate unnecessary converts.
>
> > +  gcall *call = vect_gen_while (next_mask, test_index_cmp_type,
> > + this_test_limit);
> > +  gsi_insert_after (test_gsi, call, GSI_SAME_STMT);
> >
> >vect_set_loop_mask (loop, mask, init_mask, next_mask);
> >  }
> > @@ -637,12 +649,12 @@ vect_set_loop_condition_masked (struct loop *loop, 
> > loop_vec_info loop_vinfo,
> >
> >tree compare_type = LOOP_VINFO_MASK_COMPARE_TYPE (loop_vinfo);
> >unsigned int compare_precision = TYPE_PRECISION (compare_type);
> > -  unsigned HOST_WIDE_INT max_vf = vect_max_vf (loop_vinfo);
> >tree orig_niters = niters;
> >
> >/* Type of the initial value of NITERS.  */
> >tree ni_actual_type = TREE_TYPE (niters);
> >unsigned int ni_actual_precision = TYPE_PRECISION (ni_actual_type);
> > +  tree niters_skip = LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo);
> >
> >/* Convert NITERS to the same size as the compare.  */
> >if (compare_precision > ni_actual_precision
> > @@ -661,33 +673,7 @@ vect_set_loop_condition_masked (struct loop *loop, 
> > loop_vec_info loop_vinfo,
> >else
> >  niters = gimple_convert (&preheader_seq, compare_type, niters);
> >
> > -  /* Convert skip_niters to the right type.  */
> > -  tree niters_skip = LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo);
> > -
> > -  /* Now calculate the value that the induction variable must be able
> > - to hit in order to ensure that we end the loop with an all-false mask.
> > - This involves adding the maximum number of inactive trailing scalar
> > - iterations.  */
> > -  widest_int iv_limit;
> > -  bool known_max_iters = max_loop_iterations (loop, &iv_limit);
> > -  if (known_max_iters)
> > -{
> > -  if (niters_skip)
> > - {
> > -   /* Add the maximum number of skipped iterations to the
> > -  maximum iteration count.  */
> > -   if (TREE_CODE (niters_skip) == INTEGER_CST)
> > - iv_limit += wi::to_widest (niters_skip);
> > -   else
> > - iv_limit += max_vf - 1;
> > - }
> > -  /* IV_LIMIT is the maximum number of latch iterations, which is also
> > -  the maximum in-range IV value.  Round this value down to the previous
> > -  vector alignment boundary and then add an extra full iteration.  */
> > -  poly_uint64 vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
> > -  iv_limit = (iv_limit & -(int) known_alignment (vf)) + max_vf;
> > -}
> > -
> > +  widest_int iv_limit = vect_iv_limit_for_full_masking (loop_vinfo);
> >/* Get the vectorization factor in tree form.  */
> >tree vf = build_int_cst (compare_type,
> >  LOOP_VINFO_VECT_FACTOR (loop_vinfo));
> > @@ -717,7 +703,7 @@ vect_set_loop_condition_masked (struct loop *loop, 
> > loop_vec_info loop_vinfo,
> >   /* See whether zero-based IV would ever generate all-false masks
> >  before wrapping around.  */
> >   bool might_wrap_p
> > -   = (!known_max_iters
> > +   = (iv_limit == UINT_MAX
>
> Shouldn't this be == -1?
>
> >|| (wi::min_precision (iv_limit * rgm->max_nscalars_per_iter,
> >   UNSIGNED)
> >> compare_precision));
> > diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
> > index 4942c69..1240037 100644
> > --- a/gcc/tree-vect-loop.c
> > +++ b/gcc/tree-vect-loop.c
> > @@ -1029,7 +1029,10 @@ static bool
> >  vect_verify_full_masking (loop_vec_info loop_vinfo)
> >  {
> >struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
> > +  tree niters_type = TREE_TYPE (LOOP_VINFO_NITERS (loop_vinfo));
> >unsigned int min_ni_width;
> > +  unsigned int max_nscalars_per_iter
> > += vect_get_max_nscalars_per_iter (loop_vinfo);
> >
> >/* Use a normal loop if there are no statements that need masking.

Re: [PATCH] Move rust_{is_mangled,demangle_sym} to a private libiberty header.

2019-06-02 Thread Ian Lance Taylor via gcc-patches
On Sat, Jun 1, 2019 at 7:15 AM Eduard-Mihai Burtescu  wrote:
>
> 2019-06-01  Eduard-Mihai Burtescu  
> include/ChangeLog:
> * demangle.h (rust_is_mangled): Move to libiberty/rust-demangle.h.
> (rust_demangle_sym): Move to libiberty/rust-demangle.h.
> libiberty/ChangeLog:
> * cplus-dem.c: Include rust-demangle.h.
> * rust-demangle.c: Include rust-demangle.h.
> * rust-demangle.h: New file.

This is OK if it bootstraps and tests pass.

Thanks.

Ian