[PATCH] Fix PR64240

Yangfei (Felix) felix.yang@huawei.com
Tue Dec 16 10:57:00 GMT 2014


> On December 16, 2014 9:51:25 AM CET, "Yangfei (Felix)" <felix.yang@huawei.com>
> wrote:
> >Hi,
> >
> >This patch fixes an obvious typo which may affect the DDG creation of
> >SMS and make this optimization produce buggy code.
> >Bootstrapped on x86_64-suse-linux.  Also passed check-gcc test for
> >aarch64-linux-gnu.
> >  OK for the trunk?
> 
> Do you have a testcase? If so please add it.
>
> OK

Yes, the patch is updated with the testcase added. 


Index: gcc/ddg.c
===================================================================
--- gcc/ddg.c	(revision 218582)
+++ gcc/ddg.c	(working copy)
@@ -77,7 +77,7 @@ mark_mem_use (rtx *x, void *)
 {
   subrtx_iterator::array_type array;
   FOR_EACH_SUBRTX (iter, array, *x, NONCONST)
-    if (MEM_P (*x))
+    if (MEM_P (*iter))
       {
 	mem_ref_p = true;
 	break;
Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 218582)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2014-12-16  Felix Yang  <felix.yang@huawei.com>
+
+	PR rtl-optimization/64240
+	* ddg.c (mark_mem_use): Check *iter instead of *x.
+
 2014-12-10  Felix Yang  <felix.yang@huawei.com>
 
 	* config/aarch64/aarch64-protos.h (aarch64_function_profiler): Remove
Index: gcc/testsuite/gcc.dg/sms-12.c
===================================================================
--- gcc/testsuite/gcc.dg/sms-12.c	(revision 0)
+++ gcc/testsuite/gcc.dg/sms-12.c	(revision 0)
@@ -0,0 +1,43 @@
+/* { dg-do run } */
+/* { dg-skip-if "" { ! { aarch64-*-* } } { "*" } { "" } } */
+/* { dg-options "-O2 -fmodulo-sched -funroll-loops -fdump-rtl-sms --param sms-min-sc=1 -fmodulo-sched-allow-regmoves -fPIC" } */
+
+extern void abort (void);
+
+int X[1000]={0};
+int Y[1000]={0};
+
+extern void abort (void);
+
+__attribute__ ((noinline))
+int
+foo (int len, long a)
+{
+  int i;
+  long res = a;
+
+  len = 1000;
+  for (i = 0; i < len; i++)
+    res += X[i]* Y[i];
+
+  if (res != 601)
+    abort ();
+
+}
+
+int
+main ()
+{
+  X[0] = Y[1] = 2;
+  Y[0] = X[1] = 21;
+  X[2] = Y[3] = 3;
+  Y[2] = X[3] = 31;
+  X[4] = Y[5] = 4;
+  Y[4] = X[5] = 41;
+
+  foo (6, 3);
+  return 0;
+}
+
+/* { dg-final { cleanup-rtl-dump "sms" } } */
+

Property changes on: gcc/testsuite/gcc.dg/sms-12.c
___________________________________________________________________
Added: svn:executable
   + *

Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(revision 218582)
+++ gcc/testsuite/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2014-12-16  Felix Yang  <felix.yang@huawei.com>
+
+	PR rtl-optimization/64240
+	* gcc.dg/sms-12.c: New test.
+
 2014-12-10  Martin Liska  <mliska@suse.cz>
 
 	* gcc.dg/ipa/pr63909.c: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr64240-v2.diff
Type: application/octet-stream
Size: 2294 bytes
Desc: pr64240-v2.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20141216/cd47a5ad/attachment.obj>


More information about the Gcc-patches mailing list