[Bug tree-optimization/88775] [8/9 Regression] Optimize std::string assignment

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jan 10 22:50:00 GMT 2019


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

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Unfortunately the #c11 patch breaks the
20_util/function_objects/comparisons_pointer.cc testcase (wonder if your VRP
patch would break it too), where the testcase does exactly what has been
discussed on IRC:
int b[8];
int a[8];

void
test01()
{
  int* p = a + 8;
  std::greater<int*> gt;

  std::stringstream ss;
  ss << gt(p, b) << ' ' << gt(b, p) << ' ' << (!gt(p, b) && !gt(b, p));

So, if we want to do this optimization, we probably need to make sure that
whatever optimizes the a + 8 != b comparisons into false doesn't do that if one
pointer is known or could point to the end of one of the objects and the other
pointer points to the start of another object and those two objects could
potentially live in the same section (though, maybe even different sections
could be problematic if one is at the end of the whole section and another one
is the first one in the next section).  As the distinction is gone in RTL, this
must be some GIMPLE or tree opt.


More information about the Gcc-bugs mailing list