Message ID | 20220216085334.GX2646553@tucnak |
---|---|
State | New |
Headers | show |
Series | combine: Fix up -fcompare-debug issue in the combiner [PR104544] | expand |
Hi! On Wed, Feb 16, 2022 at 09:53:34AM +0100, Jakub Jelinek wrote: > On the following testcase on aarch64-linux, we behave differently > with -g and -g0. [ huge snip ] > The following patch fixes that by instead ignoring debug insns during the > searching. We can still check BLOCK_FOR_INSN (insn) on those, because > if we notice DEBUG_INSN in a following basic block, necessarily there won't > be any further normal insns in the current block after it. > --- gcc/combine.cc.jj 2022-02-11 13:51:56.294928090 +0100 > +++ gcc/combine.cc 2022-02-15 14:15:41.663012950 +0100 > @@ -4223,10 +4223,12 @@ try_combine (rtx_insn *i3, rtx_insn *i2, > for (rtx_insn *insn = NEXT_INSN (i3); > !done > && insn > - && NONDEBUG_INSN_P (insn) > + && INSN_P (insn) > && BLOCK_FOR_INSN (insn) == this_basic_block; > insn = NEXT_INSN (insn)) > { > + if (DEBUG_INSN_P (insn)) > + continue; > struct insn_link *link; > FOR_EACH_LOG_LINK (link, insn) > if (link->insn == i3 && link->regno == regno) About half of the similar loops in combine.c are still broken this way, from a quick sampling :-( Okay for trunk and all backports you may want. Thanks! Segher
On Wed, Feb 16, 2022 at 04:44:58AM -0600, Segher Boessenkool wrote: > > --- gcc/combine.cc.jj 2022-02-11 13:51:56.294928090 +0100 > > +++ gcc/combine.cc 2022-02-15 14:15:41.663012950 +0100 > > @@ -4223,10 +4223,12 @@ try_combine (rtx_insn *i3, rtx_insn *i2, > > for (rtx_insn *insn = NEXT_INSN (i3); > > !done > > && insn > > - && NONDEBUG_INSN_P (insn) > > + && INSN_P (insn) > > && BLOCK_FOR_INSN (insn) == this_basic_block; > > insn = NEXT_INSN (insn)) > > { > > + if (DEBUG_INSN_P (insn)) > > + continue; > > struct insn_link *link; > > FOR_EACH_LOG_LINK (link, insn) > > if (link->insn == i3 && link->regno == regno) > > About half of the similar loops in combine.c are still broken this way, > from a quick sampling :-( Looking for just NONDEBUG_INSN_P, I don't see any other than this. > Okay for trunk and all backports you may want. Thanks! Thanks. Jakub
On Wed, Feb 16, 2022 at 11:55:23AM +0100, Jakub Jelinek wrote: > On Wed, Feb 16, 2022 at 04:44:58AM -0600, Segher Boessenkool wrote: > > About half of the similar loops in combine.c are still broken this way, > > from a quick sampling :-( > > Looking for just NONDEBUG_INSN_P, I don't see any other than this. Ah yes, I was confused by !NONDEBUG_INSN. Too many inversions make my head spin (NONDEBUG_INSN really means RTX_INSN && !DEBUG_INSN). So everything looks fine here now. Thanks for double checking! Segher
--- gcc/combine.cc.jj 2022-02-11 13:51:56.294928090 +0100 +++ gcc/combine.cc 2022-02-15 14:15:41.663012950 +0100 @@ -4223,10 +4223,12 @@ try_combine (rtx_insn *i3, rtx_insn *i2, for (rtx_insn *insn = NEXT_INSN (i3); !done && insn - && NONDEBUG_INSN_P (insn) + && INSN_P (insn) && BLOCK_FOR_INSN (insn) == this_basic_block; insn = NEXT_INSN (insn)) { + if (DEBUG_INSN_P (insn)) + continue; struct insn_link *link; FOR_EACH_LOG_LINK (link, insn) if (link->insn == i3 && link->regno == regno) --- gcc/testsuite/gcc.dg/pr104544.c.jj 2022-02-15 14:17:50.154221461 +0100 +++ gcc/testsuite/gcc.dg/pr104544.c 2022-02-15 14:17:34.441440536 +0100 @@ -0,0 +1,19 @@ +/* PR rtl-optimization/104544 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +int m, n; +__int128 q; + +void +bar (unsigned __int128 x, int y) +{ + if (x) + q += y; +} + +void +foo (void) +{ + bar (!!q - 1, (m += m ? m : 1) < n); +}