Selecting BRCOND instead of BRCC

Hi everyone,

I have the following code (as part of a larger function):
%0 = icmp eq i16 %a, 0 ; [#uses=1]
br i1 %0, label %bb1, label %bb

I would like to match this with a BRCOND, but all I get is an error message when compiling the above code that say:
LLVM ERROR: Cannot yet select: 0x170f200: ch = br_cc 0x170f000, 0x170ed00, 0x170dc60, 0x170ec00, 0x170ef00 [ID=19]
0x170f000: ch = TokenFactor 0x170e560, 0x170e760, 0x170e960 [ID=18]
0x170e560: ch = CopyToReg 0x16d5748, 0x170e460, 0x170df60 [ID=15]
0x16d5748: ch = EntryToken [ORD=1] [ID=0]
0x170e460: i16 = Register %reg16384 [ID=5]
0x170df60: i16,ch = CopyFromReg 0x16d5748, 0x170de60 [ID=12]
0x16d5748: ch = EntryToken [ORD=1] [ID=0]
0x170de60: i16 = Register %reg16388 [ID=2]
0x170e760: ch = CopyToReg 0x16d5748, 0x170e660, 0x170e160 [ID=16]
0x16d5748: ch = EntryToken [ORD=1] [ID=0]
0x170e660: i16 = Register %reg16385 [ID=6]
0x170e160: i16,ch = CopyFromReg 0x16d5748, 0x170e060 [ID=13]
0x16d5748: ch = EntryToken [ORD=1] [ID=0]
0x170e060: i16 = Register %reg16389 [ID=3]
0x170e960: ch = CopyToReg 0x16d5748, 0x170e860, 0x170e360 [ID=17]
0x16d5748: ch = EntryToken [ORD=1] [ID=0]
0x170e860: i16 = Register %reg16386 [ID=7]
0x170e360: i16,ch = CopyFromReg 0x16d5748, 0x170e260 [ID=14]
0x16d5748: ch = EntryToken [ORD=1] [ID=0]
0x170e260: i16 = Register %reg16390 [ID=4]
0x170ed00: ch = seteq [ORD=1] [ID=9]
0x170dc60: i16,ch = CopyFromReg 0x16d5748, 0x170db60 [ORD=1] [ID=11]
0x16d5748: ch = EntryToken [ORD=1] [ID=0]
0x170db60: i16 = Register %reg16387 [ORD=1] [ID=1]
0x170ec00: i16 = Constant<0> [ORD=1] [ID=8]
0x170ef00: ch = BasicBlock<bb1 0x170a5d8> [ID=10]

In my file I’m trying to match BRCOND as follows:
let isBranch = 1 in
def CondBranch : F3_1<2, 0b000101,
(ins IntRegs:$L, i16imm:$R, brtarget:$dst),
“; TODO: do conditional branching.”,
[(brcond (seteq IntRegs:$L, simm8:$R), bb:$dst)]>;

I know CondBranch only handles SETEQ, but it should still match the code above (which does “icmp eq”)? Or am I wrong?


/ Torgny

Hi Torgny,

You may want to check your TargetISelLowering, for the setOperationAction you have on BRCOND.

BR_CC is the result of the BRCOND expansion.

Best regards,