[PR,57809] Wasted work in omega_eliminate_red()
diff mbox

Message ID 3d2169b26938aa3d2aa3575bf745cf44.squirrel@webmail.cs.wisc.edu
State New
Headers show

Commit Message

pchang9@cs.wisc.edu July 19, 2013, 11:15 p.m. UTC
Hi,

The problem appears in revision 201034 in version 4.9.  I attached a
one-line patch that fixes it.  I also reported this problem
at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57809

I bootstrapped and ran the regression tests for this patch on x86_64-linux
and all tests pass.

In method "omega_eliminate_red()" in gcc/omega.c, the loop on line 2592
should break immediately after "red_found" is set to "1". All the
iterations after "red_found" set to "1" do not perform any useful work, at
best they just set "red_found" again to "1".

There are three more similar problems in the same file gcc/omega.c:

1. omega_problem_has_red_equations(): the loop on line 4854 should break
immediately after "result" is set to "true".

2. omega_problem_has_red_equations(): the loop on line 4907 should break
immediately after "result" is set to "true".

3. omega_query_variable(): the loop on line 5252 should break immediately
after "coupled" is set to "true".




-Chang
Index: gcc/omega.c
===================================================================
--- gcc/omega.c	(revision 201034)
+++ gcc/omega.c	(working copy)
@@ -2591,7 +2591,10 @@
 
   for (red_found = 0, e = pb->num_geqs - 1; e >= 0; e--)
     if (pb->geqs[e].color == omega_red)
-      red_found = 1;
+      {
+        red_found = 1;
+        break;
+      }
 
   if (!red_found)
     {
Index: gcc/omega.c
===================================================================
--- gcc/omega.c	(revision 201034)
+++ gcc/omega.c	(working copy)
@@ -4853,7 +4853,10 @@
 
   for (e = pb->num_geqs - 1; e >= 0; e--)
     if (pb->geqs[e].color == omega_red)
-      result = true;
+      {
+        result = true;
+        break;
+      }
 
   if (!result)
     return false;
Index: gcc/omega.c
===================================================================
--- gcc/omega.c	(revision 201034)
+++ gcc/omega.c	(working copy)
@@ -4906,7 +4906,10 @@
 
   for (e = pb->num_geqs - 1; e >= 0; e--)
     if (pb->geqs[e].color == omega_red)
-      result = true;
+      {
+        result = true;
+        break;
+      }
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
Index: gcc/omega.c
===================================================================
--- gcc/omega.c	(revision 201034)
+++ gcc/omega.c	(working copy)
@@ -5251,7 +5251,10 @@
 
   for (e = pb->num_subs - 1; e >= 0; e--)
     if (pb->subs[e].coef[i] != 0)
-      coupled = true;
+      {
+        coupled = true;
+        break;
+      }
 
   for (e = pb->num_eqs - 1; e >= 0; e--)
     if (pb->eqs[e].coef[i] != 0)

Patch
diff mbox

Index: gcc/omega.c
===================================================================
--- gcc/omega.c	(revision 201034)
+++ gcc/omega.c	(working copy)
@@ -2591,7 +2591,10 @@ 

   for (red_found = 0, e = pb->num_geqs - 1; e >= 0; e--)
     if (pb->geqs[e].color == omega_red)
-      red_found = 1;
+      {
+        red_found = 1;
+        break;
+      }

   if (!red_found)
     {
Index: gcc/omega.c
===================================================================
--- gcc/omega.c	(revision 201034)
+++ gcc/omega.c	(working copy)
@@ -4853,7 +4853,10 @@ 

   for (e = pb->num_geqs - 1; e >= 0; e--)
     if (pb->geqs[e].color == omega_red)
-      result = true;
+      {
+        result = true;
+        break;
+      }

   if (!result)
     return false;
Index: gcc/omega.c
===================================================================
--- gcc/omega.c	(revision 201034)
+++ gcc/omega.c	(working copy)
@@ -4906,7 +4906,10 @@ 

   for (e = pb->num_geqs - 1; e >= 0; e--)
     if (pb->geqs[e].color == omega_red)
-      result = true;
+      {
+        result = true;
+        break;
+      }

   if (dump_file && (dump_flags & TDF_DETAILS))
     {
Index: gcc/omega.c
===================================================================
--- gcc/omega.c	(revision 201034)
+++ gcc/omega.c	(working copy)
@@ -5251,7 +5251,10 @@ 

   for (e = pb->num_subs - 1; e >= 0; e--)
     if (pb->subs[e].coef[i] != 0)
-      coupled = true;
+      {
+        coupled = true;
+        break;
+      }

   for (e = pb->num_eqs - 1; e >= 0; e--)
     if (pb->eqs[e].coef[i] != 0)