// fork from bug 22230
// fails with        -O1
// doesn't fail with -O1 -fno-tree-ccp -fno-tree-dominator-opts
// introduced between 2005-05-17 2005-05-18

void abort (void);

int main (void)
{
  int a, i;

  for (i = 0; i < 5; i++)
    a = i * i;
  if (a != 16)
    abort ();
  return 0;
}

/*
--- 2005-05-17/bug22230-5.c.t28.phiopt1 2005-07-12 17:40:19.000000000 +0400
+++ 2005-05-18/bug22230-5.c.t28.phiopt1 2005-07-12 17:40:32.000000000 +0400
@@ -1,6 +1,8 @@
 
 ;; Function main (main)
 
+Merging blocks 0 and 6
+Merging blocks 1 and 2
 main ()
 {
   int i;
@@ -8,20 +10,15 @@
   int D.1571;
 
 <bb 0>:
-  goto <bb 6> (<L6>);
 
-  # i_9 = PHI <i_1(2), i_3(6)>;
+  # i_9 = PHI <i_8(1), 0(0)>;
 <L0>:;
   a_7 = i_9 * i_9;
   i_8 = i_9 + 1;
-
-  # a_2 = PHI <a_7(1)>;
-  # i_1 = PHI <i_8(1)>;
-<L1>:;
-  if (i_1 <= 4) goto <L0>; else goto <L2>;
+  if (i_8 <= 4) goto <L0>; else goto <L2>;
 
 <L2>:;
-  if (a_2 != 16) goto <L3>; else goto <L4>;
+  if (a_7 != 16) goto <L3>; else goto <L4>;
 
 <L3>:;
   abort ();
@@ -29,11 +26,6 @@
 <L4>:;
   return 0;
 
-  # a_5 = PHI <a_4(0)>;
-  # i_3 = PHI <0(0)>;
-<L6>:;
-  goto <bb 1> (<L0>);
-
 }

Caused by this patch:

2005-05-17  Zdenek Dvorak  <[EMAIL PROTECTED]>

        * timevar.def (TV_SCEV_CONST): New timevar.
        * tree-optimize.c (init_tree_optimization_passes): Add
        pass_scev_cprop.
        * tree-pass.h (pass_scev_cprop): Declare.
        * tree-scalar-evolution.c (scev_const_prop): New function.
        * tree-scalar-evolution.h (scev_const_prop): Declare.
        * tree-ssa-loop.c (gate_scev_const_prop, pass_scev_cprop):
        New.
        * tree-cfg.c (replace_uses_by): Export.
        * tree-flow.h (replace_uses_by): Declare.

*/

-- 
           Summary: scev cprop causes wrong code
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: critical
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: belyshev at depni dot sinp dot msu dot ru
                CC: gcc-bugs at gcc dot gnu dot org,rakdver at gcc dot gnu
                    dot org
GCC target triplet: x86_64-*-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22442

Reply via email to