ref: c40ecd533a2317a3db0b29c3ecdc6ffd0d8baeb4
parent: 4343d4491f8251b0af5065d3898a2dc7cf8abf2f
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Sep 5 15:58:46 EDT 2015
Add more identities for shift operators
--- a/cc1/fold.c
+++ b/cc1/fold.c
@@ -423,13 +423,20 @@
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