aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2016-12-14 22:57:35 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-06-28 18:55:41 +0200
commita3e062b5803154e05f127a91b2aba6dcc51eb3d1 (patch)
tree3351eda530a0f2fea54cc713b0260de1ff12a3ed
parent22a058c697d310797c6af326345c68739778b7c4 (diff)
downloadsparse-dev-a3e062b5803154e05f127a91b2aba6dcc51eb3d1.tar.gz
bool: remove OP_{AND,OR}_BOOL instructions
Now that these instructions are not generated anymore, we can remove all related code, defines and doc. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--Documentation/IR.rst8
-rw-r--r--cse.c4
-rw-r--r--example.c3
-rw-r--r--linearize.c2
-rw-r--r--linearize.h4
-rw-r--r--simplify.c23
-rw-r--r--sparse-llvm.c24
7 files changed, 2 insertions, 66 deletions
diff --git a/Documentation/IR.rst b/Documentation/IR.rst
index ff0ccdf2..0419ac41 100644
--- a/Documentation/IR.rst
+++ b/Documentation/IR.rst
@@ -125,14 +125,6 @@ They all follow the same signature:
.. op:: OP_XOR
Logical XOR
-Boolean ops
------------
-.. op:: OP_AND_BOOL
- Boolean AND
-
-.. op:: OP_OR_BOOL
- Boolean OR
-
Integer compares
----------------
They all have the following signature:
diff --git a/cse.c b/cse.c
index 231b7e86..848ac512 100644
--- a/cse.c
+++ b/cse.c
@@ -54,8 +54,7 @@ void cse_collect(struct instruction *insn)
case OP_AND: case OP_OR:
/* Binary logical */
- case OP_XOR: case OP_AND_BOOL:
- case OP_OR_BOOL:
+ case OP_XOR:
/* Binary comparison */
case OP_SET_EQ: case OP_SET_NE:
@@ -175,7 +174,6 @@ static int insn_compare(const void *_i1, const void *_i2)
/* commutative binop */
case OP_ADD:
case OP_MUL:
- case OP_AND_BOOL: case OP_OR_BOOL:
case OP_AND: case OP_OR:
case OP_XOR:
case OP_SET_EQ: case OP_SET_NE:
diff --git a/example.c b/example.c
index 6b645211..8a2b1ab4 100644
--- a/example.c
+++ b/example.c
@@ -43,8 +43,6 @@ static const char *opcodes[] = {
[OP_AND] = "and",
[OP_OR] = "or",
[OP_XOR] = "xor",
- [OP_AND_BOOL] = "and-bool",
- [OP_OR_BOOL] = "or-bool",
/* Binary comparison */
[OP_SET_EQ] = "seteq",
@@ -1402,7 +1400,6 @@ static void generate_one_insn(struct instruction *insn, struct bb_state *state)
case OP_ADD: case OP_MUL:
case OP_AND: case OP_OR: case OP_XOR:
- case OP_AND_BOOL: case OP_OR_BOOL:
generate_commutative_binop(state, insn);
break;
diff --git a/linearize.c b/linearize.c
index bd991450..194afe66 100644
--- a/linearize.c
+++ b/linearize.c
@@ -213,8 +213,6 @@ static const char *opcodes[] = {
[OP_AND] = "and",
[OP_OR] = "or",
[OP_XOR] = "xor",
- [OP_AND_BOOL] = "and-bool",
- [OP_OR_BOOL] = "or-bool",
/* Binary comparison */
[OP_SET_EQ] = "seteq",
diff --git a/linearize.h b/linearize.h
index 242cefb8..092e1ac2 100644
--- a/linearize.h
+++ b/linearize.h
@@ -178,9 +178,7 @@ enum opcode {
OP_AND,
OP_OR,
OP_XOR,
- OP_AND_BOOL,
- OP_OR_BOOL,
- OP_BINARY_END = OP_OR_BOOL,
+ OP_BINARY_END = OP_XOR,
/* floating-point comparison */
OP_FPCMP,
diff --git a/simplify.c b/simplify.c
index 6aa720b0..f8531043 100644
--- a/simplify.c
+++ b/simplify.c
@@ -489,12 +489,6 @@ static pseudo_t eval_insn(struct instruction *insn)
case OP_XOR:
res = left ^ right;
break;
- case OP_AND_BOOL:
- res = left && right;
- break;
- case OP_OR_BOOL:
- res = left || right;
- break;
/* Binary comparison */
case OP_SET_EQ:
@@ -637,11 +631,6 @@ static int simplify_constant_rightside(struct instruction *insn)
long long bits = sbit | (sbit - 1);
switch (insn->opcode) {
- case OP_OR_BOOL:
- if (value == 1)
- return replace_with_pseudo(insn, insn->src2);
- goto case_neutral_zero;
-
case OP_OR:
if ((value & bits) == bits)
return replace_with_pseudo(insn, insn->src2);
@@ -680,10 +669,6 @@ static int simplify_constant_rightside(struct instruction *insn)
case OP_MUL:
return simplify_mul_div(insn, value);
- case OP_AND_BOOL:
- if (value == 1)
- return replace_with_pseudo(insn, insn->src1);
- /* Fall through */
case OP_AND:
if (!value)
return replace_with_pseudo(insn, insn->src2);
@@ -753,13 +738,6 @@ static int simplify_binop_same_args(struct instruction *insn, pseudo_t arg)
case OP_OR:
return replace_with_pseudo(insn, arg);
- case OP_AND_BOOL:
- case OP_OR_BOOL:
- remove_usage(arg, &insn->src2);
- insn->src2 = value_pseudo(0);
- insn->opcode = OP_SET_NE;
- return REPEAT_CSE;
-
default:
break;
}
@@ -1197,7 +1175,6 @@ int simplify_instruction(struct instruction *insn)
switch (insn->opcode) {
case OP_ADD: case OP_MUL:
case OP_AND: case OP_OR: case OP_XOR:
- case OP_AND_BOOL: case OP_OR_BOOL:
canonicalize_commutative(insn);
if (simplify_binop(insn))
return REPEAT_CSE;
diff --git a/sparse-llvm.c b/sparse-llvm.c
index 937f4490..d28eb6e7 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -601,30 +601,6 @@ static void output_op_binary(struct function *fn, struct instruction *insn)
assert(!is_float_type(insn->type));
target = LLVMBuildXor(fn->builder, lhs, rhs, target_name);
break;
- case OP_AND_BOOL: {
- LLVMValueRef lhs_nz, rhs_nz;
- LLVMTypeRef dst_type;
-
- lhs_nz = LLVMBuildIsNotNull(fn->builder, lhs, LLVMGetValueName(lhs));
- rhs_nz = LLVMBuildIsNotNull(fn->builder, rhs, LLVMGetValueName(rhs));
- target = LLVMBuildAnd(fn->builder, lhs_nz, rhs_nz, target_name);
-
- dst_type = insn_symbol_type(insn);
- target = LLVMBuildZExt(fn->builder, target, dst_type, target_name);
- break;
- }
- case OP_OR_BOOL: {
- LLVMValueRef lhs_nz, rhs_nz;
- LLVMTypeRef dst_type;
-
- lhs_nz = LLVMBuildIsNotNull(fn->builder, lhs, LLVMGetValueName(lhs));
- rhs_nz = LLVMBuildIsNotNull(fn->builder, rhs, LLVMGetValueName(rhs));
- target = LLVMBuildOr(fn->builder, lhs_nz, rhs_nz, target_name);
-
- dst_type = insn_symbol_type(insn);
- target = LLVMBuildZExt(fn->builder, target, dst_type, target_name);
- break;
- }
default:
assert(0);
break;