Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-28410

ClangCodeModel confused by IMM intrinsics

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • Qt Creator 8.0.2
    • None
    • Qt 5.15.2, Qt Creator 8.0.2, MSVC 2019 64-bit.
    • Windows

    Description

      With MSVC as the compiler, when ClangCodeModel is enabled, it gets confused by IMM intrinsics (at least), but unfortunately I cannot give a fully accurate and concrete description.

       

      I first noticed it in this code snippet, where it failed to recognize anything from <immintrin.h>, despite the code compiling (and running) with no issues:

      Then, when attempting to narrow it down for a bug report, the issue manifested itself differently and I was unable to construct a test case that showed the exact same behavior. In this case, it recognize the intrinsics but failed to recognize the Microsoft-specific form of __m256, which has some member fields:

      As with the first observation, the above code compiles with no issues.

      Here is that second test in text form:

      using uint = unsigned;
      #define USE_IMM 1
      #if USE_IMM
      #include <immintrin.h>
      #endif
      
      int main () {
      
          const auto xcoef = [] (const float *a, const float *b, uint len) {
      #if USE_IMM
              __m256 sum = { 0, 0, 0, 0 };
              for (uint k = 0; k < len; k += 4) {
                  __m256 avals = _mm256_load_ps(a + k);
                  __m256 bvals = _mm256_load_ps(b + k);
                  sum = _mm256_fmadd_ps(avals, bvals, sum);
              }
              return sum.m256_f32[0] + sum.m256_f32[1] + sum.m256_f32[2] + sum.m256_f32[3];
      #else
              double sum = 0;
              while (len) { sum += *(a++) * *(b++); -- len; }
              return sum;
      #endif
          };
      
      }
      
      

      It seems like it is perhaps assuming gcc's form of immintrin.h? But I am not sure.

      I'm sorry that I do not have more to offer here.

      Attachments

        1. image-2022-11-04-12-01-16-084.png
          158 kB
          Jason Cipriani
        2. image-2022-11-04-12-01-28-616.png
          137 kB
          Jason Cipriani

        Activity

          People

            kandeler Christian Kandeler
            jasonc Jason Cipriani
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: