Q:

llc - expected value token error

I'm getting this message when I try to llc my example.ll file:
llc: example.ll:12:29: error: expected value token
%1 = icmp slt i1 %cmptmp, i16 0
                          ^

The example.ll file:
; ModuleID = 'modulle'

define i16 @main() {
entry:
  %x = alloca i16
  store i16 2, i16* %x
  br label %loop_condition

loop_condition:                                   ; preds = %loop, %entry
  %0 = load i16, i16* %x
  %cmptmp = icmp sgt i16 %0, 1
  %1 = icmp slt i1 %cmptmp, i16 0
  br i1 %1, label %loop, label %while_continue

loop:                                             ; preds = %loop_condition
  br label %loop_condition

while_continue:                                   ; preds = %loop_condition
  ret i16 0
}

When I remove i16 everything works fine, but I don't know why LLVM insert that in my code. Does anybody know what's the problem?
--- UPDATE ---
The .ll output is from my toy compiler. This is the code for lines 11 and 12:
Value *cond = llvm::CmpInst::Create(llvm::Instruction::ICmp, llvm::CmpInst::ICMP_SLT, binRelOpCond, llvm::ConstantInt::get(llvm::getGlobalContext(), llvm::APInt(16, 0, true)), "", codeGenContext.getBlock());

where binRelOpCond variable is:
CmpInst *compareRes = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_SGT, left, right, "cmptmp", codeGenContext.getBlock());

Thanks.

A:

That ll file is malformed. icmp's syntax doesn't have a type for each operand, just a single type for both:
<result> = icmp <cond> <ty> <op1>, <op2>

Looking at the code you added in the comment which generated the ll, the bug is with llvm::APInt(16, 0, true) - you're explicitly creating a constant of type i16, but you may only compare with a constant of type i1 since that's %cmptmp's type. I don't know why no assertion caught that, though.

