]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/35659 (Miscompiled code with -O2 (but not with -O2 -funroll-loops) on...
authorMaxim Kuvyrkov <maxim@codesourcery.com>
Wed, 6 Aug 2008 06:23:47 +0000 (06:23 +0000)
committerMaxim Kuvyrkov <mkuvyrkov@gcc.gnu.org>
Wed, 6 Aug 2008 06:23:47 +0000 (06:23 +0000)
PR target/35659
* haifa-sched.c (sched_insn_is_legitimate_for_speculation_p): Move ...
* sched-deps.c (sched_insn_is_legitimate_for_speculation_p): ... here.
Don't allow predicated instructions for data speculation.
* sched-int.h (sched_insn_is_legitimate_for_speculation_p): Move
declaration.

From-SVN: r138759

gcc/ChangeLog
gcc/haifa-sched.c
gcc/sched-deps.c
gcc/sched-int.h

index fb238345559a3a7f82c5fd188e13be8762357ce0..7b50bdf77ad0e312283d622ad4133b0cbfb799dd 100644 (file)
@@ -1,3 +1,12 @@
+2008-08-06  Maxim Kuvyrkov  <maxim@codesourcery.com>
+
+       PR target/35659
+       * haifa-sched.c (sched_insn_is_legitimate_for_speculation_p): Move ...
+       * sched-deps.c (sched_insn_is_legitimate_for_speculation_p): ... here.
+       Don't allow predicated instructions for data speculation.
+       * sched-int.h (sched_insn_is_legitimate_for_speculation_p): Move
+       declaration.
+
 2008-08-06  Maxim Kuvyrkov  <maxim@codesourcery.com>
 
        * haifa-sched.c (extend_global): Split to extend_global_data and
index db1d66f49b84490ca9a11238a5641d4dfed97432..76282bd0ced7d41fe81302bd6d4101908afcf827 100644 (file)
@@ -4019,32 +4019,6 @@ change_pattern (rtx insn, rtx new_pat)
   dfa_clear_single_insn_cache (insn);
 }
 
-/* Return true if INSN can potentially be speculated with type DS.  */
-bool
-sched_insn_is_legitimate_for_speculation_p (const_rtx insn, ds_t ds)
-{
-  if (HAS_INTERNAL_DEP (insn))
-    return false;
-
-  if (!NONJUMP_INSN_P (insn))
-    return false;
-
-  if (SCHED_GROUP_P (insn))
-    return false;
-
-  if (IS_SPECULATION_CHECK_P (insn))
-    return false;
-
-  if (side_effects_p (PATTERN (insn)))
-    return false;
-
-  if ((ds & BE_IN_SPEC)
-      && may_trap_p (PATTERN (insn)))
-    return false;
-
-  return true;
-}
-
 /* -1 - can't speculate,
    0 - for speculation with REQUEST mode it is OK to use
    current instruction pattern,
index b8b3a4418dfc63325ef5a4a4383594fea9a825a8..bbd7a36a44132ba953b513c1378f2ff052a7599e 100644 (file)
@@ -536,6 +536,46 @@ sched_insns_conditions_mutex_p (const_rtx insn1, const_rtx insn2)
 }
 \f
 
+/* Return true if INSN can potentially be speculated with type DS.  */
+bool
+sched_insn_is_legitimate_for_speculation_p (const_rtx insn, ds_t ds)
+{
+  if (HAS_INTERNAL_DEP (insn))
+    return false;
+
+  if (!NONJUMP_INSN_P (insn))
+    return false;
+
+  if (SCHED_GROUP_P (insn))
+    return false;
+
+  if (IS_SPECULATION_CHECK_P (insn))
+    return false;
+
+  if (side_effects_p (PATTERN (insn)))
+    return false;
+
+  if (ds & BE_IN_SPEC)
+    /* The following instructions, which depend on a speculatively scheduled
+       instruction, cannot be speculatively scheduled along.  */
+    {
+      if (may_trap_p (PATTERN (insn)))
+       /* If instruction might trap, it cannot be speculatively scheduled.
+          For control speculation it's obvious why and for data speculation
+          it's because the insn might get wrong input if speculation
+          wasn't successful.  */
+       return false;
+
+      if ((ds & BE_IN_DATA)
+         && sched_get_condition (insn) != NULL_RTX)
+       /* If this is a predicated instruction, then it cannot be
+          speculatively scheduled.  See PR35659.  */
+       return false;
+    }
+
+  return true;
+}
+
 /* Initialize LIST_PTR to point to one of the lists present in TYPES_PTR,
    initialize RESOLVED_P_PTR with true if that list consists of resolved deps,
    and remove the type of returned [through LIST_PTR] list from TYPES_PTR.
index f2e39bf4fc3e39943ac9b6dbcea976ef7ce32999..bfbb86124561c5043e2a89112fe9071d92b55c87 100644 (file)
@@ -805,6 +805,7 @@ enum INSN_TRAP_CLASS
 
 /* Functions in sched-deps.c.  */
 extern bool sched_insns_conditions_mutex_p (const_rtx, const_rtx);
+extern bool sched_insn_is_legitimate_for_speculation_p (const_rtx, ds_t);
 extern void add_dependence (rtx, rtx, enum reg_note);
 extern void sched_analyze (struct deps *, rtx, rtx);
 extern bool deps_pools_are_empty_p (void);
@@ -838,7 +839,6 @@ extern void sched_finish (void);
 
 extern int try_ready (rtx);
 extern void * xrecalloc (void *, size_t, size_t, size_t);
-extern bool sched_insn_is_legitimate_for_speculation_p (const_rtx, ds_t);
 extern void unlink_bb_notes (basic_block, basic_block);
 extern void add_block (basic_block, basic_block);
 extern rtx bb_note (basic_block);