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: "glisse 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 10:27:47 +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 #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
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.