re PR lto/88087 (ICE in execute at tree-ssa-pre.c:4220 since r266183)
authorRichard Biener <rguenther@suse.de>
Tue, 20 Nov 2018 08:06:09 +0000 (08:06 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 20 Nov 2018 08:06:09 +0000 (08:06 +0000)
2018-11-20  Richard Biener  <rguenther@suse.de>

PR tree-optimization/88087
* tree-ssa-pre.c (create_expression_by_pieces): Re-materialize
call fntype.
* tree-ssa-sccvn.c (copy_reference_ops_from_call): Remember
call fntype.

* gcc.dg/tree-ssa/pr88087.c: New testcase.

From-SVN: r266301

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr88087.c [new file with mode: 0644]
gcc/tree-ssa-pre.c
gcc/tree-ssa-sccvn.c

index 712146fccb62878612df4386e5ccc33917dabce7..0c357fb4bed48c812975d75c2b0d7b21895c2e97 100644 (file)
@@ -1,3 +1,11 @@
+2018-11-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/88087
+       * tree-ssa-pre.c (create_expression_by_pieces): Re-materialize
+       call fntype.
+       * tree-ssa-sccvn.c (copy_reference_ops_from_call): Remember
+       call fntype.
+
 2018-11-20  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/88089
index 29e67449752977983761183226b7ec5519ad2438..4284ce25dab8c438329e75548d2341082d29033f 100644 (file)
@@ -1,3 +1,8 @@
+2018-11-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/88087
+       * gcc.dg/tree-ssa/pr88087.c: New testcase.
+
 2018-11-19  Paul Koning  <ni1d@arrl.net>
 
        * gcc.c-torture/execute/align-3.c: Skip if pdp11.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr88087.c b/gcc/testsuite/gcc.dg/tree-ssa/pr88087.c
new file mode 100644 (file)
index 0000000..d0061b6
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-pre-stats" } */
+
+int f();
+int d;
+void c()
+{
+  for (;;)
+    {
+      f();
+      int (*fp)() __attribute__((const)) = (void *)f;
+      d = fp();
+    }
+}
+
+/* We shouldn't ICE and hoist the const call of fp out of the loop.  */
+/* { dg-final { scan-tree-dump "Eliminated: 1" "pre" } } */
index 20d3c7807a1a49e8313eacf6a1064142e4b10ce5..4d5bce83a2c0749cd1ffcbb053cfe77dfa0edf29 100644 (file)
@@ -2792,9 +2792,10 @@ create_expression_by_pieces (basic_block block, pre_expr expr,
              args.quick_push (arg);
            }
          gcall *call = gimple_build_call_vec (fn, args);
+         gimple_call_set_fntype (call, currop->type);
          if (sc)
            gimple_call_set_chain (call, sc);
-         tree forcedname = make_ssa_name (currop->type);
+         tree forcedname = make_ssa_name (TREE_TYPE (currop->type));
          gimple_call_set_lhs (call, forcedname);
          /* There's no CCP pass after PRE which would re-compute alignment
             information so make sure we re-materialize this here.  */
index 43641916d5298ab53f4b3c84d73cc182acb8a8f0..01bedf56662aec710225298886b62ce7d2edb223 100644 (file)
@@ -1206,7 +1206,7 @@ copy_reference_ops_from_call (gcall *call,
 
   /* Copy the type, opcode, function, static chain and EH region, if any.  */
   memset (&temp, 0, sizeof (temp));
-  temp.type = gimple_call_return_type (call);
+  temp.type = gimple_call_fntype (call);
   temp.opcode = CALL_EXPR;
   temp.op0 = gimple_call_fn (call);
   temp.op1 = gimple_call_chain (call);