[PATCH 10/10] bool: remove OP_{AND,OR}_BOOL instructions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 Documentation/IR.rst |  8 --------
 cse.c                |  4 +---
 example.c            |  3 ---
 linearize.c          |  2 --
 linearize.h          |  4 +---
 simplify.c           | 23 -----------------------
 sparse-llvm.c        | 24 ------------------------
 7 files changed, 2 insertions(+), 66 deletions(-)

diff --git a/Documentation/IR.rst b/Documentation/IR.rst
index ff0ccdf24..0419ac411 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 231b7e869..848ac5125 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 6b645211f..8a2b1ab46 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 bd9914507..194afe664 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 242cefb8f..092e1ac23 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 89532646a..512df6310 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:
@@ -644,11 +638,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);
@@ -687,10 +676,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);
@@ -760,13 +745,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;
 	}
@@ -1204,7 +1182,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 937f4490c..d28eb6e7a 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;
-- 
2.18.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux