@@ -587,14 +587,27 @@ static void output_op_compare(struct function *fn, struct instruction *insn)
LLVMTypeRef dst_type = insn_symbol_type(insn);
- if (LLVMGetTypeKind(LLVMTypeOf(lhs)) == LLVMIntegerTypeKind) {
+ switch (LLVMGetTypeKind(LLVMTypeOf(lhs))) {
+ case LLVMPointerTypeKind:
+ case LLVMIntegerTypeKind: {
LLVMIntPredicate op = translate_op(insn->opcode);
target = LLVMBuildICmp(fn->builder, op, lhs, rhs, target_name);
- } else {
+ break;
+ }
+ case LLVMHalfTypeKind:
+ case LLVMFloatTypeKind:
+ case LLVMDoubleTypeKind:
+ case LLVMX86_FP80TypeKind:
+ case LLVMFP128TypeKind:
+ case LLVMPPC_FP128TypeKind: {
LLVMRealPredicate op = translate_fop(insn->opcode);
target = LLVMBuildFCmp(fn->builder, op, lhs, rhs, target_name);
+ break;
+ }
+ default:
+ assert(0);
}
target = LLVMBuildZExt(fn->builder, target, dst_type, target_name);
In output_op_compare() everything that is not of interger type is treated as floats, pointers disagree. Fix this by rearranging the code and use a switch to easily treat pointers like integers as required for LLVM's icmp. Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- sparse-llvm.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)