(ffssi2, ffshi2): Assume bsf produces garbage if input is 0.
authorRichard Stallman <rms@gnu.org>
Tue, 13 Jul 1993 07:34:25 +0000 (07:34 +0000)
committerRichard Stallman <rms@gnu.org>
Tue, 13 Jul 1993 07:34:25 +0000 (07:34 +0000)
(ffssi2, ffshi2): Assume bsf produces
garbage if input is 0.  Use jumps to load output in that case.

From-SVN: r4911

gcc/config/i386/i386.md

index 3b91864c1e977f2d307a60bb9afc475d137465f3..983f49734f8961f0ff0e4e606bd5d784f50f40d0 100644 (file)
   ""
   "*
 {
-  rtx xops[2];
+  rtx xops[3];
 
   xops[0] = operands[0];
-  xops[1] = constm1_rtx;
-  output_asm_insn (AS2 (mov%L0,%1,%0), xops);
-  return AS2 (bsf%L0,%1,%0);
+  xops[1] = operands[1];
+  xops[2] = constm1_rtx;
+  /* Can there be a way to avoid the jump here?  */
+  output_asm_insn (AS2 (bsf%L0,%1,%0), xops);
+  output_asm_insn (\"jnz 1f\", xops);
+  output_asm_insn (AS2 (mov%L0,%2,%0), xops);
+  output_asm_insn (\"1:\", xops);
+  return \"\";
 }")
 
 (define_expand "ffshi2"
   ""
   "*
 {
-  rtx xops[2];
+  rtx xops[3];
 
   xops[0] = operands[0];
-  xops[1] = constm1_rtx;
-  output_asm_insn (AS2 (mov%W0,%1,%0), xops);
-  return AS2 (bsf%W0,%1,%0);
+  xops[1] = operands[1];
+  xops[2] = constm1_rtx;
+  output_asm_insn (AS2 (bsf%W0,%1,%0), xops);
+  output_asm_insn (\"jnz 1f\", xops);
+  output_asm_insn (AS2 (mov%W0,%2,%0), xops);
+  output_asm_insn (\"1:\", xops);
+  return \"\";
 }")
 \f
 ;; These patterns match the binary 387 instructions for addM3, subM3,