Help understanding verification error for fcmp

I’m using TVM to generate LLVM IR code through the LLVM module API. For one of the use-cases I’m working LLVM throws a verification error:

Invalid operand types for FCmp instruction
  %166 = fcmp oeq i8* %32, %165

I was not able to get help on the TVM forum, so I thought I might try here. Here’s the complete LLVM IR subroutine:

assert_end59:                                     ; preds = %assert_end57
  %164 = getelementptr inbounds %0, %0* %19, i64 0, i32 0
  %165 = load i8*, i8** %164, align 8
  %166 = fcmp oeq i8* %32, %165
  br i1 %166, label %assert_end61, label %assert_fail60, !prof !5

Am I correct in understanding that the operands of %166 should be floating point values or arrays of floating point values, but they are both int8 pointers? What should the correct behavior be in this case?

If my understanding is correct then there might be an error upstream in how TVM generates LLVM modules which resulted in either a faulty fcmp instead of icmp or a missing cast to floating point. At a high level, the TVM graph representation looks correct.


I’m going to necromance this thread in the spirit of trying to avoid beginner questions with no answers. :slight_smile:

Yes, you are correct; fcmp expects floating point scalar or vector types. FCmpInst checks this explicitly:

    // Check that the operands are the right type
    assert(getOperand(0)->getType()->isFPOrFPVectorTy() &&
           "Invalid operand types for FCmp instruction");

So yes, this IR is invalid, since the inputs are not FP. TVM probably has/had a bug here.