Moving between registers of different classes

Suppose I need to align an address register to even boundary. Since address
register can't be AND-ed with anything, I move the value into general purpose
register, to "and" and then move it into address register. Unfortunately, the
register allocator crashes. Here's machine code:

        %reg1030 = - %reg1027, 1
        %reg1031 = move %reg1030
        %reg1032 = + %reg1031, -2
        %reg1033 = move %reg1032
        %ar1 = load64 %gr1<def>, %reg1033

and here's assertion:

llc: LiveIntervals.cpp:507: void llvm::LiveIntervals::joinIntervals():
Assertion `rcA == rcB && "registers must be of the same class"' failed.
(gdb) up 4
(gdb) p *intA
$1 = (llvm::LiveInterval &) @0x8064698: {reg = 1030, weight = 0,
(gdb) p *intB
$2 = (llvm::LiveInterval &) @0x80646b8: {reg = 1031, weight = 0,

Is there anything I can do to make it work? Actually, it seems like a bug in
register allocator. If it can't coalesce intervals because there are
different register classes, it should just leave the move alone, not crash.

- Volodya

You are right, it shouldn't crash. The assert was added to check if the
x86 instructor selector ever did a move between two different register
classes and it was left there. Can you try the attached patch and let me
know if it works?

li.diff (1.57 KB)