OSDN Git Service

* mn10300.c (const_8bit_operand): New function.
[pf3gnuchains/gcc-fork.git] / gcc / config / mn10300 / mn10300.md
index f023478..1547ad0 100644 (file)
      (zero_extract:SI (match_operand:QI 0 "general_operand" "R,d")
                      (match_operand 1 "const_int_operand" "")
                      (match_operand 2 "const_int_operand" "")))]
-  "INTVAL (operands[1]) <= 8 && INTVAL (operands[2]) <= 7"
+  "mask_ok_for_mem_btst (INTVAL (operands[1]), INTVAL (operands[2]))"
   "*
 {
   int len = INTVAL (operands[1]);
       len--;
     }
 
+  /* If the source operand is not a reg (ie it is memory), then extract the
+     bits from mask that we actually want to test.  Note that the mask will
+     never cross a byte boundary.  */
+  if (!REG_P (operands[0]))
+    {
+      if (mask & 0xff)
+       mask = mask & 0xff;
+      else if (mask & 0xff00)
+       mask = (mask >> 8) & 0xff;
+      else if (mask & 0xff0000)
+       mask = (mask >> 16) & 0xff;
+      else if (mask & 0xff000000)
+       mask = (mask >> 24) & 0xff;
+    }
+  
   xoperands[0] = operands[0];
   xoperands[1] = GEN_INT (mask);
   if (GET_CODE (operands[0]) == REG)
   [(set (cc0)
      (and:SI
        (subreg:SI (match_operand:QI 0 "general_operand" "R,d") 0)
-       (match_operand:SI 1 "const_int_operand" "")))]
+       (match_operand:SI 1 "const_8bit_operand" "")))]
   ""
   "@
   btst %1,%A0