Bug 65197 - static initialization via intel intrinsics
Summary: static initialization via intel intrinsics
Status: RESOLVED DUPLICATE of bug 4131
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2015-02-24 22:02 UTC by Marc Glisse
Modified: 2025-03-19 21:37 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Glisse 2015-02-24 22:02:41 UTC
I am compiling the following with: g++ -std=gnu++11 -Ofast

#include <x86intrin.h>
extern const __m128i x = { -1, 0 };
extern const __m128i y = _mm_set_epi64x (0, -1);

While x becomes a nice constant in .rodata, y is initialized by _GLOBAL__sub_I_x (copying a constant that is in .rodata). For this specific case, marking _mm_set_epi64x as constexpr gives y the same treatment as x, and I believe we should do that, i.e. mark all intrinsics that can be constexpr in C++11/C++14. However, I believe we are missing an optimization in the general case that would notice (late, after many optimizations) when the initialization function has become unnecessary.

Some possibly related bugs: PR4131, PR18399, PR24928, PR37949.
Comment 1 Drea Pinski 2016-01-24 07:34:53 UTC
For C++11/14/17 (17 has more freedoms for constexpr) reasons it might make sense to mark _mm_set_epi64x as constexpr.
Comment 2 Drea Pinski 2025-03-11 21:36:42 UTC
This is a dup of PR 24928.

During the IPA passes we have already:
void _GLOBAL__sub_I_x ()
{
  <bb 2> [local count: 1073741824]:
  y = { -1, 0 };
  return;

}

*** This bug has been marked as a duplicate of bug 24928 ***
Comment 3 Drea Pinski 2025-03-11 21:39:43 UTC
Sorry I meant PR 4131.

*** This bug has been marked as a duplicate of bug 4131 ***