[llvm-bugs] [Bug 50409] New: [SLPVectorizer] Optimisations depend on whether LLVM was built with libstdc++ or libc++

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 19 14:10:35 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50409

            Bug ID: 50409
           Summary: [SLPVectorizer] Optimisations depend on whether LLVM
                    was built with libstdc++ or libc++
           Product: libraries
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: harald at gigawatt.nl
                CC: llvm-bugs at lists.llvm.org

Created attachment 24876
  --> https://bugs.llvm.org/attachment.cgi?id=24876&action=edit
SLPVectorizer diff between two clang 12.0.0 builds

For the following reduced test case, we get different results from
SLPVectorizer in LLVM 12 depending on whether LLVM was built with libstdc++ or
libc++:

  struct a {
    long long b[2];
  } c, d;
  a e();
  bool f();
  void g() {
    a ak, am(d), ar;
    while (f()) {
      a aq = e();
      if (am.b[0])
        aq = am;
      ak = aq;
    }
    ar = e();
    ar.b[0] &= ak.b[0];
    ar.b[1] &= ak.b[1];
    ar.b[0] &= 8;
    a as = ak;
    if (as.b[0])
      c = ar;
  }

When compiled with -O2 for x86, see the attached diff for how this results in
different code depending on LLVM was built with GCC+libstdc++ or with
clang+libc++. I saw this with clang 12.0.0 but it looks like this should still
be an issue on main as well. This was noticed back in 2017 and fixed
(presumably) but the fix got reverted and no new fix was installed in its
place.

Fix:

https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20171120/504117.html

Revert:

https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20180101/514219.html

Unfortunately communication seems to have gone badly on both sides there and
this issue just got completely forgotten about, meaning we have more
stable_sorts with bad comparison functions now than we did back then: D82444
added another one. This means even if we were to want to reapply the original
fix, it is no longer a complete fix.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210519/54aca6bf/attachment.html>


More information about the llvm-bugs mailing list