Stop only if there aren't any usable algorithms
authorH.J. Lu <hongjiu.lu@intel.com>
Tue, 2 Dec 2014 14:10:23 +0000 (14:10 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Tue, 2 Dec 2014 14:10:23 +0000 (06:10 -0800)
When searching for an usable algorithm with -minline-all-stringops,
decide_alg stops when it sees libcall even if there is a usable
algorithm.  It goes into an infinite loop.  This patch changes
decide_alg to stop searching only if there aren't any usable algorithms.
Testd on Linux/x86-64.

gcc/

PR target/64108
* config/i386/i386.c (decide_alg): Stop only if there aren't
any usable algorithms.

gcc/testsuite/

PR target/64108
* gcc.target/i386/memset-strategy-2.c: New test.

From-SVN: r218272

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/memset-strategy-2.c [new file with mode: 0644]

index 3eacc5a258837833a45a89770b8402a3c04b95c2..c746d0f8a5134ea597447a2f69a5ec0d2d9b6d95 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/64108
+       * config/i386/i386.c (decide_alg): Stop only if there aren't
+       any usable algorithms.
+
 2014-12-02  Tom de Vries  <tom@codesourcery.com>
 
        PR rtl-optimization/63718
index 3397167179078f1d7f5c0de373bfa0f11741691a..211c9e6a65ecccd956daf3b60cdc1d8a4b914f7b 100644 (file)
@@ -24464,7 +24464,8 @@ decide_alg (HOST_WIDE_INT count, HOST_WIDE_INT expected_size,
                      *noalign = alg_noalign;
                      return alg;
                    }
-                 break;
+                 else if (!any_alg_usable_p)
+                   break;
                }
              else if (alg_usable_p (candidate, memset))
                {
index 00da0bdbddec9a528905cb935a5db4f6f34bd536..5d668494f8acc854a30bbae43be84e8d29a84f41 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/64108
+       * gcc.target/i386/memset-strategy-2.c: New test.
+
 2014-12-02  Richard Biener  <rguenther@suse.de>
 
        * gcc.dg/torture/20141202-1.c: New testcase.
diff --git a/gcc/testsuite/gcc.target/i386/memset-strategy-2.c b/gcc/testsuite/gcc.target/i386/memset-strategy-2.c
new file mode 100644 (file)
index 0000000..aafa54d
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR target/64108 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=atom -mmemset-strategy=libcall:-1:align -minline-all-stringops" } */
+
+char a[2048];
+void t (void)
+{
+  __builtin_memset (a, 1, 2048);
+}
+