diff options
author | Patrick Palka <ppalka@redhat.com> | 2025-04-12 14:06:56 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2025-04-12 14:06:56 -0400 |
commit | e7bccec33beece4a46bc1b20ed375e803e97aa88 (patch) | |
tree | 26bd642799e9ae4cfe0f2d986ea3c67e4f245f57 /gcc/rust/parse/rust-parse-impl.h | |
parent | 342f1663bfb0e662f12c035c922d72166be9dd22 (diff) | |
download | gcc-e7bccec33beece4a46bc1b20ed375e803e97aa88.zip gcc-e7bccec33beece4a46bc1b20ed375e803e97aa88.tar.gz gcc-e7bccec33beece4a46bc1b20ed375e803e97aa88.tar.bz2 |
c++: improve constexpr prvalue folding [PR116416]
This patch improves upon r15-6052-g12de1942a0a673 by performing prvalue
folding with mce_false rather than mce_unknown when it's safe to do so
(i.e. ff_mce_false is set), so that we can also fold temporary initializers
that call is_constant_evaluated etc.
In passing I noticed constexpr-prvalue1.C could more precisely verify the
optimization happened by inspecting what the front end spits out instead
of inspecting the optimized assembly -- that there's no constructor call
doesn't necessarily imply the constructor has been completely folded away,
only that its body has been inlined.
PR c++/116416
gcc/cp/ChangeLog:
* constexpr.cc (maybe_constant_init_1): Generalize type of
of manifestly_const_eval parameter from bool to mce_value.
(maybe_constant_init): Define 3-parameter version taking a
manifestly_const_eval instead of bool parameter.
(cxx_constant_init): Adjust.
* cp-gimplify.cc (cp_fold_r) <case TARGET_EXPR>: Pass mce_false
to maybe_constant_init during prvalue folding if ff_mce_false is
set.
* cp-tree.h (maybe_constant_init): Declare new overload.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/constexpr-prvalue1.C: Adjust to instead inspect
the 'original' dump.
* g++.dg/cpp1y/constexpr-prvalue1a.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
0 files changed, 0 insertions, 0 deletions