[PATCH] Added a new register class for Thumb PC-rel loads

Tilmann Scheller tscheller at apple.com
Thu Sep 5 04:54:04 PDT 2013


Hmm, thinking more about this, I think this is actually not what you really want.

I noticed two things:
(1) The test case produces the same code with and without the patch, so it’s actually not triggering the added code.
(2) I think the constraint is actually in the wrong place. Constraining the destination register of the ADR doesn’t guarantee you that the final register used by the MOV will be different from LR.

This is the relevant code in the test case:

        adr.w   r3, LJTI0_0_0
        adds    r1, #4
        movs    r2, #0
        movs    r4, #0
        add.w   r5, r3, r0, lsl #2
                                        @ implicit-def: R3
        mov     pc, r5

As you can see there is an ADD between the ADR and the MOV and the jump target ends up in r5 rather than r3. Nothing prevents the register allocator from choosing LR instead of r5.

I’m not familiar with the jump table code, so I can’t really say what’s the easiest way to achieve what you want. 

Anyone else who can comment on that?

I’ll revert the patch for now.

Regards,

Tilmann


On Sep 5, 2013, at 1:20 PM, Tilmann Scheller <tscheller at apple.com> wrote:

> Yeah, that’s what I was thinking too.
> 
> I changed the commit message a bit, since this is actually using the ADR instruction (not a load) and committed in in 190043.
> 
> Thanks,
> 
> Tilmann
> 
> On Sep 4, 2013, at 10:49 PM, Daniel Stewart <stewartd at codeaurora.org> wrote:
> 
>> No, not an easy test case to reduce at all. This is actually as reduced as I could get it.
>> 
>> Daniel
>> 
>> From: Renato Golin [mailto:renato.golin at linaro.org] 
>> Sent: Wednesday, September 04, 2013 3:43 PM
>> To: Tilmann Scheller
>> Cc: Daniel Stewart; Commits
>> Subject: Re: [PATCH] Added a new register class for Thumb PC-rel loads
>> 
>> LGTM.
>> 
>> 
>> On 4 September 2013 20:38, Tilmann Scheller <tscheller at apple.com> wrote:
>> I assume there’s not much you can do to reduce your test case even further, right?
>> 
>> That's not an easy case to reduce, unfortunately.
>> 
>> cheers,
>> --renato
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list