This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/22442] [4.1 regression] scev cprop causes wrong code
- From: "rakdver at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Jul 2005 15:14:26 -0000
- Subject: [Bug tree-optimization/22442] [4.1 regression] scev cprop causes wrong code
- References: <20050712142053.22442.belyshev@depni.sinp.msu.ru>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From rakdver at gcc dot gnu dot org 2005-07-12 15:14 -------
The following patch fixes the problem, I am just testing it:
Index: tree-chrec.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-chrec.c,v
retrieving revision 2.21
diff -c -3 -p -r2.21 tree-chrec.c
*** tree-chrec.c 25 Jun 2005 02:01:15 -0000 2.21
--- tree-chrec.c 12 Jul 2005 15:11:08 -0000
*************** chrec_fold_multiply_poly_poly (tree type
*** 167,172 ****
--- 167,175 ----
tree poly0,
tree poly1)
{
+ tree t0, t1, t2;
+ int var;
+
gcc_assert (poly0);
gcc_assert (poly1);
gcc_assert (TREE_CODE (poly0) == POLYNOMIAL_CHREC);
*************** chrec_fold_multiply_poly_poly (tree type
*** 191,218 ****
/* poly0 and poly1 are two polynomials in the same variable,
{a, +, b}_x * {c, +, d}_x -> {a*c, +, a*d + b*c + b*d, +, 2*b*d}_x. */
! return
! build_polynomial_chrec
! (CHREC_VARIABLE (poly0),
! build_polynomial_chrec
! (CHREC_VARIABLE (poly0),
!
! /* "a*c". */
! chrec_fold_multiply (type, CHREC_LEFT (poly0), CHREC_LEFT (poly1)),
!
! /* "a*d + b*c + b*d". */
! chrec_fold_plus
! (type, chrec_fold_multiply (type, CHREC_LEFT (poly0), CHREC_RIGHT (poly1)),
!
! chrec_fold_plus
! (type,
! chrec_fold_multiply (type, CHREC_RIGHT (poly0), CHREC_LEFT (poly1)),
! chrec_fold_multiply (type, CHREC_RIGHT (poly0), CHREC_RIGHT (poly1))))),
!
! /* "2*b*d". */
! chrec_fold_multiply
! (type, build_int_cst (NULL_TREE, 2),
! chrec_fold_multiply (type, CHREC_RIGHT (poly0), CHREC_RIGHT (poly1))));
}
/* When the operands are automatically_generated_chrec_p, the fold has
--- 194,218 ----
/* poly0 and poly1 are two polynomials in the same variable,
{a, +, b}_x * {c, +, d}_x -> {a*c, +, a*d + b*c + b*d, +, 2*b*d}_x. */
!
! /* "a*c". */
! t0 = chrec_fold_multiply (type, CHREC_LEFT (poly0), CHREC_LEFT (poly1));
!
! /* "a*d + b*c + b*d". */
! t1 = chrec_fold_multiply (type, CHREC_LEFT (poly0), CHREC_RIGHT (poly1));
! t1 = chrec_fold_plus (type, t1, chrec_fold_multiply (type,
! CHREC_RIGHT (poly0),
! CHREC_LEFT (poly1)));
! t1 = chrec_fold_plus (type, t1, chrec_fold_multiply (type,
! CHREC_RIGHT (poly0),
! CHREC_RIGHT (poly1)));
! /* "2*b*d". */
! t2 = chrec_fold_multiply (type, CHREC_RIGHT (poly0), CHREC_RIGHT (poly1));
! t2 = chrec_fold_multiply (type, build_int_cst_type (type, 2), t2);
!
! var = CHREC_VARIABLE (poly0);
! return build_polynomial_chrec (var, t0,
! build_polynomial_chrec (var, t1, t2));
}
/* When the operands are automatically_generated_chrec_p, the fold has
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22442