[hackers] [scc] Fix problems with identities about & || Roberto E. Vargas Caballero
commit 20b5535ad47415dae9f55e048cb0958be03bb9a1
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sun Sep 6 12:14:42 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sun Sep 6 21:59:37 2015 +0200
Fix problems with identities about &
The ones function was generating more problems, that the
problems it was fixing. At this moment there is a know bug,
because we are not expanding the most significant bit, so
some cases can be missed.
diff --git a/cc1/fold.c b/cc1/fold.c
index 17a6572..ab66987 100644
--- a/cc1/fold.c
+++ b/cc1/fold.c
_AT_@ -135,6 +135,16 @@ rshi(TINT l, TINT r, Type *tp)
return 1;
}
+static TUINT
+ones(int n)
+{
+ TUINT v;
+
+ for (v = 1; n--; v |= 1)
+ v <<= 1;
+ return v;
+}
+
static bool
foldint(int op, Symbol *res, TINT l, TINT r)
{
_AT_@ -360,20 +370,10 @@ commutative(int *op, Node **lp, Node **rp)
aux = l;
l = r;
r = aux;
- *rp = r;
- *lp = l;
break;
}
-}
-
-static TUINT
-ones(int n)
-{
- TUINT v;
-
- for (v = 1; n--; v |= 1)
- v <<= 1;
- return v;
+ *rp = r;
+ *lp = l;
}
static Node *
_AT_@ -462,7 +462,7 @@ identity(int *op, Node *lp, Node *rp)
return NULL;
case OBAND:
/* i & ~0 => i */
- if (cmpnode(rp, ones(lp->type->size * 8)))
+ if (cmpnode(rp, ~0))
goto free_right;
return NULL;
case OMOD:
Received on Sun Sep 06 2015 - 22:02:30 CEST
This archive was generated by hypermail 2.3.0
: Sun Sep 06 2015 - 22:12:11 CEST