* config/avr/avr.h (MOVE_MAX): Set value to 1.
        (MOVE_MAX_PIECES): Define.
        (MOVE_RATIO): Define.
        * config/avr/avr.c (TARGET_USE_BY_PIECES_INFRASTRUCTURE_P):
        Provide target hook.
        (avr_use_by_pieces_infrastructure_p): New function.
From-SVN: r231782
+2015-12-17  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
+
+       * config/avr/avr.h (MOVE_MAX): Set value to 1.
+       (MOVE_MAX_PIECES): Define.
+       (MOVE_RATIO): Define.
+       * config/avr/avr.c (TARGET_USE_BY_PIECES_INFRASTRUCTURE_P):
+       Provide target hook.
+       (avr_use_by_pieces_infrastructure_p): New function.
+
 2015-12-17  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
 
        * config.gcc: mark *-interix* as obsolete.
        * configure.ac: Remove checks for functions that exist in isl 0.13
        or later.
        * graphite-isl-ast-to-gimple.c: Remove #ifdefs and code for isl 0.12.
-        * graphite-optimize-isl.c: Same.
+       * graphite-optimize-isl.c: Same.
        * graphite-poly.c: Same.
        * graphite-sese-to-poly.c: Same.
        * graphite.h: Add comment for isl 0.14.
 
 }
 
 
+/* Implement TARGET_USE_BY_PIECES_INFRASTRUCTURE_P.  */
+
+/* Prefer sequence of loads/stores for moves of size upto
+   two - two pairs of load/store instructions are always better
+   than the 5 instruction sequence for a loop (1 instruction
+   for loop counter setup, and 4 for the body of the loop). */
+
+static bool
+avr_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT size,
+                                    unsigned int align ATTRIBUTE_UNUSED,
+                                    enum by_pieces_operation op,
+                                    bool speed_p)
+{
+
+  if (op != MOVE_BY_PIECES || (speed_p && (size > (MOVE_MAX_PIECES))))
+    return default_use_by_pieces_infrastructure_p (size, align, op, speed_p);
+
+  return size <= (MOVE_MAX_PIECES);
+}
+
+
 /* Worker function for `NOTICE_UPDATE_CC'.  */
 /* Update the condition code in the INSN.  */
 
 #undef  TARGET_PRINT_OPERAND_PUNCT_VALID_P
 #define TARGET_PRINT_OPERAND_PUNCT_VALID_P avr_print_operand_punct_valid_p
 
+#undef TARGET_USE_BY_PIECES_INFRASTRUCTURE_P
+#define TARGET_USE_BY_PIECES_INFRASTRUCTURE_P \
+  avr_use_by_pieces_infrastructure_p
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 \f
 
 
 #undef WORD_REGISTER_OPERATIONS
 
-#define MOVE_MAX 4
+/* Can move only a single byte from memory to reg in a
+   single instruction. */
+
+#define MOVE_MAX 1
+
+/* Allow upto two bytes moves to occur using by_pieces
+   infrastructure */
+
+#define MOVE_MAX_PIECES 2
+
+/* Set MOVE_RATIO to 3 to allow memory moves upto 4 bytes to happen
+   by pieces when optimizing for speed, like it did when MOVE_MAX_PIECES
+   was 4. When optimizing for size, allow memory moves upto 2 bytes. 
+   Also see avr_use_by_pieces_infrastructure_p. */
+
+#define MOVE_RATIO(speed) ((speed) ? 3 : 2)
 
 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1