[PATCH 2/3]Improve induction variable elimination

Bin.Cheng amker.cheng@gmail.com
Fri Jul 25 14:42:00 GMT 2014


On Fri, Jul 25, 2014 at 1:35 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Thu, Jul 17, 2014 at 11:08 AM, Bin Cheng <bin.cheng@arm.com> wrote:
>> Hi,
>> As quoted from the function difference_cannot_overflow_p,
>>
>>   /* TODO: deeper inspection may be necessary to prove the equality.  */
>>   switch (code)
>>     {
>>     case PLUS_EXPR:
>>       return expr_equal_p (e1, offset) || expr_equal_p (e2, offset);
>>     case POINTER_PLUS_EXPR:
>>       return expr_equal_p (e2, offset);
>>
>>     default:
>>       return false;
>>     }
>>
>> The overflow check can be improved by using deeper inspection to prove the
>> equality.  This patch deals with that by making below two improvements:
>>   a) Handles constant cases.
>>   b) Uses affine expansion as deeper inspection to check the equality.
>>
>> As a result, functions strip_wrap_conserving_type_conversions and
>> expr_equal_p can be removed now.  A test case is also added to illustrate iv
>> elimination opportunity captured by this patch.
>>
>> Thanks,
>> bin
>
> You add special casing for constants but I don't see any testcases for that.
> Specifically
>
> +  /* No overflow if offset is zero.  */
> +  if (offset == integer_zero_node)
>      return true;
>
> is a bogus check (use integer_zerop).  Apart from the special-casing of
Will be changed.

> constants the patch looks good to me.
>
Ah, Now I can see that handling of constants (here the zero offset
case) is to make the 3rd patch to work.  I should include this part of
code in the 3rd patch.  Also I will try to reduce testcase for other
non-zero constant scenarios

Thanks,
bin



More information about the Gcc-patches mailing list