diff options
| -rw-r--r-- | sparse-llvm.c | 17 | ||||
| -rw-r--r-- | validation/backend/pointer-cmp.c | 9 |
2 files changed, 24 insertions, 2 deletions
diff --git a/sparse-llvm.c b/sparse-llvm.c index 871ba62c..01a9ae22 100644 --- a/sparse-llvm.c +++ b/sparse-llvm.c @@ -588,14 +588,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); diff --git a/validation/backend/pointer-cmp.c b/validation/backend/pointer-cmp.c new file mode 100644 index 00000000..fa76d1b5 --- /dev/null +++ b/validation/backend/pointer-cmp.c @@ -0,0 +1,9 @@ +int cmpint( int x, int y) { return x == y; } +int cmpflt( float x, float y) { return x == y; } +int cmpvptr(void *x, void *y) { return x == y; } +int cmpiptr(int *x, int *y) { return x == y; } + +/* + * check-name: pointer comparison + * check-command: ./sparsec -Wno-decl -c $file -o tmp.o + */ |
