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  <vmaka...@redhat.com>
+
+	PR rtl-optimization/70478
+	* lra-constraints.c (process_alt_operands): Disfavor alternative
+	insn memory operands.
+
 2017-04-07  Jeff Law  <l...@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  <vmaka...@redhat.com>
+
+	PR rtl-optimization/70478
+	* gcc.target/s390/pr70478.c: New.
+
 2017-04-07  Martin Liska  <mli...@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;
+}

Reply via email to