Re: [PATCH] Fix wrong code out of NRV + RSO + inlining (take 2)

2024-10-01 Thread Richard Biener
On Tue, Oct 1, 2024 at 12:01 PM Eric Botcazou wrote: > > Hi, > > the attached Ada testcase compiled with -O -flto exhibits a wrong code issue > when the 3 optimizations NRV + RSO + inlining are applied to the same call: if > the LHS of the call is marked write-only before inlining, then it will ke

[PATCH] Fix wrong code out of NRV + RSO + inlining (take 2)

2024-10-01 Thread Eric Botcazou
Hi, the attached Ada testcase compiled with -O -flto exhibits a wrong code issue when the 3 optimizations NRV + RSO + inlining are applied to the same call: if the LHS of the call is marked write-only before inlining, then it will keep the mark after inlining although it may be read in GIMPLE f

Re: [PATCH] Fix wrong code out of NRV + RSO + inlining

2024-09-11 Thread Richard Biener
On Wed, Sep 11, 2024 at 12:38 PM Eric Botcazou wrote: > > > Hmm, it looks to me that the IPA analysis marking the variable readonly > > in the first place is wrong - or that NRV may not be applied to such a > > variable later. Is NRV ever applied to say > > > > static const S s = ...; > > > > s =

Re: [PATCH] Fix wrong code out of NRV + RSO + inlining

2024-09-11 Thread Eric Botcazou
> Hmm, it looks to me that the IPA analysis marking the variable readonly > in the first place is wrong - or that NRV may not be applied to such a > variable later. Is NRV ever applied to say > > static const S s = ...; > > s = foo (); > > thus a readonly declared LHS? But NRV is only an examp

Re: [PATCH] Fix wrong code out of NRV + RSO + inlining

2024-09-11 Thread Richard Biener
On Wed, Sep 11, 2024 at 10:26 AM Eric Botcazou wrote: > > Hi, > > the attached Ada testcase compiled with -O -flto exhibits a wrong code issue > when the 3 optimizations NRV + RSO + inlining are applied to the same call: if > the LHS of the call is marked write-only before inlining, then it will k

[PATCH] Fix wrong code out of NRV + RSO + inlining

2024-09-11 Thread Eric Botcazou
Hi, the attached Ada testcase compiled with -O -flto exhibits a wrong code issue when the 3 optimizations NRV + RSO + inlining are applied to the same call: if the LHS of the call is marked write-only before inlining, then it will keep the mark after inlining although it may be read in GIMPLE f