Re: patch to fix PR68349

2015-12-07 Thread Vladimir Makarov

On 12/04/2015 06:52 PM, H.J. Lu wrote:

On Fri, Dec 4, 2015 at 11:26 AM, Vladimir Makarov  wrote:

   The following patch fixes

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68349

   The patch was tested and bootstrapped on x86/x86-64.

  Committed as rev. 231300.

unsigned long strlen();
^^^

I got

./xgcc -B./ -O2
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/pr68349.c
-S -m32
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/pr68349.c:6:15:
warning: conflicting types for built-in function ‘strlen’
  unsigned long strlen();

Shouldn't strlen be renamed?


Thanks for reporting this, H.J.

I've committed the following patch:

Index: ChangeLog
===
--- ChangeLog   (revision 231368)
+++ ChangeLog   (working copy)
@@ -1,3 +1,7 @@
+2015-12-07  Vladimir Makarov  
+
+   * gcc.target/i386/pr68349.c (strlen): Rename to my_strlen.
+
 2015-12-07  Nathan Sidwell  

* gcc.target/nvptx/abort.c: New.
Index: gcc.target/i386/pr68349.c
===
--- gcc.target/i386/pr68349.c   (revision 231300)
+++ gcc.target/i386/pr68349.c   (working copy)
@@ -3,7 +3,7 @@
 /* { dg-options "-O2" } */

 int a, b;
-unsigned long strlen();
+unsigned long my_strlen();
 typedef struct sHyphenNode {
   char sepcnts[0];
   struct sHyphenNode *Daughters[];
@@ -12,7 +12,7 @@
 PHyphenNode c;
 void DoHyphens_Field_1() {
   char d[300], e[300];
-  int z, f, l = strlen();
+  int z, f, l = my_strlen();
   for (; z;)
 ;
   for (; l; z++) {



Re: patch to fix PR68349

2015-12-04 Thread H.J. Lu
On Fri, Dec 4, 2015 at 11:26 AM, Vladimir Makarov  wrote:
>   The following patch fixes
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68349
>
>   The patch was tested and bootstrapped on x86/x86-64.
>
>  Committed as rev. 231300.

unsigned long strlen();
^^^

I got

./xgcc -B./ -O2
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/pr68349.c
-S -m32
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/pr68349.c:6:15:
warning: conflicting types for built-in function ‘strlen’
 unsigned long strlen();

Shouldn't strlen be renamed?

-- 
H.J.


patch to fix PR68349

2015-12-04 Thread Vladimir Makarov

  The following patch fixes

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68349

  The patch was tested and bootstrapped on x86/x86-64.

 Committed as rev. 231300.
Index: ChangeLog
===
--- ChangeLog	(revision 231299)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2015-12-04  Vladimir Makarov  
+
+	PR rtl-optimization/68349
+	* lra-eliminations.c (move_plus_up): New function.
+	(lra_eliminate_regs_1): Use the function.
+
 2015-12-04  Nathan Sidwell  
 
 	* config/nvptx/nvptx.c (nvptx_assemble_decl_begin): New,
Index: lra-eliminations.c
===
--- lra-eliminations.c	(revision 231299)
+++ lra-eliminations.c	(working copy)
@@ -279,6 +279,29 @@ get_elimination (rtx reg)
   return _elim_table;
 }
 
+/* Transform (subreg (plus reg const)) to (plus (subreg reg) const)
+   when it is possible.  Return X or the transformation result if the
+   transformation is done.  */
+static rtx
+move_plus_up (rtx x)
+{
+  rtx subreg_reg;
+  enum machine_mode x_mode, subreg_reg_mode;
+  
+  if (GET_CODE (x) != SUBREG || !subreg_lowpart_p (x))
+return x;
+  subreg_reg = SUBREG_REG (x);
+  x_mode = GET_MODE (x);
+  subreg_reg_mode = GET_MODE (subreg_reg);
+  if (GET_CODE (x) == SUBREG && GET_CODE (subreg_reg) == PLUS
+  && GET_MODE_SIZE (x_mode) <= GET_MODE_SIZE (subreg_reg_mode)
+  && CONSTANT_P (XEXP (subreg_reg, 1)))
+return gen_rtx_PLUS (x_mode, lowpart_subreg (x_mode, subreg_reg,
+		 subreg_reg_mode),
+			 XEXP (subreg_reg, 1));
+  return x;
+}
+
 /* Scan X and replace any eliminable registers (such as fp) with a
replacement (such as sp) if SUBST_P, plus an offset.  The offset is
a change in the offset between the eliminable register and its
@@ -407,6 +430,8 @@ lra_eliminate_regs_1 (rtx_insn *insn, rt
 	 subst_p, update_p,
 	 update_sp_offset, full_p);
 
+	new0 = move_plus_up (new0);
+	new1 = move_plus_up (new1);
 	if (new0 != XEXP (x, 0) || new1 != XEXP (x, 1))
 	  return form_sum (new0, new1);
   }
Index: testsuite/ChangeLog
===
--- testsuite/ChangeLog	(revision 231299)
+++ testsuite/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2015-12-04  Vladimir Makarov  
+
+	PR rtl-optimization/68349
+	* gcc.target/i386/pr68349.c: New test.
+
 2015-12-04  Nathan Sidwell  
 
 	* gcc.target/nvptx/ary-init.c: New.
@@ -288,7 +293,6 @@
 	* gfortran.dg/graphite/pr68550-1.f90: New.
 	* gfortran.dg/graphite/pr68550-2.f90: New.
 
->>> .r231221
 2015-12-02  Marek Polacek  
 
 	PR c/68513
Index: testsuite/gcc.target/i386/pr68349.c
===
--- testsuite/gcc.target/i386/pr68349.c	(revision 0)
+++ testsuite/gcc.target/i386/pr68349.c	(working copy)
@@ -0,0 +1,30 @@
+/* PR target/68483 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int a, b;
+unsigned long strlen();
+typedef struct sHyphenNode {
+  char sepcnts[0];
+  struct sHyphenNode *Daughters[];
+} * PHyphenNode;
+int GetIndex();
+PHyphenNode c;
+void DoHyphens_Field_1() {
+  char d[300], e[300];
+  int z, f, l = strlen();
+  for (; z;)
+;
+  for (; l; z++) {
+f = z;
+for (; f < l; f++) {
+  c = c->Daughters[GetIndex(d[f])];
+  a = 0;
+  for (; a <= f - z; a++)
+	if (e[z + a])
+	  e[z] = c->sepcnts[a];
+}
+  }
+  if (e[z])
+b = 1;
+}