This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR36691, wrong-code with wrong # of iterations
- From: Zdenek Dvorak <rakdver at kam dot mff dot cuni dot cz>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 4 Aug 2008 18:44:06 +0200
- Subject: Re: [PATCH] Fix PR36691, wrong-code with wrong # of iterations
- References: <alpine.LNX.1.10.0808041728320.3427@zhemvz.fhfr.qr>
Hi,
> This fixes PR36691 where we wrongly skip generation of assumptions
> for non-wrapping of the induction variable.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu - Zdenek, does this
> look ok?
yes, thanks for fixing this. Although,
> *************** number_of_iterations_lt_to_ne (tree type
> *** 692,703 ****
> mpz_set_double_int (mmod, tree_to_double_int (mod), true);
> mpz_neg (mmod, mmod);
>
> if (integer_nonzerop (iv0->step))
> {
> /* The final value of the iv is iv1->base + MOD, assuming that this
> computation does not overflow, and that
> iv0->base <= iv1->base + MOD. */
> ! if (!iv1->no_overflow && !integer_zerop (mod))
> {
> bound = fold_build2 (MINUS_EXPR, type,
> TYPE_MAX_VALUE (type1), tmod);
it might be better to just fix the tests and check iv0->no_overflow here
(since iv1->step == 0, it does not make sense to check whether it
overflows),
> *************** number_of_iterations_lt_to_ne (tree type
> *** 719,725 ****
> /* The final value of the iv is iv0->base - MOD, assuming that this
> computation does not overflow, and that
> iv0->base - MOD <= iv1->base. */
> ! if (!iv0->no_overflow && !integer_zerop (mod))
> {
> bound = fold_build2 (PLUS_EXPR, type1,
> TYPE_MIN_VALUE (type1), tmod);
and iv1->no_overflow here.
Zdenek