For now give up on predicated values when doing PRE (there's a
similar hunk in PHI-translation already).  I need to sit down
and decide whether it's worth handling them or whether we'd
better prune them from the hash tables when assigning value-ids.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

2018-08-28  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/87117
        * tree-ssa-pre.c (compute_avail): Do not make expressions
        with predicated values available.
        (get_expr_value_id): Assert we do not run into predicated value
        expressions.

        * gcc.dg/pr87117-2.c: New testcase.

Index: gcc/tree-ssa-pre.c
===================================================================
--- gcc/tree-ssa-pre.c  (revision 263906)
+++ gcc/tree-ssa-pre.c  (working copy)
@@ -663,6 +663,7 @@ get_expr_value_id (pre_expr expr)
       id = VN_INFO (PRE_EXPR_NAME (expr))->value_id;
       break;
     case NARY:
+      gcc_assert (!PRE_EXPR_NARY (expr)->predicated_values);
       id = PRE_EXPR_NARY (expr)->value_id;
       break;
     case REFERENCE:
@@ -3902,7 +3903,7 @@ compute_avail (void)
                        continue;
 
                      vn_nary_op_lookup_stmt (stmt, &nary);
-                     if (!nary)
+                     if (!nary || nary->predicated_values)
                        continue;
 
                      /* If the NARY traps and there was a preceding
Index: gcc/testsuite/gcc.dg/pr87117-2.c
===================================================================
--- gcc/testsuite/gcc.dg/pr87117-2.c    (nonexistent)
+++ gcc/testsuite/gcc.dg/pr87117-2.c    (working copy)
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fcode-hoisting" } */
+
+void e();
+
+void a(int c, char **d)
+{
+  char b;
+  if (1 < c)
+    b = (char)(__INTPTR_TYPE__)d[0];
+  if (1 < c && b)
+    e();
+  while (1 < c)
+    ;
+}

Reply via email to