This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]