aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlen Nakamura <glen@imodulo.com>2003-02-21 08:07:25 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2003-02-21 08:07:25 +0000
commit9e7d0b92a95ffe1fc14f72cafeef322b7723c1c3 (patch)
tree3711b274afdafc286d6a6ed6aef58424b13479b0
parente9019af61669bd7fcb58f6b2e1f0f7c8a0a3ad13 (diff)
downloadgcc-9e7d0b92a95ffe1fc14f72cafeef322b7723c1c3.zip
gcc-9e7d0b92a95ffe1fc14f72cafeef322b7723c1c3.tar.gz
gcc-9e7d0b92a95ffe1fc14f72cafeef322b7723c1c3.tar.bz2
re PR rtl-optimization/8613 (-O2 optimization generates wrong code)
PR optimization/8613 * builtins.c (expand_builtin): Emit postincrements before expanding builtin functions. From-SVN: r63207
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/builtins.c3
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20030221-1.c17
4 files changed, 30 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5fafbeb..4890e7b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/builtins.c b/gcc/builtins.c
index cdb9bb2..25ae873 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 603ae10..08d3785 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..9dcee3e
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20030221-1.c
@@ -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;
+}