[LLVMdev] Possible missed optimization?
Borja Ferrer
borja.ferav at gmail.com
Sat Sep 4 09:54:22 PDT 2010
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:
typedef unsigned short t;
t foo(t a, t b)
{
t a4 = b^a^18;
return a4;
}
Argument "a" is passed in R15:R14 and argument "b" is passed in R13:R12, the
return value is stored in R15:R14.
Producing the following asm code:
xor r15, r13 ; xor top part
mov r8, r14
xor r8, r12 ; xor bottom part
movi r14, 18
xor r14, r8 ; xor bottom part with imm value
However it could have produced:
xor r15, r13
xor r14, r12
movi r8, 18
xor r14, r8
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?
Changing the register allocation order didnt work.
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100904/a6db132b/attachment.html>
More information about the llvm-dev
mailing list