This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fixed PR23391
- From: Sebastian Pop <sebastian dot pop at cri dot ensmp dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 15 Aug 2005 14:35:09 +0200
- Subject: Fixed PR23391
Fixed PR23391 with this patch. Bootstrapped and tested on
{amd64,i686}-linux. Committed to mainline.
seb
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ChangeLog,v
retrieving revision 2.9732
diff -d -u -p -r2.9732 ChangeLog
--- ChangeLog 15 Aug 2005 07:51:15 -0000 2.9732
+++ ChangeLog 15 Aug 2005 12:22:23 -0000
@@ -1,5 +1,15 @@
2005-08-15 Sebastian Pop <pop@cri.ensmp.fr>
+ PR 23391
+ * Makefile.in (tree-chrec.o): Depends on real.h.
+ * tree-chrec.c: Include real.h.
+ (chrec_fold_plus_poly_poly, chrec_fold_multiply_poly_poly,
+ chrec_fold_plus_1): Use build_real for SCALAR_FLOAT_TYPE_P.
+ * tree-scalar-evolution.c (add_to_evolution_1,
+ interpret_rhs_modify_expr): Ditto.
+
+2005-08-15 Sebastian Pop <pop@cri.ensmp.fr>
+
PR 23386
* tree-data-ref.c (estimate_niter_from_size_of_data): When
step is negative compute the estimation from init downwards to zero.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1535
diff -d -u -p -r1.1535 Makefile.in
--- Makefile.in 6 Aug 2005 13:25:52 -0000 1.1535
+++ Makefile.in 15 Aug 2005 12:22:26 -0000
@@ -1942,7 +1942,7 @@ tree-browser.o : tree-browser.c tree-bro
$(TREE_H) tree-inline.h $(DIAGNOSTIC_H) $(HASHTAB_H) \
$(TM_H) coretypes.h
tree-chrec.o: tree-chrec.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
- $(GGC_H) $(TREE_H) tree-chrec.h tree-pass.h $(PARAMS_H) \
+ $(GGC_H) $(TREE_H) real.h tree-chrec.h tree-pass.h $(PARAMS_H) \
$(DIAGNOSTIC_H) $(VARRAY_H) $(CFGLOOP_H) $(TREE_FLOW_H)
tree-scalar-evolution.o: tree-scalar-evolution.c $(CONFIG_H) $(SYSTEM_H) \
coretypes.h $(TM_H) $(GGC_H) $(TREE_H) real.h $(RTL_H) \
Index: tree-chrec.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-chrec.c,v
retrieving revision 2.23
diff -d -u -p -r2.23 tree-chrec.c
--- tree-chrec.c 13 Aug 2005 17:28:37 -0000 2.23
+++ tree-chrec.c 15 Aug 2005 12:22:27 -0000
@@ -30,6 +30,7 @@ Software Foundation, 51 Franklin Street,
#include "tm.h"
#include "ggc.h"
#include "tree.h"
+#include "real.h"
#include "diagnostic.h"
#include "varray.h"
#include "cfgloop.h"
@@ -119,7 +120,9 @@ chrec_fold_plus_poly_poly (enum tree_cod
(CHREC_VARIABLE (poly1),
chrec_fold_minus (type, poly0, CHREC_LEFT (poly1)),
chrec_fold_multiply (type, CHREC_RIGHT (poly1),
- build_int_cst_type (type, -1)));
+ SCALAR_FLOAT_TYPE_P (type)
+ ? build_real (type, dconstm1)
+ : build_int_cst_type (type, -1)));
}
if (CHREC_VARIABLE (poly0) > CHREC_VARIABLE (poly1))
@@ -208,7 +211,9 @@ chrec_fold_multiply_poly_poly (tree type
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);
+ t2 = chrec_fold_multiply (type, SCALAR_FLOAT_TYPE_P (type)
+ ? build_real (type, dconst2)
+ : build_int_cst_type (type, 2), t2);
var = CHREC_VARIABLE (poly0);
return build_polynomial_chrec (var, t0,
@@ -284,8 +289,10 @@ chrec_fold_plus_1 (enum tree_code code,
return build_polynomial_chrec
(CHREC_VARIABLE (op1),
chrec_fold_minus (type, op0, CHREC_LEFT (op1)),
- chrec_fold_multiply (type, CHREC_RIGHT (op1),
- build_int_cst_type (type, -1)));
+ chrec_fold_multiply (type, CHREC_RIGHT (op1),
+ SCALAR_FLOAT_TYPE_P (type)
+ ? build_real (type, dconstm1)
+ : build_int_cst_type (type, -1)));
default:
{
Index: tree-scalar-evolution.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-scalar-evolution.c,v
retrieving revision 2.35
diff -d -u -p -r2.35 tree-scalar-evolution.c
--- tree-scalar-evolution.c 13 Aug 2005 17:28:40 -0000 2.35
+++ tree-scalar-evolution.c 15 Aug 2005 12:22:28 -0000
@@ -676,7 +676,9 @@ add_to_evolution_1 (unsigned loop_nb,
{
var = loop_nb;
left = chrec_before;
- right = build_int_cst (type, 0);
+ right = SCALAR_FLOAT_TYPE_P (type)
+ ? build_real (type, dconst0)
+ : build_int_cst (type, 0);
}
else
{
@@ -1680,7 +1682,9 @@ interpret_rhs_modify_expr (struct loop *
opnd10 = TREE_OPERAND (opnd1, 0);
chrec10 = analyze_scalar_evolution (loop, opnd10);
chrec10 = chrec_convert (type, chrec10, at_stmt);
- res = chrec_fold_minus (type, build_int_cst (type, 0), chrec10);
+ res = chrec_fold_multiply (type, chrec10, SCALAR_FLOAT_TYPE_P (type)
+ ? build_real (type, dconstm1)
+ : build_int_cst_type (type, -1));
break;
case MULT_EXPR:
Index: testsuite/gcc.dg/tree-ssa/pr23391.c
===================================================================
RCS file: testsuite/gcc.dg/tree-ssa/pr23391.c
diff -N testsuite/gcc.dg/tree-ssa/pr23391.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/tree-ssa/pr23391.c 15 Aug 2005 12:22:44 -0000
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+
+void
+foo (int N)
+{
+ int C;
+ double R;
+
+ R = 0.0;
+ do
+ {
+ R += 0.001;
+ C = (int) (R * N);
+ if (-R * N <= R * N)
+ {
+ C++;
+ }
+ }
+ while (C < 0);
+
+ return;
+}