This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] Fix uninitialized var problem introduced with the sse memset changes (PR target/51261)


Hi!

With -O0 decide_alg wouldn't initialize *dynamic_check and the callers
would use an uninitialized variable.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk as obvious.

2011-11-23  Jakub Jelinek  <jakub@redhat.com>

	PR target/51261
	* config/i386/i386.c (decide_alg): Initialize *dynamic_check
	even if !optimize.

	* gcc.dg/pr51261.c: New test.

--- gcc/config/i386/i386.c.jj	2011-11-21 16:21:58.000000000 +0100
+++ gcc/config/i386/i386.c	2011-11-23 13:06:18.185380361 +0100
@@ -22106,12 +22106,12 @@ decide_alg (HOST_WIDE_INT count, HOST_WI
   else
     optimize_for_speed = true;
 
+  *dynamic_check = -1;
   if (!optimize)
     return (rep_prefix_usable ? rep_prefix_1_byte : libcall);
 
   cost = optimize_for_speed ? ix86_cost : &ix86_size_cost;
 
-  *dynamic_check = -1;
   if (memset)
     algs = &cost->memset[align_unknown][TARGET_64BIT != 0];
   else
--- gcc/testsuite/gcc.dg/pr51261.c.jj	2011-11-23 13:12:14.493114983 +0100
+++ gcc/testsuite/gcc.dg/pr51261.c	2011-11-23 13:08:56.000000000 +0100
@@ -0,0 +1,9 @@
+/* PR target/51261 */
+/* { dg-do compile } */
+/* { dg-options "-fcompare-debug" } */
+
+void
+foo (void *p, int n)
+{
+  __builtin_memset (p, 0xff, n);
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]