https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92180
Bug ID: 92180 Summary: Missed optimization on casting __builtin_ia32_rdtsc result to int32 Product: gcc Version: 9.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: mserdarsanli at gmail dot com Target Milestone: --- Link: https://godbolt.org/z/wcIN0a #include <stdint.h> uint32_t foo1() { return __builtin_ia32_rdtsc(); } uint64_t foo2() { return __builtin_ia32_rdtsc(); } Generates assembly: foo1(): rdtsc sal rdx, 32 or rax, rdx ret foo2(): rdtsc sal rdx, 32 or rax, rdx ret While clang generates better code for foo1 foo1(): # @foo1() rdtsc ret