https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106707

--- Comment #5 from Uroš Bizjak <ubizjak at gmail dot com> ---
The following pattern is matched by a peephole2 pattern:

(insn 164 161 165 5 (set (reg:DI 0 ax [orig:91 _10 ] [91])
        (reg:DI 0 ax)) "pr106707.c":13:12 82 {*movdi_internal}
     (expr_list:REG_UNUSED (reg:DI 0 ax [orig:91 _10 ] [91])
        (nil)))

and produces invalid RTL:

(insn 196 161 197 5 (parallel [
            (set (reg:DI 0 ax [orig:91 _10 ] [91])
                (reg:DI 0 ax))
            (set (reg:DI 0 ax)
                (reg:DI 0 ax [orig:91 _10 ] [91]))
        ]) "pr106707.c":13:12 -1
     (nil))

The fix is similar to the one proposed in Comment #4, but we can use:

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index a4a18cf89f5..1aef1af594d 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -3043,8 +3043,8 @@
   [(set (match_operand:SWI48 0 "general_reg_operand")
        (match_operand:SWI48 1 "general_reg_operand"))]
  "optimize_size > 1
-  && (REGNO (operands[0]) == AX_REG
-      || REGNO (operands[1]) == AX_REG)
+  && ((REGNO (operands[0]) == AX_REG)
+      != (REGNO (operands[1]) == AX_REG))
   && optimize_insn_for_size_p ()
   && peep2_reg_dead_p (1, operands[1])"
   [(parallel [(set (match_dup 0) (match_dup 1))

Reply via email to