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 c++/82915] New: Please mark intrinsics as constexpr


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

            Bug ID: 82915
           Summary: Please mark intrinsics as constexpr
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugzilla@poradnik-webmastera.com
  Target Milestone: ---

Intrinsics are marked as inline now. However gcc knows what they do, and is
able to optimize out some code code which uses them - e.g. in example below
both count1a() and count2a() are optimized to "mov eax, 5; ret". Because of
this intrinsics could be marked as constexpr. This would allow gcc to better
optimize code. It also would allow to perform quick code validation in tools
like Compiler Explorer, by using code like below.

#include "immintrin.h"

constexpr int data[8] = {0, 1, 0, 2, 0, 3};

constexpr int count1(const int* d)
{
  int cnt = 0;
  for (int n = 0; n < 8; ++n)
    if (0 == d[n])
      ++cnt;
  return cnt;
}

int count1a()
{
  return count1(data);
}

inline int count2(const int* d)
{
  __m256i v = _mm256_loadu_si256((const __m256i*)d);
  v = _mm256_cmpeq_epi32(v, _mm256_setzero_si256());
  return _mm256_movemask_epi8(v) >> 2;
}

int count2a()
{
  return count1(data);
}

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