|| REG_NOTE_KIND (note) == REG_EQUIV)
{
insn_propagation prop (use_insn->rtl (), m_dest, m_src);
- return (prop.apply_to_rvalue (&XEXP (note, 0))
+ return (prop.apply_to_note (&XEXP (note, 0))
&& (can_propagate || prop.num_replacements == 0));
}
return true;
return res;
}
+/* Like apply_to_rvalue, but specifically for the case where *LOC is in
+ a note. This never changes the INSN_CODE. */
+
+bool
+insn_propagation::apply_to_note (rtx *loc)
+{
+ auto old_code = INSN_CODE (insn);
+ bool res = apply_to_rvalue (loc);
+ if (INSN_CODE (insn) != old_code)
+ INSN_CODE (insn) = old_code;
+ return res;
+}
+
/* Check whether INSN matches a specific alternative of an .md pattern. */
bool
insn_propagation (rtx_insn *, rtx, rtx, bool = true);
bool apply_to_pattern (rtx *);
bool apply_to_rvalue (rtx *);
+ bool apply_to_note (rtx *);
/* Return true if we should accept a substitution into the address of
memory expression MEM. Undoing changes OLD_NUM_CHANGES and up restores
for (const insn_change *change : changes)
if (!change->is_deletion ())
{
- fprintf (dump_file, " %c %d", sep, change->new_cost);
+ if (INSN_CODE (change->rtl ()) == NOOP_MOVE_INSN_CODE)
+ fprintf (dump_file, " %c nop", sep);
+ else
+ fprintf (dump_file, " %c %d", sep, change->new_cost);
sep = '+';
}
if (weighted_new_cost != 0)
--- /dev/null
+// { dg-additional-options "-fschedule-insns -fno-thread-jumps -fno-dce" }
+
+int a, b, c;
+volatile int d;
+int e(int f, int g) { return g > 1 ? 1 : f >> g; }
+int main() {
+ int *i = &a;
+ long j[1];
+ if (a)
+ while (1) {
+ a ^= 1;
+ if (*i)
+ while (1)
+ ;
+ b = c && e((d, 1) >= 1, j[0]);
+ }
+ return 0;
+}