Patchwork [committed] Fix ipa-pure-const in 4.5 (PR tree-optimization/46491)

login
register
mail settings
Submitter Jakub Jelinek
Date Nov. 15, 2010, 10:35 p.m.
Message ID <20101115223530.GH29412@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/71312/
State New
Headers show

Comments

Jakub Jelinek - Nov. 15, 2010, 10:35 p.m.
Hi!

This patch fixes the Linux kernel problem on i8k.c in 4.5.
Turns out Honza has fixed this already on the trunk the same way,
bootstrapped/regtested on x86_64-linux and i686-linux, committed to 4.5
and testcase to 4.6.  Will backport to 4.4 when I test it there (with
additional -fno-ipa-reference, so the bug is less urgent there).

2010-11-15  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/46491
	Backport from mainline

	2010-05-14  Jan Hubicka  <jh@suse.cz>
	* ipa-pure-const.c (check_stmt): Do not use memory_identifier_string.

	* gcc.target/i386/pr46491.c: New test.


	Jakub

Patch

--- gcc/ipa-pure-const.c.jj	2010-08-11 16:06:19.000000000 +0200
+++ gcc/ipa-pure-const.c	2010-11-15 20:08:27.484278596 +0100
@@ -460,7 +460,7 @@  check_stmt (gimple_stmt_iterator *gsip, 
       for (i = 0; i < gimple_asm_nclobbers (stmt); i++)
 	{
 	  tree op = gimple_asm_clobber_op (stmt, i);
-	  if (simple_cst_equal(TREE_VALUE (op), memory_identifier_string) == 1)
+	  if (strcmp (TREE_STRING_POINTER (TREE_VALUE (op)), "memory") == 0)
 	    {
               if (dump_file)
                 fprintf (dump_file, "    memory asm clobber is not const/pure");
--- gcc/testsuite/gcc.target/i386/pr46491.c.jj	2010-11-15 21:28:16.102499133 +0100
+++ gcc/testsuite/gcc.target/i386/pr46491.c	2010-11-15 21:00:40.000000000 +0100
@@ -0,0 +1,22 @@ 
+/* PR tree-optimization/46491 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+
+__attribute__((noinline)) int
+foo (int *p)
+{
+  int r;
+  asm ("movl $6, (%1)\n\txorl %0, %0" : "=r" (r) : "r" (p) : "memory");
+  return r;
+}
+
+int
+main (void)
+{
+  int p = 8;
+  if ((foo (&p) ? : p) != 6)
+    abort ();
+  return 0;
+}