This is minor tweak to support 8-bit parity.

Otherwise, the input operand of 8-bit values will be extended before parity
computation.

The final representation as libgcc call is not generated in split1 and no more
in expand. Notice that

- combine is not allowed to propagate hard regs into zero-extends.
- combine does not try parity:QI

Ok for trunk?

Johann

        * config/avr/avr.md (parityhi2): Expand allowing pseudos.
        (*parityhi2): New pre-reload insn-and-split to map 16-bit parity
        to the libgcc insn.
        (*parityqihi2): Same for 8-bit parity.


Index: config/avr/avr.md
===================================================================
--- config/avr/avr.md	(revision 180605)
+++ config/avr/avr.md	(working copy)
@@ -4288,15 +4288,41 @@ (define_insn "delay_cycles_4"
 
 ;; Parity
 
+;; Postpone expansion of 16-bit parity to libgcc call until after combine for
+;; better 8-bit parity recognition.
+
 (define_expand "parityhi2"
+  [(parallel [(set (match_operand:HI 0 "register_operand" "")
+                   (parity:HI (match_operand:HI 1 "register_operand" "")))
+              (clobber (reg:HI 24))])])
+
+(define_insn_and_split "*parityhi2"
+  [(set (match_operand:HI 0 "register_operand"           "=r")
+        (parity:HI (match_operand:HI 1 "register_operand" "r")))
+   (clobber (reg:HI 24))]
+  "!reload_completed"
+  { gcc_unreachable(); }
+  "&& 1"
   [(set (reg:HI 24)
-        (match_operand:HI 1 "register_operand" ""))
+        (match_dup 1))
    (set (reg:HI 24)
         (parity:HI (reg:HI 24)))
-   (set (match_operand:HI 0 "register_operand" "")
-        (reg:HI 24))]
-  ""
-  "")
+   (set (match_dup 0)
+        (reg:HI 24))])
+
+(define_insn_and_split "*parityqihi2"
+  [(set (match_operand:HI 0 "register_operand"           "=r")
+        (parity:HI (match_operand:QI 1 "register_operand" "r")))
+   (clobber (reg:HI 24))]
+  "!reload_completed"
+  { gcc_unreachable(); }
+  "&& 1"
+  [(set (reg:QI 24)
+        (match_dup 1))
+   (set (reg:HI 24)
+        (zero_extend:HI (parity:QI (reg:QI 24))))
+   (set (match_dup 0)
+        (reg:HI 24))])
 
 (define_expand "paritysi2"
   [(set (reg:SI 22)

Reply via email to