diff options
author | Marek Polacek <polacek@redhat.com> | 2023-10-19 09:57:53 -0400 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2023-10-19 16:18:14 -0400 |
commit | 4d81962ba00ab74c4bc5fac685988f9cf778a9bb (patch) | |
tree | 4ac0e4f78e9715e0050e672d9c9a858f6bad4670 /gcc/cp/constexpr.cc | |
parent | 86d0b086648540f8318c7454be2061bd8fc030df (diff) | |
download | gcc-4d81962ba00ab74c4bc5fac685988f9cf778a9bb.zip gcc-4d81962ba00ab74c4bc5fac685988f9cf778a9bb.tar.gz gcc-4d81962ba00ab74c4bc5fac685988f9cf778a9bb.tar.bz2 |
c++: small tweak for cp_fold_r
This patch is an optimization tweak for cp_fold_r. If we cp_fold_r the
COND_EXPR's op0 first, we may be able to evaluate it to a constant if -O.
cp_fold has:
3143 if (callee && DECL_DECLARED_CONSTEXPR_P (callee)
3144 && !flag_no_inline)
...
3151 r = maybe_constant_value (x, /*decl=*/NULL_TREE,
flag_no_inline is 1 for -O0:
1124 if (opts->x_optimize == 0)
1125 {
1126 /* Inlining does not work if not optimizing,
1127 so force it not to be done. */
1128 opts->x_warn_inline = 0;
1129 opts->x_flag_no_inline = 1;
1130 }
but otherwise it's 0 and cp_fold will maybe_constant_value calls to
constexpr functions. And if it doesn't, then folding the COND_EXPR
will keep both arms, and we can avoid calling maybe_constant_value.
gcc/cp/ChangeLog:
* cp-gimplify.cc (cp_fold_r): Don't call maybe_constant_value.
Diffstat (limited to 'gcc/cp/constexpr.cc')
0 files changed, 0 insertions, 0 deletions