ref: 20b5535ad47415dae9f55e048cb0958be03bb9a1
parent: c40ecd533a2317a3db0b29c3ecdc6ffd0d8baeb4
author: Roberto E. Vargas Caballero <[email protected]>
date: Sun Sep 6 08:14:42 EDT 2015
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.
--- a/cc1/fold.c
+++ b/cc1/fold.c
@@ -135,6 +135,16 @@
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)
{
@@ -360,22 +370,12 @@
aux = l;
l = r;
r = aux;
- *rp = r;
- *lp = l;
break;
}
+ *rp = r;
+ *lp = l;
}
-static TUINT
-ones(int n)
-{
- TUINT v;
-
- for (v = 1; n--; v |= 1)
- v <<= 1;
- return v;
-}
-
static Node *
identity(int *op, Node *lp, Node *rp)
{
@@ -462,7 +462,7 @@
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: