[LLVMdev] Confusion over ISelLowering of setcc
rafaelauler at gmail.com
Sun Apr 17 09:07:02 PDT 2011
And finally gets optimised to this:
> 0x3741240: i1,ch = CopyFromReg 0x37241a8, 0x3741640 [ID=6]
> 0x3741340: i1 = Constant<-1> [ID=2]
> 0x3741940: ch = setne
> 0x3741740: i64 = setcc 0x3741240, 0x3741340, 0x3741940
> 0x3741540: ch = BasicBlock<else 0x373c230> [ID=3]
> 0x3741140: ch = brcond 0x37241a8, 0x3741740, 0x3741540 [ID=8]
> Which is invalid as setcc should always return an i1 type. I'm unsure as
> to whether this is coming from the -1 constant turning the setcc into an
> i64, or just the ISelLowering being set up incorrectly.
> http://llvm.org/docs/CodeGenerator.html#targetlowering does indicate
> that the return type of setcc operations should be specified in this
> class, though I'm not sure how this should be done.
If you take a look at the TargetLowering class implementation
(lib/CodeGen/SelectionDAG/TargetLowering.cpp), the virtual member function
"getSetCCResultType()" is implemented as:
So, the default action for the target independent code generator is to
promote SetCC return types to the machine pointer type. Since this member
function is virtual, you may try overriding getSetCCResultType().
But I think SetCC returning a type different of i1 is not invalid because
you are in the lowering phase. In this phase, the code should comply to
machine constraints (or, in other words, whatever the machine instruction
selector can handle), and not the LLVM IR constraints.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev