[LLVMdev] Using branches in lowered operations

Javier Martinez javier at jmartinez.org
Tue Dec 15 16:23:23 PST 2009

Hi Evan,

Thanks for the useful pointer. When trying to implement the example to my
situation I ran into a strange issue that I don't know how to resolve.

My target doesn't support 64-bit operations and so far all operations have
been expanded using LLVM except for division and remainder. For division,
LLVM only gives you the option of either calling an external library or
custom lowering the division. If the operation is custom lowered, because
the return type (i64) is not legal, LLVM ends up calling into
ReplaceNodeResults(). ReplaceNodeResults() has the restriction that the
result has to have the same number of values and types. This forces the
lowering function to return a target defined custom i64 node. At the next
legalization cycle ExpandIntegerResults() is called to expand this node
causing an assert because getOperationAction doesn't operate on custom

Am I doing something wrong? My goal is to provide an expansion for 64-bit
division that unfortunately uses branches for a target that doesn't support
64-bit integers.


On Thu, 10 Dec 2009 22:52:12 -0800, Evan Cheng <evan.cheng at apple.com>
> See X86InstrInfo.td
> let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
> def CMOV_GR8 : I<0, Pseudo,
> This creates a CMOV_GR8 pseudo instruction at isel time which can be
> expanded during scheduling time.
> Evan
> On Dec 10, 2009, at 11:46 AM, Javier Martinez wrote:
>> Hello,
>> My expansion for an operation uses if and loops. How do I introduce
>> branches in the target lowering stage? Do I have to create basic blocks,
>> add the instructions to them and and add them to the machine function's
>> basic block list?
>> Thanks,
>> Javier
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list