Re: [PATCH V2] Disable sched1 in functions that call setjmp

2023-01-05 Thread Qing Zhao via Gcc-patches
Alexander, (Sorry for the late reply due to holiday vacation). > On Dec 24, 2022, at 3:10 AM, Alexander Monakov wrote: > > > On Fri, 23 Dec 2022, Qing Zhao wrote: > >> BTW, Why sched1 is not enabled on x86 by default? > > Register allocation is tricky on x86 due to small number of

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-25 Thread Segher Boessenkool
Hi! On Sat, Dec 24, 2022 at 10:58:41AM +0100, Jose E. Marchesi via Gcc-patches wrote: > Allright, so we have two short-term alternatives for at least remove the > possibility that GCC generates wrong code for valid C when the scheduler > is turned on: > > a) To disable sched1 in functions that

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-24 Thread Alexander Monakov via Gcc-patches
On Sat, 24 Dec 2022, Jose E. Marchesi wrote: > However, there is something I don't understand: wouldn't sched2 > introduce the same problem when -fsched2-use-superblocks is specified? Superblocks are irrelevant, a call instruction does not end a basic block and the problematic motion happens

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-24 Thread Richard Biener via Gcc-patches
> Am 24.12.2022 um 10:54 schrieb Jose E. Marchesi : > >  Am 24.12.2022 um 09:11 schrieb Alexander Monakov via Gcc-patches : >>> >>>  On Fri, 23 Dec 2022, Qing Zhao wrote: BTW, Why sched1 is not enabled on x86 by default? >>> >>> Register allocation is tricky on

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-24 Thread Jose E. Marchesi via Gcc-patches
>> Am 24.12.2022 um 09:11 schrieb Alexander Monakov via Gcc-patches >> : >> >>  >>> On Fri, 23 Dec 2022, Qing Zhao wrote: >>> >>> BTW, Why sched1 is not enabled on x86 by default? >> >> Register allocation is tricky on x86 due to small number of general-purpose >> registers, and sched1 can

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-24 Thread Richard Biener via Gcc-patches
> Am 24.12.2022 um 09:11 schrieb Alexander Monakov via Gcc-patches > : > >  >> On Fri, 23 Dec 2022, Qing Zhao wrote: >> >> BTW, Why sched1 is not enabled on x86 by default? > > Register allocation is tricky on x86 due to small number of general-purpose > registers, and sched1 can make it

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-24 Thread Alexander Monakov via Gcc-patches
On Fri, 23 Dec 2022, Qing Zhao wrote: > BTW, Why sched1 is not enabled on x86 by default? Register allocation is tricky on x86 due to small number of general-purpose registers, and sched1 can make it even more difficult. I think before register pressure modeling was added, sched1 could not be

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-23 Thread Qing Zhao via Gcc-patches
> On Dec 23, 2022, at 2:36 PM, Alexander Monakov wrote: > > > > On Fri, 23 Dec 2022, Qing Zhao wrote: > >> Then, sched2 still can move insn across calls? >> So does sched2 have the same issue of incorrectly moving the insn across a >> call which has unknown control flow? > > I think

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-23 Thread Alexander Monakov via Gcc-patches
On Fri, 23 Dec 2022, Qing Zhao wrote: > Then, sched2 still can move insn across calls? > So does sched2 have the same issue of incorrectly moving the insn across a > call which has unknown control flow? I think problems are unlikely because register allocator assigns pseudos that cross

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-23 Thread Qing Zhao via Gcc-patches
Then, sched2 still can move insn across calls? So does sched2 have the same issue of incorrectly moving the insn across a call which has unknown control flow? Qing > On Dec 23, 2022, at 12:31 PM, Alexander Monakov wrote: > > > On Fri, 23 Dec 2022, Jose E. Marchesi wrote: > >>> (scheduling

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-23 Thread Jose E. Marchesi via Gcc-patches
> On Fri, 23 Dec 2022, Jose E. Marchesi wrote: > >> > (scheduling across calls in sched2 is somewhat dubious as well, but >> > it doesn't risk register pressure issues, and on VLIW CPUs it at least >> > can result in better VLIW packing) >> >> Does sched2 actually schedule across calls? All

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-23 Thread Alexander Monakov via Gcc-patches
On Fri, 23 Dec 2022, Jose E. Marchesi wrote: > > (scheduling across calls in sched2 is somewhat dubious as well, but > > it doesn't risk register pressure issues, and on VLIW CPUs it at least > > can result in better VLIW packing) > > Does sched2 actually schedule across calls? All the

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-23 Thread Jose E. Marchesi via Gcc-patches
> On Fri, 23 Dec 2022, Qing Zhao wrote: >> >> I am a little confused, you mean pre-RA scheduler does not look at the >> >> data flow >> >> information at all when scheduling insns across calls currently? >> > >> > I think it does not inspect liveness info, and may extend lifetime of a >> >

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-23 Thread Alexander Monakov via Gcc-patches
On Fri, 23 Dec 2022, Qing Zhao wrote: > >> I am a little confused, you mean pre-RA scheduler does not look at the > >> data flow > >> information at all when scheduling insns across calls currently? > > > > I think it does not inspect liveness info, and may extend lifetime of a > > pseudo > >

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-23 Thread Qing Zhao via Gcc-patches
> On Dec 23, 2022, at 2:33 AM, Alexander Monakov wrote: > > > On Thu, 22 Dec 2022, Qing Zhao wrote: > >>> I think scheduling across calls in the pre-RA scheduler is simply an >>> oversight, >>> we do not look at dataflow information and with 50% chance risk extending >>> lifetime of a

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-23 Thread Jose E. Marchesi via Gcc-patches
> Alexander Monakov via Gcc-patches writes: >> On Thu, 22 Dec 2022, Jose E. Marchesi via Gcc-patches wrote: >> >>> The first instruction scheduler pass reorders instructions in the TRY >>> block in a way `b=true' gets executed before the call to the function >>> `f'. This optimization is

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-23 Thread Richard Sandiford via Gcc-patches
Alexander Monakov via Gcc-patches writes: > On Thu, 22 Dec 2022, Jose E. Marchesi via Gcc-patches wrote: > >> The first instruction scheduler pass reorders instructions in the TRY >> block in a way `b=true' gets executed before the call to the function >> `f'. This optimization is wrong, because

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-22 Thread Alexander Monakov via Gcc-patches
On Thu, 22 Dec 2022, Qing Zhao wrote: > > I think scheduling across calls in the pre-RA scheduler is simply an > > oversight, > > we do not look at dataflow information and with 50% chance risk extending > > lifetime of a pseudoregister across a call, causing higher register > > pressure at >

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-22 Thread Qing Zhao via Gcc-patches
> On Dec 22, 2022, at 12:56 PM, Alexander Monakov wrote: > > > On Thu, 22 Dec 2022, Jose E. Marchesi via Gcc-patches wrote: > >> The first instruction scheduler pass reorders instructions in the TRY >> block in a way `b=true' gets executed before the call to the function >> `f'. This

Re: [PATCH V2] Disable sched1 in functions that call setjmp

2022-12-22 Thread Alexander Monakov via Gcc-patches
On Thu, 22 Dec 2022, Jose E. Marchesi via Gcc-patches wrote: > The first instruction scheduler pass reorders instructions in the TRY > block in a way `b=true' gets executed before the call to the function > `f'. This optimization is wrong, because `main' calls setjmp and `f' > is known to call

[PATCH V2] Disable sched1 in functions that call setjmp

2022-12-22 Thread Jose E. Marchesi via Gcc-patches
When the following testcase is built with -fschedule-insns in either x86_64 or aarch64: #include #include #include jmp_buf ex_buf__; #define TRY do{ if( !setjmp(ex_buf__) ){ #define CATCH } else { #define ETRY } }while(0) #define THROW longjmp(ex_buf__, 1) int f(int x)