[LLVMdev] Possible missed optimization?

Eli Friedman eli.friedman at gmail.com
Sat Sep 4 17:40:13 PDT 2010


On Sat, Sep 4, 2010 at 1:31 PM, Jakob Stoklund Olesen <stoklund at 2pi.dk> wrote:
>
> On Sep 4, 2010, at 11:21 AM, Borja Ferrer wrote:
>
>> I've noticed this pattern happening with other operators aswell, but used xor in this example. As i said before, i tried with different register allocation orders, but it will produce always the same result. GCC is emitting longer code, but since LLVM is so nearer to the optimal code sequence i wanted to reach it.
>
> In LLVM, copies are coalesced away as much as possible before registers are allocated, so the allocation order wouldn't affect it.
>
> Try looking at the output of -debug-only=regcoalescing to see what is going wrong.

If you want to take a look at this yourself, the issue is easy to
reproduce with Thumb1:
$ cat > test.c
typedef unsigned long long t;
t foo(t a, t b)
{
    t a4 = b^a^18;
    return a4;
}
$ clang -cc1 -triple thumbv5-u-u -S -O2 test.c -o -
[...]
	eors	r1, r3
	mov	r3, r0
	eors	r3, r2
	movs	r0, #18
	eors	r0, r3
	bx	lr
[...]

-Eli




More information about the llvm-dev mailing list