Hello, while testing trivial functions in my backend i noticed a suboptimal way of assigning regs that had the following pattern, consider the following function:<br><br>typedef unsigned short t;<br>t foo(t a, t b)<br>{<br>
t a4 = b^a^18;<br> return a4;<br>}<br><br>Argument "a" is passed in R15:R14 and argument "b" is passed in R13:R12, the return value is stored in R15:R14.<br><br>Producing the following asm code:<br>
xor r15, r13 ; xor top part<br> mov r8, r14<br> xor r8, r12 ; xor bottom part<br> movi r14, 18<br> xor r14, r8 ; xor bottom part with imm value<br><br>However it could have produced:<br>
xor r15, r13<br> xor r14, r12<br> movi r8, 18<br> xor r14, r8<br><br>This saves the first move instruction by using any scratch register when moving the imm value instead of using r14 which is used as an incoming reg and as the return value. Is this a missed optimization from LLVM or did i miss something out?<br>
Changing the register allocation order didnt work.<br><br>Thanks<br>