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 #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.

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