This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR36691, wrong-code with wrong # of iterations


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]