[PATCH 09/10] bool: generate plain OP_{AND,OR} instead of OP_{AND,OR}_BOOL

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

 



Now that OP_AND_BOOL and OP_OR_BOOL are always given boolean
operands, they are just a special case of 1 bit OP_AND & OP_OR.

To avoid to have to repeat CSE, simplification patterns, ...
better to generate plain OP_AND & OP_OR instead.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 linearize.c                        |  2 +-
 validation/optim/bool-context-fp.c |  8 ++++----
 validation/optim/bool-simplify.c   | 25 +++++++++++++++++++++++++
 validation/optim/bool-simplify2.c  |  4 ++--
 4 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/linearize.c b/linearize.c
index 726e911bc..bd9914507 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1487,7 +1487,7 @@ static pseudo_t linearize_call_expression(struct entrypoint *ep, struct expressi
 static pseudo_t linearize_binop_bool(struct entrypoint *ep, struct expression *expr)
 {
 	pseudo_t src1, src2, dst;
-	int op = (expr->op == SPECIAL_LOGICAL_OR) ? OP_OR_BOOL : OP_AND_BOOL;
+	int op = (expr->op == SPECIAL_LOGICAL_OR) ? OP_OR : OP_AND;
 
 	src1 = linearize_expression_to_bool(ep, expr->left);
 	src2 = linearize_expression_to_bool(ep, expr->right);
diff --git a/validation/optim/bool-context-fp.c b/validation/optim/bool-context-fp.c
index 6c80eeb17..6325ee365 100644
--- a/validation/optim/bool-context-fp.c
+++ b/validation/optim/bool-context-fp.c
@@ -53,7 +53,7 @@ bfior:
 	setfval.32  %r19 <- 0.000000
 	fcmpune.1   %r20 <- %arg1, %r19
 	fcmpune.1   %r23 <- %arg2, %r19
-	or-bool.1   %r24 <- %r20, %r23
+	or.1        %r24 <- %r20, %r23
 	ret.1       %r24
 
 
@@ -63,7 +63,7 @@ ifior:
 	setfval.32  %r29 <- 0.000000
 	fcmpune.1   %r30 <- %arg1, %r29
 	fcmpune.1   %r33 <- %arg2, %r29
-	or-bool.1   %r34 <- %r30, %r33
+	or.1        %r34 <- %r30, %r33
 	zext.32     %r35 <- (1) %r34
 	ret.32      %r35
 
@@ -74,7 +74,7 @@ bfand:
 	setfval.32  %r38 <- 0.000000
 	fcmpune.1   %r39 <- %arg1, %r38
 	fcmpune.1   %r42 <- %arg2, %r38
-	and-bool.1  %r43 <- %r39, %r42
+	and.1       %r43 <- %r39, %r42
 	ret.1       %r43
 
 
@@ -84,7 +84,7 @@ ifand:
 	setfval.32  %r48 <- 0.000000
 	fcmpune.1   %r49 <- %arg1, %r48
 	fcmpune.1   %r52 <- %arg2, %r48
-	and-bool.1  %r53 <- %r49, %r52
+	and.1       %r53 <- %r49, %r52
 	zext.32     %r54 <- (1) %r53
 	ret.32      %r54
 
diff --git a/validation/optim/bool-simplify.c b/validation/optim/bool-simplify.c
index 5b3cf449e..68aabb782 100644
--- a/validation/optim/bool-simplify.c
+++ b/validation/optim/bool-simplify.c
@@ -18,6 +18,17 @@ int or_1(int a)
 	return a || 1;
 }
 
+// try again but with something true but != 1
+int and_2(int a)
+{
+	return a && 2;
+}
+
+int or_2(int a)
+{
+	return a || 2;
+}
+
 /*
  * check-name: bool-simplify
  * check-command: test-linearize -Wno-decl $file
@@ -51,5 +62,19 @@ or_1:
 	ret.32      $1
 
 
+and_2:
+.L8:
+	<entry-point>
+	setne.1     %r26 <- %arg1, $0
+	zext.32     %r29 <- (1) %r26
+	ret.32      %r29
+
+
+or_2:
+.L10:
+	<entry-point>
+	ret.32      $1
+
+
  * check-output-end
  */
diff --git a/validation/optim/bool-simplify2.c b/validation/optim/bool-simplify2.c
index e015fe8ec..70b0587ea 100644
--- a/validation/optim/bool-simplify2.c
+++ b/validation/optim/bool-simplify2.c
@@ -16,9 +16,9 @@ foo:
 	<entry-point>
 	setne.1     %r2 <- %arg1, $0
 	setne.1     %r4 <- %arg2, $0
-	or-bool.1   %r5 <- %r2, %r4
+	or.1        %r5 <- %r2, %r4
 	setne.1     %r9 <- %arg3, $0
-	or-bool.1   %r10 <- %r5, %r9
+	or.1        %r10 <- %r5, %r9
 	zext.32     %r11 <- (1) %r10
 	ret.32      %r11
 
-- 
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