This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Use cst_and_fits_in_hwi in ptr_difference_const
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 19 Aug 2005 11:40:52 +0200
- Subject: [patch] Use cst_and_fits_in_hwi in ptr_difference_const
Hello,
ptr_difference_const uses host_integerp to check whether
difference of offsets is a constant. This however fails
if there is an overflow during the computation of the difference,
which happens sometimes; this causes suboptimal behavior in
ivopts. This patch makes it use cst_and_fits_in_hwi
that does not care about overflows, instead.
Bootstrapped & regtested on i686.
Zdenek
* fold-const.c (ptr_difference_const): Use
cst_and_fits_in_hwi instead of host_integerp.
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.595
diff -c -3 -p -r1.595 fold-const.c
*** fold-const.c 13 Jun 2005 14:59:31 -0000 1.595
--- fold-const.c 14 Jun 2005 19:27:22 -0000
*************** ptr_difference_const (tree e1, tree e2,
*** 11838,11847 ****
toffset2 = fold_convert (type, toffset2);
tdiff = fold_build2 (MINUS_EXPR, type, toffset1, toffset2);
! if (!host_integerp (tdiff, 0))
return false;
! *diff = tree_low_cst (tdiff, 0);
}
else if (toffset1 || toffset2)
{
--- 11838,11847 ----
toffset2 = fold_convert (type, toffset2);
tdiff = fold_build2 (MINUS_EXPR, type, toffset1, toffset2);
! if (!cst_and_fits_in_hwi (tdiff))
return false;
! *diff = int_cst_value (tdiff);
}
else if (toffset1 || toffset2)
{