re PR rtl-optimization/8613 (-O2 optimization generates wrong code)
authorGlen Nakamura <glen@imodulo.com>
Fri, 21 Feb 2003 08:07:25 +0000 (08:07 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 21 Feb 2003 08:07:25 +0000 (08:07 +0000)
PR optimization/8613
* builtins.c (expand_builtin): Emit postincrements before expanding
builtin functions.

From-SVN: r63207

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20030221-1.c [new file with mode: 0644]

index 5fafbeb7f6e7744f524a445fe29ed673f4ee7529..4890e7b2c11e363e83dc3c1186ab2c07cd87a4b9 100644 (file)
@@ -1,3 +1,9 @@
+2003-02-21  Glen Nakamura  <glen@imodulo.com>
+
+       PR optimization/8613
+       * builtins.c (expand_builtin): Emit postincrements before expanding
+       builtin functions.
+
 2003-02-21  Ben Elliston  <bje@redhat.com>
 
        PR other/5634
index cdb9bb25c1949263b7b0cb0e788a49a3e5195fa0..25ae873e1415e73e53b81026c8b9be6b1b671986 100644 (file)
@@ -4012,6 +4012,9 @@ expand_builtin (exp, target, subtarget, mode, ignore)
   tree arglist = TREE_OPERAND (exp, 1);
   enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
 
+  /* Perform postincrements before expanding builtin functions.  */
+  emit_queue ();
+
   if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
     return (*targetm.expand_builtin) (exp, target, subtarget, mode, ignore);
 
index 603ae101b5d4905df2a317ecb08b043584fc84f5..08d3785a0a686704037864e438fa56beaf711ef2 100644 (file)
@@ -1,3 +1,7 @@
+2003-02-21  Glen Nakamura  <glen@imodulo.com>
+
+       * gcc.c-torture/execute/20030221-1.c: New test.
+
 2003-02-20  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/9729
diff --git a/gcc/testsuite/gcc.c-torture/execute/20030221-1.c b/gcc/testsuite/gcc.c-torture/execute/20030221-1.c
new file mode 100644 (file)
index 0000000..9dcee3e
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR optimization/8613 */
+/* Contributed by Glen Nakamura */
+
+extern void abort (void);
+int main (void)
+{
+  char buf[16] = "1234567890";
+  char *p = buf;
+
+  *p++ = (char) __builtin_strlen (buf);
+
+  if ((buf[0] != 10) || (p - buf != 1))
+    abort ();
+
+  return 0;
+}