diff mbox

patch to fix PR70478

Message ID 561d01a4-84b7-b70d-b9b9-517c1528c0c2@redhat.com
State New
Headers show

Commit Message

Vladimir Makarov April 7, 2017, 4:04 p.m. UTC
The following patch fixes

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

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

   Committed as rev. 246764.

Comments

Jakub Jelinek April 7, 2017, 9:45 p.m. UTC | #1
On Fri, Apr 07, 2017 at 12:04:16PM -0400, Vladimir Makarov wrote:
>   The following patch fixes
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70478
> 
>   The patch was successfully bootstrapped and tested on x86-64/ppc64/arm64.
> 
>   Committed as rev. 246764.
> 

> Index: ChangeLog
> ===================================================================
> --- ChangeLog	(revision 246763)
> +++ ChangeLog	(working copy)
> @@ -1,3 +1,9 @@
> +2017-04-07  Vladimir Makarov  <vmakarov@redhat.com>
> +
> +	PR rtl-optimization/70478
> +	* lra-constraints.c (process_alt_operands): Disfavor alternative
> +	insn memory operands.

This has regressed:
+UNRESOLVED: gfortran.dg/pr68627.f   -O   scan-assembler-not vbroadcastsd[ \\\\t]+%xmm[0-9]+, %ymm[0-9]+
+FAIL: gfortran.dg/pr68627.f   -O  (internal compiler error)
+FAIL: gfortran.dg/pr68627.f   -O  (test for excess errors)
on x86_64-linux, starting with r246764 there is ICE:
Error: unable to find a register to spill
pr68627.f:16:0: Error: this is the insn:
(insn 202 1300 1177 12 (set (reg:V2DF 1306 [785])
        (vec_concat:V2DF (reg:DF 1307 [orig:259 _282 ] [259])
            (reg:DF 1421 [orig:263 _313 ] [263]))) "pr68627.f":11 2727 {vec_concatv2df}
     (expr_list:REG_DEAD (reg:DF 1421 [orig:263 _313 ] [263])
        (expr_list:REG_DEAD (reg:DF 1307 [orig:259 _282 ] [259])
            (nil))))
pr68627.f:16:0: internal compiler error: in assign_by_spills, at lra-assigns.c:1476

	Jakub
Vladimir Makarov April 8, 2017, 7:19 p.m. UTC | #2
On 04/07/2017 05:45 PM, Jakub Jelinek wrote:
> On Fri, Apr 07, 2017 at 12:04:16PM -0400, Vladimir Makarov wrote:
>
>> Index: ChangeLog
>> ===================================================================
>> --- ChangeLog	(revision 246763)
>> +++ ChangeLog	(working copy)
>> @@ -1,3 +1,9 @@
>> +2017-04-07  Vladimir Makarov  <vmakarov@redhat.com>
>> +
>> +	PR rtl-optimization/70478
>> +	* lra-constraints.c (process_alt_operands): Disfavor alternative
>> +	insn memory operands.
> This has regressed:
> +UNRESOLVED: gfortran.dg/pr68627.f   -O   scan-assembler-not vbroadcastsd[ \\\\t]+%xmm[0-9]+, %ymm[0-9]+
> +FAIL: gfortran.dg/pr68627.f   -O  (internal compiler error)
> +FAIL: gfortran.dg/pr68627.f   -O  (test for excess errors)
> on x86_64-linux, starting with r246764 there is ICE:
> Error: unable to find a register to spill
> pr68627.f:16:0: Error: this is the insn:
> (insn 202 1300 1177 12 (set (reg:V2DF 1306 [785])
>          (vec_concat:V2DF (reg:DF 1307 [orig:259 _282 ] [259])
>              (reg:DF 1421 [orig:263 _313 ] [263]))) "pr68627.f":11 2727 {vec_concatv2df}
>       (expr_list:REG_DEAD (reg:DF 1421 [orig:263 _313 ] [263])
>          (expr_list:REG_DEAD (reg:DF 1307 [orig:259 _282 ] [259])
>              (nil))))
> pr68627.f:16:0: internal compiler error: in assign_by_spills, at lra-assigns.c:1476
>
>
Thanks, Jakub.  I used only check-gcc on 3 platforms to check the 
patch.  I should have checked other languages too.

Meanwhile, I've reversed the patch.  I'll continue work on the PR.
diff mbox

Patch

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 246763)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@ 
+2017-04-07  Vladimir Makarov  <vmakarov@redhat.com>
+
+	PR rtl-optimization/70478
+	* lra-constraints.c (process_alt_operands): Disfavor alternative
+	insn memory operands.
+
 2017-04-07  Jeff Law  <law@redhat.com>
 
 	* config/iq2000/iq2000.c (final_prescan_insn): Do not separate a
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog	(revision 246763)
+++ testsuite/ChangeLog	(working copy)
@@ -1,3 +1,8 @@ 
+2017-04-07  Vladimir Makarov  <vmakarov@redhat.com>
+
+	PR rtl-optimization/70478
+	* gcc.target/s390/pr70478.c: New.
+
 2017-04-07  Martin Liska  <mliska@suse.cz>
 
 	PR target/79889
Index: lra-constraints.c
===================================================================
--- lra-constraints.c	(revision 246763)
+++ lra-constraints.c	(working copy)
@@ -2685,6 +2685,21 @@  process_alt_operands (int only_alternati
 		    }
 		}
 
+	      /* When we use memory operand, the insn should read the
+		 value from memory and even if we just wrote a value
+		 into the memory it is costly in comparison with an
+		 insn alternative which does not use memory
+		 (e.g. register or immediate operand).  */
+	      if (no_regs_p && offmemok)
+		{
+		  if (lra_dump_file != NULL)
+		    fprintf
+		      (lra_dump_file,
+		       "            Using memory insn operand %d: reject+=3\n",
+		       nop);
+		  reject += 3;
+		}
+	      
 #ifdef SECONDARY_MEMORY_NEEDED
 	      /* If reload requires moving value through secondary
 		 memory, it will need one more insn at least.  */
Index: testsuite/gcc.target/s390/pr70478.c
===================================================================
--- testsuite/gcc.target/s390/pr70478.c	(nonexistent)
+++ testsuite/gcc.target/s390/pr70478.c	(working copy)
@@ -0,0 +1,8 @@ 
+/* { dg-do compile } */
+/* { dg-options "-w -O3 -march=z9-109" } */
+/* { dg-final { scan-assembler-not "stg" } } */
+
+void foo(unsigned int *a, unsigned char *b)
+{
+  *a &= *b;
+}