re PR debug/52001 (Huge compile-time regression with var-tracking)
[gcc.git] / gcc / var-tracking.c
index e9b5ca886ae36547ea45626e555145c206caa69a..c6280e2c1f185121c08852b901187ab508f26ef1 100644 (file)
@@ -5334,6 +5334,10 @@ reverse_op (rtx val, const_rtx expr, rtx insn)
   if (!v || !cselib_preserved_value_p (v))
     return;
 
+  /* Use canonical V to avoid creating multiple redundant expressions
+     for different VALUES equivalent to V.  */
+  v = canonical_cselib_val (v);
+
   /* Adding a reverse op isn't useful if V already has an always valid
      location.  Ignore ENTRY_VALUE, while it is always constant, we should
      prefer non-ENTRY_VALUE locations whenever possible.  */