aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--sparse-llvm.c23
-rw-r--r--validation/backend/logical-ops.c2
2 files changed, 19 insertions, 6 deletions
diff --git a/sparse-llvm.c b/sparse-llvm.c
index b015ea3c..a85dfea5 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -375,12 +375,27 @@ static void output_op_binary(struct function *fn, struct instruction *insn)
assert(!symbol_is_fp_type(insn->type));
target = LLVMBuildXor(fn->builder, lhs, rhs, target_name);
break;
- case OP_AND_BOOL:
- assert(0);
+ case OP_AND_BOOL: {
+ LLVMValueRef x, y;
+
+ assert(!symbol_is_fp_type(insn->type));
+
+ y = LLVMBuildICmp(fn->builder, LLVMIntNE, lhs, LLVMConstInt(LLVMTypeOf(lhs), 0, 0), "y");
+ x = LLVMBuildICmp(fn->builder, LLVMIntNE, rhs, LLVMConstInt(LLVMTypeOf(rhs), 0, 0), "x");
+
+ target = LLVMBuildAnd(fn->builder, y, x, target_name);
break;
- case OP_OR_BOOL:
- assert(0);
+ }
+ case OP_OR_BOOL: {
+ LLVMValueRef tmp;
+
+ assert(!symbol_is_fp_type(insn->type));
+
+ tmp = LLVMBuildOr(fn->builder, rhs, lhs, "tmp");
+
+ target = LLVMBuildICmp(fn->builder, LLVMIntNE, tmp, LLVMConstInt(LLVMTypeOf(tmp), 0, 0), target_name);
break;
+ }
/* Binary comparison */
case OP_SET_EQ:
diff --git a/validation/backend/logical-ops.c b/validation/backend/logical-ops.c
index 1a0e9244..8b2a6a85 100644
--- a/validation/backend/logical-ops.c
+++ b/validation/backend/logical-ops.c
@@ -1,4 +1,3 @@
-#if 0
static int and_bool(int x, int y)
{
return x && y;
@@ -18,7 +17,6 @@ static unsigned int uor_bool(unsigned int x, unsigned int y)
{
return x || y;
}
-#endif
/*
* check-name: Logical operator code generation