[LLVMdev] selecting select_cc

Ralph Corderoy ralph at inputplus.co.uk
Tue Aug 22 03:36:03 PDT 2006


Hi Rafael,

> I am trying to add support for select_cc. In ARM it can be implemented
> with:
>
> mov $dst, $falseVal
> cmp $a, $b
> moveq $dst, $trueVal

The more normal ARM code, as produced by assembly writers and compilers
that I've seen, is

    cmp $a, $b
    moveq $dst, $trueVal
    movne $dst, $falseVal

e.g. at the end of a function returning r0

    orr r0, r0, #0x40
    cmp r0, #0xfe
    moveq r0, #1
    movne r0, #0

since only one mov instruction is executed and the logic is clearer to
the reader.  I may be out of date here, but a skipped instruction takes
one S-cycle whereas your always executed mov may take two S-cycles if a
register-controlled shift is used, and more if $dst is the PC.

Hopefully, it's no more difficult for LLVM to generate.

Cheers,


Ralph.

PS.  It's great to see LLVM gaining an ARM backend.





More information about the llvm-dev mailing list