This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix simplify_builtin_call in forwprop (PR tree-optimization/46461)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 15 Nov 2010 21:16:46 +0100
- Subject: [PATCH] Fix simplify_builtin_call in forwprop (PR tree-optimization/46461)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
When stmt1 is a byte store instead of memcpy, ptr1 can be
something that is not is_gimple_val. Fixed thusly, bootstrapped/regtested
on x86_64-linux and i686-linux. Ok for trunk?
Alternatively the conditional could be left out, as force_gimple_operand_gsi
will do nothing if it is is_gimple_val already (but will call is_gimple_val
twice and a couple of other checks).
2010-11-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/46461
* tree-ssa-forwprop.c (simplify_builtin_call): Ensure ptr1 is
a gimple val.
* gcc.c-torture/compile/pr46461.c: New test.
--- gcc/tree-ssa-forwprop.c.jj 2010-11-09 13:58:30.000000000 +0100
+++ gcc/tree-ssa-forwprop.c 2010-11-15 11:11:52.000000000 +0100
@@ -1594,6 +1594,9 @@ simplify_builtin_call (gimple_stmt_itera
memcpy call. */
gimple_stmt_iterator gsi = gsi_for_stmt (stmt1);
+ if (!is_gimple_val (ptr1))
+ ptr1 = force_gimple_operand_gsi (gsi_p, ptr1, true, NULL_TREE,
+ true, GSI_SAME_STMT);
gimple_call_set_fndecl (stmt2, built_in_decls [BUILT_IN_MEMCPY]);
gimple_call_set_arg (stmt2, 0, ptr1);
gimple_call_set_arg (stmt2, 1, new_str_cst);
--- gcc/testsuite/gcc.c-torture/compile/pr46461.c.jj 2010-11-15 11:13:31.000000000 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr46461.c 2010-11-15 11:13:15.000000000 +0100
@@ -0,0 +1,8 @@
+/* PR tree-optimization/46461 */
+
+void
+foo (char *c)
+{
+ c[7] = 0xff;
+ __builtin_memset (c + 8, 0xff, 8);
+}
Jakub