This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/23471] a*a (for signed ints with -fno-wrapv) is always postive
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 31 Mar 2016 11:21:09 +0000
- Subject: [Bug tree-optimization/23471] a*a (for signed ints with -fno-wrapv) is always postive
- Auto-submitted: auto-generated
- References: <bug-23471-4 at http dot gcc dot gnu dot org/bugzilla/>
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.