[LLVMdev] Help me improve two-address code

Anton Korobeynikov anton at korobeynikov.info
Thu Apr 16 17:02:28 PDT 2009

Hello, Greg

> ... and assumed it was sufficient, since I saw no other targets making 
> special arrangements.
You need to mark you instruction as commutative. Almost all targets do
this. Something like this:

let isCommutable = 1 in { // X = ADD Y, Z  == X = ADD Z, Y
def ADD16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
                     "add.w\t{$src2, $dst|$dst, $src2}",
                     [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
                      (implicit SR)]>;

With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.

More information about the llvm-dev mailing list