[LLVMdev] code generation removes duplicated instructions

Renato Golin renato.golin at arm.com
Wed Jul 6 07:27:17 PDT 2011


On 6 July 2011 14:55, D S Khudia <daya.khudia at gmail.com> wrote:
> The following is an example code generation for arm and x86 for a same IR
> BB. In the x86 code I can see that the same computation is done twice and
> result is stored in two different registers and then these two different
> registers are used for comparision.

Yes, but you shouldn't rely on it, since the compiler is free to
optimize that away.


> By the way I am duplicating instruction
> and inserting comparison to catch transient errors.

I thought so. Try running llc with -O0 or disable specific
optimizations (like dead-code elimination) to keep your comparisons
intact.

But since the two values are identical, it's possible that even so,
both will live in the same register.

cheers,
--renato




More information about the llvm-dev mailing list