This is the mail archive of the gcc-bugs@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]

[Bug tree-optimization/23471] a*a (for signed ints with -fno-wrapv) is always postive


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23471

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #3)
> The case a*a has been handled for a while, both in fold-const.c
> (tree_binary_nonnegative_warnv_p) and in VRP. However, the case a*a*a*a*a*a
> is not handled. In the .optimized dump at -O3, we still have:
> 
>   b_3 = a_2(D) * a_2(D);
>   b_4 = a_2(D) * b_3;
>   b_5 = a_2(D) * b_4;
>   b_6 = a_2(D) * b_5;
>   b_7 = a_2(D) * b_6;
> 
> If reassoc or some similar pass had turned it into the following, the
> optimization would probably work:
> 
>   b_3 = a_2(D) * a_2(D);
>   b_4 = a_2(D) * b_3;
>   b_7 = b_4 * b_4;
> 
> Not sure how often this would be useful though.

Hum, reassoc handles this for floats only it seems (__builtin_powi detection
and expansion).  Ah, and of course reassoc does nothing to
TYPE_OVERFLOW_UNDEFINED
ops.

It seems to be reassoc could handle this case anyway as code-gen optimiztion.

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