On 03/25/2011 11:49 AM, Richard Henderson wrote:
> On 03/25/2011 10:51 AM, Richard Sandiford wrote:
>> Thanks.  I think it needs to be s/!= 4/>= 6/ though, so that
>> match_scratches still work when 6 operands really are passed in.
> 
> For the record, I audited all setmem and movmem patterns.
> 
> There are is only one that uses 6 operands: i386.
> There are two that use 4 operands, but have 1 scratch: avr, pdp11.
> All the rest have exactly 4 operands.
> 
> I'll leave the test as == 6 for now.

I added a check to make sure that we don't get a 7 unexpectedly.

Committed as below.


r~
commit b52cb7196addd0e2bc281787a43dd9ce2b9b8cdc
Author: rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Mar 25 23:17:26 2011 +0000

            * expr.c (emit_block_move_via_movmem): Only use 6 operand variant
            if there are exactly 6 operands.
            (set_storage_via_setmem): Similarly.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171532 
138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e7983a2..040a83c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2011-03-25  Richard Henderson  <r...@redhat.com>
+
+       * expr.c (emit_block_move_via_movmem): Only use 6 operand variant
+       if there are exactly 6 operands.
+       (set_storage_via_setmem): Similarly.
+
 2011-03-25  Kai Tietz  <kti...@redhat.com>
 
        * collect2.c (write_c_file_stat): Handle backslash
diff --git a/gcc/expr.c b/gcc/expr.c
index 4db1c77..076b8d2 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -1294,16 +1294,20 @@ emit_block_move_via_movmem (rtx x, rtx y, rtx size, 
unsigned int align,
             that it doesn't fail the expansion because it thinks
             emitting the libcall would be more efficient.  */
          nops = insn_data[(int) code].n_operands;
+         /* ??? n_operands includes match_scratches; find some other
+            way to select the 6 operand variant, or force all targets
+            to have exactly 6 operands.  */
+         gcc_assert (nops >= 4 && nops <= 6);
+
          create_fixed_operand (&ops[0], x);
          create_fixed_operand (&ops[1], y);
          /* The check above guarantees that this size conversion is valid.  */
          create_convert_operand_to (&ops[2], size, mode, true);
          create_integer_operand (&ops[3], align / BITS_PER_UNIT);
-         if (nops != 4)
+         if (nops == 6)
            {
              create_integer_operand (&ops[4], expected_align / BITS_PER_UNIT);
              create_integer_operand (&ops[5], expected_size);
-             nops = 6;
            }
          if (maybe_expand_insn (code, nops, ops))
            {
@@ -2716,16 +2720,20 @@ set_storage_via_setmem (rtx object, rtx size, rtx val, 
unsigned int align,
          unsigned int nops;
 
          nops = insn_data[(int) code].n_operands;
+         /* ??? n_operands includes match_scratches; find some other
+            way to select the 6 operand variant, or force all targets
+            to have exactly 6 operands.  */
+         gcc_assert (nops >= 4 && nops <= 6);
+
          create_fixed_operand (&ops[0], object);
          /* The check above guarantees that this size conversion is valid.  */
          create_convert_operand_to (&ops[1], size, mode, true);
          create_convert_operand_from (&ops[2], val, byte_mode, true);
          create_integer_operand (&ops[3], align / BITS_PER_UNIT);
-         if (nops != 4)
+         if (nops == 6)
            {
              create_integer_operand (&ops[4], expected_align / BITS_PER_UNIT);
              create_integer_operand (&ops[5], expected_size);
-             nops = 6;
            }
          if (maybe_expand_insn (code, nops, ops))
            return true;

Reply via email to