Re: [PATCH 2/2] c++: speculative constexpr and is_constant_evaluated [PR108243]

2023-02-14 Thread Jason Merrill via Gcc-patches
fold_r, so it seems we need another flag that that only affects the manifestly constant-eval stuff; I called it ff_mce_false. How does the following look? -- >8 -- Subject: [PATCH 2/2] c++: speculative constexpr and is_constant_evaluated [PR108243] This PR illustrates that __builtin_i

Re: [PATCH 2/2] c++: speculative constexpr and is_constant_evaluated [PR108243]

2023-02-10 Thread Patrick Palka via Gcc-patches
,15 @@ cp_fold (tree x) > > > > > > > >constant, but the call followed by an INDIRECT_REF > > > > > > > > is. */ > > > > > > > > if (callee && DECL_DECLARED_CONSTEXPR_P (callee) > &g

Re: [PATCH 2/2] c++: speculative constexpr and is_constant_evaluated [PR108243]

2023-02-10 Thread Patrick Palka via Gcc-patches
+ /* At genericization time it's safe to fold > > > > > > > + __builtin_is_constant_evaluated to false. */ > > > > > > > + manifestly_const_eval = mce_false; > > > > > > > + r = maybe_constant_value (x, /*decl=*/NULL_TREE, > >

Re: [PATCH 2/2] c++: speculative constexpr and is_constant_evaluated [PR108243]

2023-02-09 Thread Patrick Palka via Gcc-patches
> > > if (TREE_CODE (r) != CALL_EXPR) > > > > > > @@ -2971,7 +2989,7 @@ cp_fold (tree x) > > > > > > vec *nelts = NULL; > > > > > > FOR_EACH_VEC_SAFE_ELT (elts, i, p) > > > > > >

Re: [PATCH 2/2] c++: speculative constexpr and is_constant_evaluated [PR108243]

2023-02-09 Thread Jason Merrill via Gcc-patches
nericize here because that flag has additional effects in cp_fold_r, so it seems we need another flag that that only affects the manifestly constant-eval stuff; I called it ff_mce_false. How does the following look? -- >8 -- Subject: [PATCH 2/2] c++: speculative constexpr and is_constant_evaluated

Re: [PATCH 2/2] c++: speculative constexpr and is_constant_evaluated [PR108243]

2023-02-09 Thread Patrick Palka via Gcc-patches
gt; > > > - op1 = cp_fold (TREE_OPERAND (x, 1)); > > > > - op2 = cp_fold (TREE_OPERAND (x, 2)); > > > > - op3 = cp_fold (TREE_OPERAND (x, 3)); > > > > + op0 = cp_fold (TREE_OPERAND (x, 0), flags); > > > > + op1 = cp_fold

Re: [PATCH 2/2] c++: speculative constexpr and is_constant_evaluated [PR108243]

2023-02-05 Thread Jason Merrill via Gcc-patches
fold_init. So it seems we need to make cp_fold when called from the latter entry point to also assume m_c_e is false. We can't re-use ff_genericize here because that flag has additional effects in cp_fold_r, so it seems we need another flag that that only affects the manifestly constant-ev

Re: [PATCH 2/2] c++: speculative constexpr and is_constant_evaluated [PR108243]

2023-02-03 Thread Patrick Palka via Gcc-patches
= cp_fold (TREE_OPERAND (x, 0)); > > > + r = cp_fold (TREE_OPERAND (x, 0), flags); > > > if (tree_invariant_p (r)) > > > x = r; > > > break; > > > @@ -3069,7 +3087,7 @@ cp_fold (tree x) > > > copy_warn

Re: [PATCH 2/2] c++: speculative constexpr and is_constant_evaluated [PR108243]

2023-02-03 Thread Patrick Palka via Gcc-patches
(!c.evaluation_restricted_p ()) > > + if (cache_p && !c.evaluation_restricted_p ()) > > { > > fold_cache->put (org_x, x); > > /* Prevent that we try to fold an already folded result again. */ > > diff --git a/gcc/testsuite/g++.dg/opt/

Re: [PATCH 2/2] c++: speculative constexpr and is_constant_evaluated [PR108243]

2023-01-30 Thread Jason Merrill via Gcc-patches
On 1/27/23 17:02, Patrick Palka wrote: This PR illustrates that __builtin_is_constant_evaluated currently acts as an optimization barrier for our speculative constexpr evaluation, since we don't want to prematurely fold the builtin to false if the expression in question would be later manifestly

Re: [PATCH 2/2] c++: speculative constexpr and is_constant_evaluated [PR108243]

2023-01-27 Thread Patrick Palka via Gcc-patches
On Fri, 27 Jan 2023, Patrick Palka wrote: > This PR illustrates that __builtin_is_constant_evaluated currently acts > as an optimization barrier for our speculative constexpr evaluation, > since we don't want to prematurely fold the builtin to false if the > expression in question would be later

[PATCH 2/2] c++: speculative constexpr and is_constant_evaluated [PR108243]

2023-01-27 Thread Patrick Palka via Gcc-patches
This PR illustrates that __builtin_is_constant_evaluated currently acts as an optimization barrier for our speculative constexpr evaluation, since we don't want to prematurely fold the builtin to false if the expression in question would be later manifestly constant evaluated (in which case it