[LLVMdev] How can I remove these redundant copy between registers?

Samuel Crow samueldcrow at gmail.com
Thu May 21 09:24:36 PDT 2015


On May 21, 2015, at 7:21 AM, zan jyu Wong wrote:

> Hi, 
> 
> I've been working on a Blackfin backend (llvm-3.6.0) based on the previous one that was removed in llvm-3.1.
> llc generates codes like this:
> 
>  29     p1 = r2;
>  30     r5 = [p1];
>  31     p1 = r2;
>  32     r6 = [p1 + 4];
>  33     r5 = r6 + r5;
>  34     r6 = [p0 + -4];
>  35     r5 *= r6;
>  36     p1 = r2;
>  37     r6 = [p1 + 8];
>  38     p1 = r2;
> 
> p1 and r2 are in different register classes.
> A p* register can be used for load/stroe values from memory while a r* register can not.
> 
> As we can see, line 31, 36, 38 can be deleted. How can I configure llc to do this? Or do I have to write a custom pass to do this optimization? Any suggestion is welcome.
> 
> Thanks,
> 
> Huang

Hello Huang,

SIlly as this may sound, did you run OPT on the bitcode first before using LLC?

Cheers,

Sam



More information about the llvm-dev mailing list