#1057653 Fix #pragma GCC target for C++

Package:
gcc-13
Source:
gcc-13
Description:
GNU C compiler
Submitter:
Gwenole Beauchesne
Date:
2023-12-06 17:12:04 UTC
Severity:
normal
#1057653#5
Date:
2023-12-06 17:09:36 UTC
From:
To:
#pragma GCC target is useful to compile specific functions with SIMD
extensions, for instance. However, that feature was long broken for
C++ where the relevant macros were not defined on the first
preprocessing pass, thus preventing some target-specific enablement.
e.g. some library wrappers for SIMD extensions usually check for SIMD
ISA macros to define vector sizes and adequate functions. The missing
define would mean a missed optimization.

This patch series addresses this issue, and is a direct backport from
the GCC mainline. Since this is not a regression vs. previous versions
of GCC, I believe there is little chance to get them from r13 branch.
(this looks broken as far as gcc 4.4.x)

0001-preprocessor-c-Support-pragma-GCC-target-macros-PR87.patch
0002-preprocessor-Reinitialize-frontend-parser-after-load.patch
0003-c-Handle-pragma-GCC-target-optimize-early.patch

Patch1 is the core fix, Patch2 is a colateral patch that addresses
ICEs from the first one. Relevant upstream issue numbers are PR
c++/41201, PR c++/48026 and PR preprocessor/87299.

IMHO, this is a nice-to-have series for testing/trixie (and Ubuntu
24.04-LTS). Note: I only regtested on bullseye and bookworm. Thanks!