Hi,

My architecture supports instructions with two parallel side effects.
For example, addition and subtraction can be done in parallel:

(define_insn "assi6"
  [(parallel [
     (set (match_operand:SI 0 "register_operand" "=r")
          (minus:SI (match_operand:SI 1 "register_operand" "r")
                    (match_operand:SI 2 "register_operand" "r")))
     (set (match_operand:SI 3 "register_operand" "=r")
          (plus:SI (match_operand:SI 4 "register_operand" "r")
                   (match_operand:SI 5 "register_operand" "r")))
  ])]
  ""
  "as\t%5, %4, %3, %2, %1, %0 %!"
)

This instruction is not chosen at ‘combine’ time even if ‘plus’ and
‘minus’ instructions are located one after other. That it is,
probably, there is no data dependency between them.

In attempt to resolve the problem, I am providing a peephole optimization:

(define_peephole2
  [
     (set (match_operand:SI 0 "register_operand")
          (minus:SI (match_operand:SI 1 "register_operand")
                    (match_operand:SI 2 "register_operand")))
     (set (match_operand:SI 3 "register_operand")
          (plus:SI (match_operand:SI 4 "register_operand")
                   (match_operand:SI 5 "register_operand")))
  ]
  ""
  [(parallel [
     (set (match_dup 0)
          (minus:SI (match_dup 1)
                    (match_dup 2)))
     (set (match_dup 3)
          (plus:SI (match_dup 4)
                   (match_dup 5)))
  ])]
  ""
)

This works for some cases, but I wanted to ask experts whether this is
the way to go. Repeating the same pattern for a peephole might be not
the best way to resolve the problem.

Did you observe something similar? What would be the best way to
resolve such situation?

Thank you,
Frank

Reply via email to