@@ -451,6 +451,12 @@ region_model_manager::maybe_fold_binop (tree type, enum tree_code op,
if (cst1 && integer_onep (cst1))
return arg0;
break;
+ case BIT_AND_EXPR:
+ if (cst1)
+ if (zerop (cst1) && INTEGRAL_TYPE_P (type))
+ /* "(ARG0 & 0)" -> "0". */
+ return get_or_create_constant_svalue (build_int_cst (type, 0));
+ break;
case TRUTH_ANDIF_EXPR:
case TRUTH_AND_EXPR:
if (cst1)
new file mode 100644
@@ -0,0 +1,46 @@
+/* { dg-additional-options "-O2" } */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+typedef struct AMARK {
+ struct AMARK *m_next;
+ char m_name;
+} AMARK;
+
+struct buf {
+ AMARK *b_amark;
+};
+
+struct buf *curbp;
+
+int pamark(void) {
+ int c;
+ AMARK *p = curbp->b_amark;
+ AMARK *last = curbp->b_amark;
+
+ c = getchar();
+
+ while (p != (AMARK *)NULL && p->m_name != (char)c) {
+ last = p;
+ p = p->m_next;
+ }
+
+ if (p != (AMARK *)NULL) {
+ printf("over writing mark %c\n", c);
+ } else {
+ if ((p = (AMARK *)malloc(sizeof(AMARK))) == (AMARK *)NULL)
+ return 0;
+
+ p->m_next = (AMARK *)NULL;
+
+ if (curbp->b_amark == (AMARK *)NULL)
+ curbp->b_amark = p;
+ else
+ last->m_next = p;
+ }
+
+ p->m_name = (char)c;
+
+ return 1;
+}
new file mode 100644
@@ -0,0 +1,20 @@
+/* { dg-additional-options "-O1" } */
+
+struct List {
+ struct List *next;
+};
+
+void foo(struct List *p, struct List *q)
+{
+ while (p && p != q){
+ p = p->next;
+ }
+}
+
+int main()
+{
+ struct List x = {0};
+ foo(0, &x);
+ return 0;
+}
+
new file mode 100644
@@ -0,0 +1,24 @@
+/* { dg-additional-options "-O2" } */
+
+#include <stdlib.h>
+
+struct List {
+ struct List *next;
+};
+
+void foo(struct List *p, struct List *q)
+{
+ while (p && p != q){
+ struct List *next = p->next;
+ free(p);
+ p = next;
+ }
+}
+
+int main()
+{
+ struct List x = {0};
+ foo(NULL, &x);
+ return 0;
+}
+