This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Combine misses commutativity
- From: "Paulo J. Matos" <paulo at matos-sorge dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 10 Feb 2012 16:57:48 +0000 (UTC)
- Subject: Combine misses commutativity
Hi,
I just noticed something strange with my iorqi3 rule.
I have the following:
(define_insn "iorqi3"
[(set (match_operand:QI 0 "register_operand" "=c")
(ior:QI (match_operand:QI 1 "register_operand" "%0")
(match_operand:QI 2 "general_operand" "cwmi")))
(clobber (reg:CC RCC))]
""
"or\\t%0,%f2")
However, there's a failure to combine looking like:
(parallel [
(set (reg:QI 1 AL)
(ior:QI (mem/c/i:QI (reg/f:QI 4 AP) [2 y+0 S1 A16])
(reg:QI 30 [ x+1 ])))
(clobber (reg:CC 13 CC))
])
I am pretty sure that this combine should be successful. It's just a
matter of inverting the operands. This is proved by the fact that if I
instead of the above, I have:
(define_insn "iorqi3"
[(set (match_operand:QI 0 "register_operand" "=c")
(ior:QI (match_operand:QI 1 "register_operand" "0")
(match_operand:QI 2 "general_operand" "cwmi")))
(clobber (reg:CC RCC))]
""
"or\\t%0,%f2")
(define_insn "*iorqi3_inv"
[(set (match_operand:QI 0 "register_operand" "=c")
(ior:QI (match_operand:QI 1 "general_operand" "cwmi")
(match_operand:QI 2 "register_operand" "0")))
(clobber (reg:CC RCC))]
""
"or\\t%0,%f1")
combine reports success:
Successfully matched this instruction:
(parallel [
(set (reg:QI 1 AL)
(ior:QI (mem/c/i:QI (reg/f:QI 4 AP) [2 y+0 S1 A16])
(reg:QI 30 [ x+1 ])))
(clobber (reg:CC 13 CC))
However, duplicating the instructions and inverting operand order seems
to defeat the purpose of '%'. So, what's the catch? Or is it a genuine
bug?
Cheers,
--
PMatos