Subject: gcc bug fix from 2.95.4 prerelease to be committed
To: None <tech-toolchain@netbsd.org>
From: Aymeric Vincent <Aymeric.Vincent@labri.fr>
List: port-powerpc
Date: 07/13/2002 16:58:22
On powerpc (at least on my macppc), compiling xkbcomp from
xsrc/xfree/xc/programs/xkbcomp yields a non-working xkbcomp with -O2.
(which is the default)
The problem is that gcc generates a bogus uStrCaseCmp() function.

The following patch to expr.c, which comes from the gcc-2_95_branch,
makes gcc generate working code.

I plan to commit this on monday unless someone wants it not to be
committed, or encourages me to commit it sooner.

 Aymeric

ChangeLog entry:
2001-05-17  Bernd Schmidt  <bernds@redhat.com>

        * expr.c (protect_from_queue): Protect against subsequent calls to
        emit_queue.
        (expand_expr, case ADDR_EXPR): Prevent protect_from_queue from being
        too clever.

CVS log entry:
revision 1.144.4.11
date: 2001/05/17 17:01:06;  author: bernds;  state: Exp;  lines: +10 -3
Fix queueing-related bugs


Index: expr.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/expr.c,v
retrieving revision 1.144.4.10
retrieving revision 1.144.4.11
diff -u -r1.144.4.10 -r1.144.4.11
--- expr.c	19 Mar 2001 13:37:17 -0000	1.144.4.10
+++ expr.c	17 May 2001 17:01:06 -0000	1.144.4.11
@@ -450,6 +450,9 @@
 				QUEUED_INSN (y));
 	      return temp;
 	    }
+	  /* Copy the address into a pseudo, so that the returned value
+	     remains correct across calls to emit_queue.  */
+	  XEXP (new, 0) = copy_to_reg (XEXP (new, 0));
 	  return new;
 	}
       /* Otherwise, recursively protect the subexpressions of all
@@ -476,9 +479,11 @@
 	}
       return x;
     }
-  /* If the increment has not happened, use the variable itself.  */
+  /* If the increment has not happened, use the variable itself.  Copy it
+     into a new pseudo so that the value remains correct across calls to
+     emit_queue.  */
   if (QUEUED_INSN (x) == 0)
-    return QUEUED_VAR (x);
+    return copy_to_reg (QUEUED_VAR (x));
   /* If the increment has happened and a pre-increment copy exists,
      use that copy.  */
   if (QUEUED_COPY (x) != 0)
@@ -8077,7 +8082,9 @@
 	  if (ignore)
 	    return op0;
 
-	  op0 = protect_from_queue (op0, 0);
+	  /* Pass 1 for MODIFY, so that protect_from_queue doesn't get
+	     clever and returns a REG when given a MEM.  */
+	  op0 = protect_from_queue (op0, 1);
 
 	  /* We would like the object in memory.  If it is a constant,
 	     we can have it be statically allocated into memory.  For