@@ -3277,9 +3277,14 @@ has_dependence_note_reg_use (int regno)
static void
has_dependence_note_mem_dep (rtx mem ATTRIBUTE_UNUSED,
rtx pending_mem ATTRIBUTE_UNUSED,
- insn_t pending_insn ATTRIBUTE_UNUSED,
+ insn_t pending_insn,
ds_t ds ATTRIBUTE_UNUSED)
{
+ /* We're only interested in dependencies with the current producer.
+ We might get other insns that were saved in dependence context
+ as last_* or pending_* fields. */
+ if (INSN_UID (pending_insn) != INSN_UID (has_dependence_data.pro))
+ return;
if (!sched_insns_conditions_mutex_p (has_dependence_data.pro,
VINSN_INSN_RTX (has_dependence_data.con)))
{
@@ -3291,9 +3296,14 @@ has_dependence_note_mem_dep (rtx mem ATTRIBUTE_UNUSED,
/* Note a dependence. */
static void
-has_dependence_note_dep (insn_t pro ATTRIBUTE_UNUSED,
+has_dependence_note_dep (insn_t pro,
ds_t ds ATTRIBUTE_UNUSED)
{
+ /* We're only interested in dependencies with the current producer.
+ We might get other insns that were saved in dependence context
+ as last_* or pending_* fields. */
+ if (INSN_UID (pro) != INSN_UID (has_dependence_data.pro))
+ return;
if (!sched_insns_conditions_mutex_p (has_dependence_data.pro,
VINSN_INSN_RTX (has_dependence_data.con)))
{
new file mode 100644
@@ -0,0 +1,21 @@
+/* { dg-options "-Og -fPIC -fschedule-insns2 -fselective-scheduling2 -fno-tree-fre --param=max-sched-extend-regions-iters=10" } */
+void bar (unsigned int);
+
+void
+foo (void)
+{
+ char buf[1] = { 3 };
+ const char *p = buf;
+ const char **q = &p;
+ unsigned int ch;
+ switch (**q)
+ {
+ case 1: ch = 5; break;
+ case 2: ch = 4; break;
+ case 3: ch = 3; break;
+ case 4: ch = 2; break;
+ case 5: ch = 1; break;
+ default: ch = 0; break;
+ }
+ bar (ch);
+}