When looking for relations between equivalencies, a typo was causing the same bitmap to be checked for both operands, instead of the correct one for each.   This caused us to never notice relations between equivalences.

I also noticed that under some circumstances the relation dump would call blocks which were NULL and trap.. Also fixed.

bootstraps on x86_64-pc-linux-gnu with no regressions.  pushed.

Andrew

>From ce0b409f562cd09c67cc2dce74143a0f0647cde5 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacl...@redhat.com>
Date: Thu, 24 Jun 2021 11:13:47 -0400
Subject: [PATCH 3/3] Fix relation query of equivalences.

When looking for relations between equivalencies, a typo was causing
the wrong bitmap to be checked. Effect was is missed them.
Plus don't dump blocks which don't exist.

	* value-relation.cc (equiv_oracle::dump): Do not dump NULL blocks.
	(relation_oracle::find_relation_block): Check correct bitmap.
	(relation_oracle::dump): Do not dump NULL blocks.
---
 gcc/value-relation.cc | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc
index 3c8698f2a54..43fcab7995a 100644
--- a/gcc/value-relation.cc
+++ b/gcc/value-relation.cc
@@ -444,7 +444,7 @@ equiv_oracle::dump (FILE *f) const
 {
   fprintf (f, "Equivalency dump\n");
   for (unsigned i = 0; i < m_equiv.length (); i++)
-    if (m_equiv[i])
+    if (m_equiv[i] && BASIC_BLOCK_FOR_FN (cfun, i))
       {
 	fprintf (f, "BB%d\n", i);
 	dump (f, BASIC_BLOCK_FOR_FN (cfun, i));
@@ -757,9 +757,9 @@ relation_oracle::find_relation_block (unsigned bb, const_bitmap b1,
     {
       unsigned op1 = SSA_NAME_VERSION (ptr->op1 ());
       unsigned op2 = SSA_NAME_VERSION (ptr->op2 ());
-      if (bitmap_bit_p (b1, op1) && bitmap_bit_p (b1, op2))
+      if (bitmap_bit_p (b1, op1) && bitmap_bit_p (b2, op2))
 	return ptr->kind ();
-      if (bitmap_bit_p (b1, op2) && bitmap_bit_p (b1, op1))
+      if (bitmap_bit_p (b1, op2) && bitmap_bit_p (b2, op1))
 	return relation_swap (ptr->kind ());
     }
 
@@ -925,8 +925,9 @@ relation_oracle::dump (FILE *f) const
 {
   fprintf (f, "Relation dump\n");
   for (unsigned i = 0; i < m_relations.length (); i++)
-    {
-      fprintf (f, "BB%d\n", i);
-      dump (f, BASIC_BLOCK_FOR_FN (cfun, i));
-    }
+    if (BASIC_BLOCK_FOR_FN (cfun, i))
+      {
+	fprintf (f, "BB%d\n", i);
+	dump (f, BASIC_BLOCK_FOR_FN (cfun, i));
+      }
 }
-- 
2.17.2

Reply via email to