scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit c40ecd533a2317a3db0b29c3ecdc6ffd0d8baeb4
parent 4343d4491f8251b0af5065d3898a2dc7cf8abf2f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat,  5 Sep 2015 19:58:46 +0200

Add more identities for shift operators

Diffstat:
Mcc1/fold.c | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/cc1/fold.c b/cc1/fold.c @@ -423,13 +423,20 @@ identity(int *op, Node *lp, Node *rp) return NULL; case OSHL: case OSHR: + /* + * i >> 0 => i (free right) + * i << 0 => i (free right) + * 0 >> i => 0 (free right) + * 0 << i => 0 (free right) + */ + if (iszeror | iszerol) + goto free_right; + return NULL; case OBXOR: case OADD: case OBOR: case OSUB: /* - * i >> 0 => i - * i << 0 => i * i + 0 => i * i - 0 => i * i | 0 => i