new file mode 100644
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-ccp -fno-tree-dce -fno-tree-vrp" } */
+
+int a, b;
+int main() {
+ int c = 2, d, e = 0;
+ if (a)
+ e = 2;
+ int f, g = -(1L | (e && f && f & e));
+ if (g)
+ L:
+ g = c;
+ c = 0;
+ d = e * g;
+ if (d)
+ goto L;
+ while (e) {
+ int i = (a && b) * i;
+ }
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ftree-pre" } */
+
+int printf(const char *, ...);
+int a, b, c = 2, d, e, *f, g;
+void o() {
+ unsigned h = 1;
+ int j = -1, k, l = 1, m = 2, i;
+ while (c < 2)
+ ;
+L1:
+ k = h;
+ h = -1;
+ if (k < 2 && !c) {
+ printf("%d", k);
+ goto L1;
+ }
+ if (!j)
+ l = printf("0");
+ if (g)
+ k = 0;
+ if (a && k)
+ goto L2;
+ while (f) {
+ m = a;
+ d = i;
+ i = e;
+ f = &j;
+ L2:
+ if (d == l && !m)
+ l = b;
+ }
+ unsigned *n[1] = {&h};
+}
+int main() {
+ o();
+ return 0;
+}
@@ -1197,18 +1197,6 @@ get_or_alloc_expr_for_constant (tree constant)
return newexpr;
}
-/* Get or allocate a pre_expr for a piece of GIMPLE, and return it.
- Currently only supports constants and SSA_NAMES. */
-static pre_expr
-get_or_alloc_expr_for (tree t)
-{
- if (TREE_CODE (t) == SSA_NAME)
- return get_or_alloc_expr_for_name (t);
- else if (is_gimple_min_invariant (t))
- return get_or_alloc_expr_for_constant (t);
- gcc_unreachable ();
-}
-
/* Return the folded version of T if T, when folded, is a gimple
min_invariant or an SSA name. Otherwise, return T. */
@@ -2779,8 +2767,16 @@ create_component_ref_by_pieces (basic_block block, vn_reference_t ref,
static tree
find_or_generate_expression (basic_block block, tree op, gimple_seq *stmts)
{
- pre_expr expr = get_or_alloc_expr_for (op);
- unsigned int lookfor = get_expr_value_id (expr);
+ /* Constants are always leaders. */
+ if (is_gimple_min_invariant (op))
+ return op;
+
+ gcc_assert (TREE_CODE (op) == SSA_NAME);
+ vn_ssa_aux_t info = VN_INFO (op);
+ unsigned int lookfor = info->value_id;
+ if (value_id_constant_p (lookfor))
+ return info->valnum;
+
pre_expr leader = bitmap_find_leader (AVAIL_OUT (block), lookfor);
if (leader)
{
@@ -2808,7 +2804,7 @@ find_or_generate_expression (basic_block block, tree op, gimple_seq *stmts)
its operand values. */
if (temp->kind == NARY)
return create_expression_by_pieces (block, temp, stmts,
- get_expr_type (expr));
+ TREE_TYPE (op));
}
/* Defer. */