NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-vax/46677: gcc bug with builtin ffs on vax.



This seems to help.

Index: gnu/dist/gcc4/gcc/config/vax/builtins.md
===================================================================
--- gnu/dist/gcc4/gcc/config/vax/builtins.md    (revision 254596)
+++ gnu/dist/gcc4/gcc/config/vax/builtins.md    (working copy)
@@ -25,7 +25,7 @@
   "
 {
   rtx label = gen_label_rtx ();
-  emit_insn (gen_ffssi2_internal (operands[0], operands[1], operands[0]));
+  emit_insn (gen_ffssi2_internal (operands[0], operands[1], operands[1]));
   emit_jump_insn (gen_bne (label));
   emit_insn (gen_negsi2 (operands[0], const1_rtx));
   emit_label (label);
@@ -36,6 +36,6 @@
 (define_insn "ffssi2_internal"
   [(set (match_operand:SI 0 "nonimmediate_operand" "=g")
         (ffs:SI (match_operand:SI 1 "general_operand" "nrQ")))
-   (set (cc0) (match_operand:SI 2 "nonimmediate_operand" "0"))]
+   (set (cc0) (ffs:SI (match_operand:SI 2 "general_operand" "1")))]
   ""
   "ffs $0,$32,%1,%0")


The reason is that, according to the GCC internals documentation, "parallel" 
means the operations are done in parallel, i.e., first all the inputs are 
computed and then all the outputs are set.  So the original code (which sets 
cc0 based on the output operand of the FFS) would set cc0 based on the previous 
value, NOT based on the result of the ffs.  The changed code says that the 
condition code is set based on the ffs answer.

It looks like it works correctly, judging by the generated assembly code.

        paul



Home | Main Index | Thread Index | Old Index