Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-11-01 Thread Patrick Palka via Gcc-patches
On Mon, 1 Nov 2021, Patrick Palka wrote: > On Fri, 29 Oct 2021, Jakub Jelinek wrote: > > > On Thu, Oct 28, 2021 at 03:35:20PM -0400, Patrick Palka wrote: > > > > Is there a reason to turn this mode of evaluating everything twice if an > > > > error should be diagnosed all the time, rather than

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-11-01 Thread Patrick Palka via Gcc-patches
On Fri, 29 Oct 2021, Jakub Jelinek wrote: > On Thu, Oct 28, 2021 at 03:35:20PM -0400, Patrick Palka wrote: > > > Is there a reason to turn this mode of evaluating everything twice if an > > > error should be diagnosed all the time, rather than only if we actually > > > see > > > a TRUTH_*_EXPR

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-29 Thread Jakub Jelinek via Gcc-patches
On Thu, Oct 28, 2021 at 03:35:20PM -0400, Patrick Palka wrote: > > Is there a reason to turn this mode of evaluating everything twice if an > > error should be diagnosed all the time, rather than only if we actually see > > a TRUTH_*_EXPR we want to handle this way? > > If we don't see any

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-28 Thread Patrick Palka via Gcc-patches
On Thu, 28 Oct 2021, Jakub Jelinek wrote: > On Thu, Oct 28, 2021 at 12:40:02PM -0400, Patrick Palka wrote: > > PR c++/102780 > > > > gcc/cp/ChangeLog: > > > > * constexpr.c (potential_constant_expression_1) : > > When tf_error isn't set, preemptively check potentiality of the > >

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-28 Thread Jakub Jelinek via Gcc-patches
On Thu, Oct 28, 2021 at 12:40:02PM -0400, Patrick Palka wrote: > PR c++/102780 > > gcc/cp/ChangeLog: > > * constexpr.c (potential_constant_expression_1) : > When tf_error isn't set, preemptively check potentiality of the > second operand before performing trial evaluation

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-28 Thread Patrick Palka via Gcc-patches
ecursive call. The revised diff below fixes this thinko, and so > > only a single extra stack frame is needed AFAICT. > > > > > What did you think of Jakub's suggestion of linearizing the terms? > > > > IIUC that would fix the quadraticness, but it wouldn't ad

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-27 Thread Jason Merrill via Gcc-patches
On 10/27/21 17:10, Patrick Palka wrote: On Wed, 27 Oct 2021, Jason Merrill wrote: On 10/27/21 14:54, Patrick Palka wrote: On Tue, 26 Oct 2021, Jakub Jelinek wrote: On Tue, Oct 26, 2021 at 05:07:43PM -0400, Patrick Palka wrote: The performance impact of the other calls to

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-27 Thread Patrick Palka via Gcc-patches
On Wed, 27 Oct 2021, Jason Merrill wrote: > On 10/27/21 14:54, Patrick Palka wrote: > > On Tue, 26 Oct 2021, Jakub Jelinek wrote: > > > > > On Tue, Oct 26, 2021 at 05:07:43PM -0400, Patrick Palka wrote: > > > > The performance impact of the other calls to > > > > cxx_eval_outermost_const_expr >

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-27 Thread Jason Merrill via Gcc-patches
On 10/27/21 14:54, Patrick Palka wrote: On Tue, 26 Oct 2021, Jakub Jelinek wrote: On Tue, Oct 26, 2021 at 05:07:43PM -0400, Patrick Palka wrote: The performance impact of the other calls to cxx_eval_outermost_const_expr from p_c_e_1 is probably already mostly mitigated by the constexpr call

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-27 Thread Patrick Palka via Gcc-patches
On Tue, 26 Oct 2021, Jakub Jelinek wrote: > On Tue, Oct 26, 2021 at 05:07:43PM -0400, Patrick Palka wrote: > > The performance impact of the other calls to cxx_eval_outermost_const_expr > > from p_c_e_1 is probably already mostly mitigated by the constexpr call > > cache and the fact that we try

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-26 Thread Jakub Jelinek via Gcc-patches
On Tue, Oct 26, 2021 at 05:07:43PM -0400, Patrick Palka wrote: > The performance impact of the other calls to cxx_eval_outermost_const_expr > from p_c_e_1 is probably already mostly mitigated by the constexpr call > cache and the fact that we try to evaluate all calls to constexpr > functions

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-26 Thread Patrick Palka via Gcc-patches
On Tue, 26 Oct 2021, Jason Merrill wrote: > On Tue, Oct 26, 2021 at 2:46 PM Jakub Jelinek via Gcc-patches > wrote: > On Tue, Oct 26, 2021 at 01:44:18PM -0400, Patrick Palka via Gcc-patches > wrote: > > In the testcase below the two left fold expressions each expand into a > >

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-26 Thread Jakub Jelinek via Gcc-patches
On Tue, Oct 26, 2021 at 03:29:02PM -0400, Jason Merrill wrote: > On Tue, Oct 26, 2021 at 2:46 PM Jakub Jelinek via Gcc-patches < > gcc-patches@gcc.gnu.org> wrote: > > > On Tue, Oct 26, 2021 at 01:44:18PM -0400, Patrick Palka via Gcc-patches > > wrote: > > > In the testcase below the two left fold

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-26 Thread Jason Merrill via Gcc-patches
On Tue, Oct 26, 2021 at 2:46 PM Jakub Jelinek via Gcc-patches < gcc-patches@gcc.gnu.org> wrote: > On Tue, Oct 26, 2021 at 01:44:18PM -0400, Patrick Palka via Gcc-patches > wrote: > > In the testcase below the two left fold expressions each expand into a > > logical expression with 1024 terms, for

Re: [PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-26 Thread Jakub Jelinek via Gcc-patches
On Tue, Oct 26, 2021 at 01:44:18PM -0400, Patrick Palka via Gcc-patches wrote: > In the testcase below the two left fold expressions each expand into a > logical expression with 1024 terms, for which potential_const_expr_1 > takes more than a minute to return true. This is because p_c_e_1 >

[PATCH] c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]

2021-10-26 Thread Patrick Palka via Gcc-patches
In the testcase below the two left fold expressions each expand into a logical expression with 1024 terms, for which potential_const_expr_1 takes more than a minute to return true. This is because p_c_e_1 performs trial evaluation of the first operand of a &&/|| in order to determine whether to