https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87550
Bug ID: 87550
Summary: Intrinsics for rdpmc (__rdpmc, __builtin_ia32_rdpmc)
are interpreted as pure functions
Product: gcc
Version: 7.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: vladimir.solontsov at mlp dot com
Target Milestone: ---
A code like
#include <stdint.h>
#include <x86intrin.h>
int main()
{
uint64_t s = __rdpmc(0);
uint64_t e = __rdpmc(0);
return (int)(e - s);
}
generates
xorl %eax, %eax
ret
It seems like __rdpmc() is treated as a pure function which makes it completely
useless.
I initially found it with g++ 7.1.0 but with godbolt confirmed it for all
others since 4.5.3.