[LLVMdev] Indirect branch instruction
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon Jan 15 11:38:06 PST 2007
Chris Lattner wrote:
>> Yes, that was the original question. But actually, for my purpose,
>> Chris' solution is functional enough. However, I looked into llvm-gcc
>> code and the switch instruction switches for all possible labels defined
>> in the method. Does LLVM is smart enough to realize that it switches on
>> the address of a label, therefore only has to generate a jmp in x86 or a
>> {mtctr, bctr} couple in powerpc?
>>
>
> I'm not sure what you mean. We do reasonable optimization of switch
> statements, but I'm sure there are cases we miss. If so, please let us
> know, so we can add them to lib/Target/README.txt
>
>
Two jumps are executed when using a switch statement for indirect branch:
the first jump goes to the right switch case, the second jumps to the
corresponding
label. However, indirect branches need only one jump: jumping to the
value contained
in a register for example (which contains the address of a label).
Nicolas
More information about the llvm-dev
mailing list