Subject: Re: gcc improvements
To: Ian Dall <Ian.Dall@dsto.defence.gov.au>
From: Matthias Pfaller <leo@dachau.marco.de>
List: port-pc532
Date: 07/17/1997 09:13:58
Ian Dall wrote:
> I looked back through my archives and found a copy of the message Jon
> sent to Richard Kenner. These patches are not in gcc up to 2.7.2.2.
> Maybe they will be in 2.8. I notice that they are *also* not in the
> netbsd-current source tree! I also noticed that there are some other
> much older differences between the ns32k.md in the netbsd tree and the
> FSF distribution -- notably the ffs instruction definitions. I have merged
> both these changes into my version.

I sent the ffs change to Richard Kenner on 28th of May 1996. I hope it will
show up in 2.8 (whenever this will come). I have appended the original
message. What other differences did you find?

Matthias

Hi Richard,

I found a bug in the ns32k machine description that results in wrong code
for ffs sometimes. Here comes a fix it.

	Matthias

Sat May 25 19:31:44 1996  Matthias Pfaller  (leo@marco.de)

	* ns32k.md (define_insns for ffs[qhs]i2): Deleted. These
	patterns only worked when the input operand was not the same
	as the output operand.
	(define_expand for ffssi2): New pattern. This uses an
	anonymous pattern that describes what the ns32k's ffsd
	instruction (really) does.

--- ns32k.md.ORIG	Mon Dec 11 21:14:24 1995
+++ ns32k.md	Tue May 21 17:07:37 1996
@@ -2607,32 +2790,33 @@
 =0C
 ;; ffs instructions
=20
-(define_insn "ffsqi2"
-  [(set (match_operand:QI 0 "general_operand" "=3Dg")
-	(ffs:QI (match_operand:SI 1 "general_operand" "g")))]
-  ""
-  "*
-{
-  return \"movqb 0,%0; ffsd %1,%0; bfs 1f; addqb 1,%0; 1:\";
-}")
-
-(define_insn "ffshi2"
-  [(set (match_operand:HI 0 "general_operand" "=3Dg")
-	(ffs:HI (match_operand:SI 1 "general_operand" "g")))]
-  ""
-  "*
-{
-  return \"movqw 0,%0; ffsd %1,%0; bfs 1f; addqw 1,%0; 1:\";
-}")
-
-(define_insn "ffssi2"
-  [(set (match_operand:SI 0 "general_operand" "=3Dg")
-	(ffs:SI (match_operand:SI 1 "general_operand" "g")))]
+(define_insn ""
+  [(set (match_operand:SI 0 "general_operand" "ro")
+	(minus:SI=20
+		(plus:SI (ffs:SI (zero_extract:SI=20
+				(match_operand:SI 1 "general_operand" "g")=20
+				(minus:SI (const_int 32) (match_dup 0))
+				(match_dup 0)))
+			(match_dup 0))=20
+		(const_int 1)))]
+  ""
+  "ffsd %1,%0; bfc 1f; addqd %$-1,%0; 1:")
+
+(define_expand "ffssi2"
+  [(set (match_operand:SI 0 "general_operand" "=3Dg") (const_int 0))
+   (set (match_dup 0)
+	(minus:SI=20
+		(plus:SI (ffs:SI (zero_extract:SI=20
+				(match_operand:SI 1 "general_operand" "g")=20
+				(minus:SI (const_int 32) (match_dup 0))
+				(match_dup 0)))
+			(match_dup 0))=20
+		(const_int 1)))
+   (set (match_dup 0)
+	(plus:SI (match_dup 0)
+		 (const_int 1)))]
   ""
-  "*
-{
-  return \"movqd 0,%0; ffsd %1,%0; bfs 1f; addqd 1,%0; 1:\";
-}")
+  "operands[1] =3D make_safe_from(operands[1], operands[0]);")
 =0C
 ;; Speed up stack adjust followed by a HI fixedpoint push.

--=20
Matthias Pfaller                            Software Entwicklung
marco Systemanalyse und Entwicklung GmbH    Tel   +49 8131 5161-41
Hans-B=F6ckler-Str. 2, D 85221 Dachau         Fax   +49 8131 5161-66
http://www.marco.de/                        Email leo@dachau.marco.de