I stumbled over this while trying to fix one of the regressions for 4.9.

This peep2 pattern in the x86 backend is obviously broken as it does not have a mode on the zero_extend in the resulting insn. As a result, if/when this peep2 matches we get an unrecognized insn.

(define_peephole2
  [(set (match_operand:DI 0 "register_operand")
        (zero_extend:DI
          (mult:SI (match_operand:SI 1 "register_operand")
                   (match_operand:SI 2 "const_int_operand"))))]
  "TARGET_64BIT
   && exact_log2 (INTVAL (operands[2])) >= 0
   && REGNO (operands[0]) == REGNO (operands[1])
   && peep2_regno_dead_p (0, FLAGS_REG)"
  [(parallel [(set (match_dup 0)
                   (zero_extend (ashift:SI (match_dup 1) (match_dup 2))))
              (clobber (reg:CC FLAGS_REG))])]
  "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[2])));")


It's obvious the zero_extend should have been DImode. I searched i386.md for other occurrences but didn't find any (remaining modeless extensions were on the peep2 and define_split input side patterns).

Bootstrapped and regression tested on x86_64-unknown-linux-gnu. Installed as obvious. No testcase as triggering requires local hackery.

        * i386.md (simple LEA peephole2): Add missing mode to zero_extend
        for zero-extended MULT simple LEA pattern.


diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 6ac2802..ab5b33f 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -17464,7 +17464,7 @@
    && REGNO (operands[0]) == REGNO (operands[1])
    && peep2_regno_dead_p (0, FLAGS_REG)"
   [(parallel [(set (match_dup 0)
-                  (zero_extend (ashift:SI (match_dup 1) (match_dup 2))))
+                  (zero_extend:DI (ashift:SI (match_dup 1) (match_dup 2))))
              (clobber (reg:CC FLAGS_REG))])]
   "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[2])));")
 

Reply via email to