ref: 03a906c70a3836ad264de982a5c7fc0bfe9cf0ef
parent: 7e3cb239304785b9a53e2e04709d34a7ad92815c
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Sep 4 18:47:56 EDT 2015
Fix algebraic identities about logical operators If the right part of a logic operator is a constant (which comes from the folding of some comparision), then the logic operator can be changed to a comma operator.
--- a/cc1/fold.c
+++ b/cc1/fold.c
@@ -377,10 +377,8 @@
}
/*
- * i || 0 => i,0
- * i || 1 => i
- * i && 0 => i,0
- * i && 1 => i
+ * i || k => i,k
+ * i && k => i,k
* i >> 0 => i
* i << 0 => i
* i + 0 => i
@@ -406,17 +404,10 @@
istrue = !iszero && rp->constant;
switch (*op) {
+ case OAND:
case OOR:
- if (istrue)
+ if (rp->constant)
goto change_to_comma;
- if (iszero)
- break;
- return NULL;
- case OAND:
- if (iszero)
- goto change_to_comma;
- if (istrue)
- break;
return NULL;
case OSHL:
case OSHR: