aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Dvorak <dvorakz@suse.cz>2005-07-13 12:08:36 +0200
committerZdenek Dvorak <rakdver@gcc.gnu.org>2005-07-13 10:08:36 +0000
commit2c5f025d8df993b43d66a9d7cc900b3cf80af7fc (patch)
treee904255113ad6aee05efca792bcfe7b71abb9070
parent7869fe47b3a1b1ea8ecc628860c4996bb5857f37 (diff)
downloadgcc-2c5f025d8df993b43d66a9d7cc900b3cf80af7fc.zip
gcc-2c5f025d8df993b43d66a9d7cc900b3cf80af7fc.tar.gz
gcc-2c5f025d8df993b43d66a9d7cc900b3cf80af7fc.tar.bz2
re PR tree-optimization/22442 (scev cprop causes wrong code)
PR tree-optimization/22442 * tree-chrec.c (chrec_fold_multiply_poly_poly): Associate chrecs correctly. From-SVN: r101962
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/tree-chrec.c42
2 files changed, 27 insertions, 21 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fcef3d2..dd21fc9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2005-07-12 Zdenek Dvorak <dvorakz@suse.cz>
+ PR tree-optimization/22442
+ * tree-chrec.c (chrec_fold_multiply_poly_poly): Associate chrecs
+ correctly.
+
+2005-07-12 Zdenek Dvorak <dvorakz@suse.cz>
+
PR rtl-optimization/20376
* toplev.c (process_options): Enable -fweb and -frename-registers when
unrolling.
diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c
index 4d62b51..b48813c 100644
--- a/gcc/tree-chrec.c
+++ b/gcc/tree-chrec.c
@@ -167,6 +167,9 @@ chrec_fold_multiply_poly_poly (tree type,
tree poly0,
tree poly1)
{
+ tree t0, t1, t2;
+ int var;
+
gcc_assert (poly0);
gcc_assert (poly1);
gcc_assert (TREE_CODE (poly0) == POLYNOMIAL_CHREC);
@@ -191,28 +194,25 @@ chrec_fold_multiply_poly_poly (tree type,
/* 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))));
+ /* "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