Hi!

We ICE on the following testcase when using cselib, because
cselib_lookup* is never called on the PREFETCH argument, and
add_insn_mem_dependence calls cselib_subst_to_values on it, which
assumes cselib_lookup* already happened on it earlier.
For MEMs sched_analyze_2 calls cselib_lookup_from_insn, but for PREFETCHes
it didn't.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2013-01-28  Jakub Jelinek  <ja...@redhat.com>

        PR rtl-optimization/56117
        * sched-deps.c (sched_analyze_2) <case PREFETCH>: For use_cselib
        call cselib_lookup_from_insn on the MEM before calling
        add_insn_mem_dependence.

        * gcc.dg/pr56117.c: New test.

--- gcc/sched-deps.c.jj 2013-01-16 19:58:42.000000000 +0100
+++ gcc/sched-deps.c    2013-01-28 09:43:33.248657691 +0100
@@ -2720,8 +2720,12 @@ sched_analyze_2 (struct deps_desc *deps,
         prefetch has only the start address but it is better to have
         something than nothing.  */
       if (!deps->readonly)
-       add_insn_mem_dependence (deps, true, insn,
-                                gen_rtx_MEM (Pmode, XEXP (PATTERN (insn), 0)));
+       {
+         rtx x = gen_rtx_MEM (Pmode, XEXP (PATTERN (insn), 0));
+         if (sched_deps_info->use_cselib)
+           cselib_lookup_from_insn (x, Pmode, true, VOIDmode, insn);
+         add_insn_mem_dependence (deps, true, insn, x);
+       }
       break;
 
     case UNSPEC_VOLATILE:
--- gcc/testsuite/gcc.dg/pr56117.c.jj   2013-01-28 09:47:21.244381559 +0100
+++ gcc/testsuite/gcc.dg/pr56117.c      2013-01-28 09:46:31.000000000 +0100
@@ -0,0 +1,9 @@
+/* PR rtl-optimization/56117 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fsched2-use-superblocks" } */
+
+void
+foo (void *p)
+{
+  __builtin_prefetch (p);
+}

        Jakub

Reply via email to