aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-ivopts.c
diff options
context:
space:
mode:
authorZdenek Dvorak <dvorakz@suse.cz>2005-07-06 08:13:13 +0000
committerZdenek Dvorak <dvorakz@suse.cz>2005-07-06 08:13:13 +0000
commit14429d54bde787a9d12281e5f11097ea7adc3448 (patch)
tree04592b2f7cfbe276bd8ac4b72b20646f3a01753d /gcc/tree-ssa-loop-ivopts.c
parentbd2d1abddbb1b21aff6c7cbfa0cb0c11bb6ff104 (diff)
PR tree-optimization/21963
* tree-ssa-loop-ivopts.c (get_computation_aff): Use constant_multiple_of in the same way get_computation_cost_at does. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@101654 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-loop-ivopts.c')
-rw-r--r--gcc/tree-ssa-loop-ivopts.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index acc1ae9c4f0..8e6b8c168d4 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -2983,6 +2983,7 @@ get_computation_aff (struct loop *loop,
unsigned HOST_WIDE_INT ustepi, cstepi;
HOST_WIDE_INT ratioi;
struct affine_tree_combination cbase_aff, expr_aff;
+ tree cstep_orig = cstep, ustep_orig = ustep;
if (TYPE_PRECISION (utype) > TYPE_PRECISION (ctype))
{
@@ -3012,13 +3013,18 @@ get_computation_aff (struct loop *loop,
expr = fold_convert (uutype, expr);
cbase = fold_convert (uutype, cbase);
cstep = fold_convert (uutype, cstep);
+
+ /* If the conversion is not noop, we must take it into account when
+ considering the value of the step. */
+ if (TYPE_PRECISION (utype) < TYPE_PRECISION (ctype))
+ cstep_orig = cstep;
}
- if (cst_and_fits_in_hwi (cstep)
- && cst_and_fits_in_hwi (ustep))
+ if (cst_and_fits_in_hwi (cstep_orig)
+ && cst_and_fits_in_hwi (ustep_orig))
{
- ustepi = int_cst_value (ustep);
- cstepi = int_cst_value (cstep);
+ ustepi = int_cst_value (ustep_orig);
+ cstepi = int_cst_value (cstep_orig);
if (!divide (TYPE_PRECISION (uutype), ustepi, cstepi, &ratioi))
{
@@ -3032,7 +3038,7 @@ get_computation_aff (struct loop *loop,
}
else
{
- ratio = constant_multiple_of (uutype, ustep, cstep);
+ ratio = constant_multiple_of (uutype, ustep_orig, cstep_orig);
if (!ratio)
return false;