[Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108573 --- Comment #8 from CVS Commits --- The releases/gcc-10 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:d868dd64ccd176cbd2829aa6175b40323f937b20 commit r10-11361-gd868dd64ccd176cbd2829aa6175b40323f937b20 Author: Jakub Jelinek Date: Wed Feb 1 12:52:52 2023 +0100 ree: Fix -fcompare-debug issues in combine_reaching_defs [PR108573] The PR78437 r7-4871 changes made combine_reaching_defs punt on WORD_REGISTER_OPERATIONS targets if a setter of smaller than word register has wider uses. This unfortunately breaks -fcompare-debug, because if such a use appears only in DEBUG_INSN(s), while all other uses aren't wider than the setter, we can REE optimize it without -g and not with -g. Such decisions shouldn't be based on debug instructions. We could try to reset them or adjust in some other way after we decide to perform the change, but at least on the testcase which used to fail on riscv64-linux the (debug_insn 8 7 9 2 (var_location:HI s (minus:HI (subreg:HI (and:DI (reg:DI 10 a0 [160]) (const_int 1 [0x1])) 0) (subreg:HI (ashiftrt:DI (reg/v:DI 9 s1 [orig:151 l ] [151]) (debug_expr:SI D#1)) 0))) "pr108573.c":12:5 -1 (nil)) clearly doesn't care about the upper bits and I have hard time imaging how could one end up with DEBUG_INSN which actually cares about those upper bits. So, the following patch just ignores uses on DEBUG_INSNs in this case, if we run into something where we'd need to do something further later on, let's deal with it when we have a testcase for it. 2023-02-01 Jakub Jelinek PR debug/108573 * ree.c (combine_reaching_defs): Don't return false for paradoxical subregs in DEBUG_INSNs. * gcc.dg/pr108573.c: New test. (cherry picked from commit e4473d7cf871c8ddf8f22d105c5af6375ebe37bf)
[Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108573 --- Comment #7 from CVS Commits --- The releases/gcc-11 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:c8aee6e44b5829ce3baafd358d2ff9f30ee7e88b commit r11-10706-gc8aee6e44b5829ce3baafd358d2ff9f30ee7e88b Author: Jakub Jelinek Date: Wed Feb 1 12:52:52 2023 +0100 ree: Fix -fcompare-debug issues in combine_reaching_defs [PR108573] The PR78437 r7-4871 changes made combine_reaching_defs punt on WORD_REGISTER_OPERATIONS targets if a setter of smaller than word register has wider uses. This unfortunately breaks -fcompare-debug, because if such a use appears only in DEBUG_INSN(s), while all other uses aren't wider than the setter, we can REE optimize it without -g and not with -g. Such decisions shouldn't be based on debug instructions. We could try to reset them or adjust in some other way after we decide to perform the change, but at least on the testcase which used to fail on riscv64-linux the (debug_insn 8 7 9 2 (var_location:HI s (minus:HI (subreg:HI (and:DI (reg:DI 10 a0 [160]) (const_int 1 [0x1])) 0) (subreg:HI (ashiftrt:DI (reg/v:DI 9 s1 [orig:151 l ] [151]) (debug_expr:SI D#1)) 0))) "pr108573.c":12:5 -1 (nil)) clearly doesn't care about the upper bits and I have hard time imaging how could one end up with DEBUG_INSN which actually cares about those upper bits. So, the following patch just ignores uses on DEBUG_INSNs in this case, if we run into something where we'd need to do something further later on, let's deal with it when we have a testcase for it. 2023-02-01 Jakub Jelinek PR debug/108573 * ree.c (combine_reaching_defs): Don't return false for paradoxical subregs in DEBUG_INSNs. * gcc.dg/pr108573.c: New test. (cherry picked from commit e4473d7cf871c8ddf8f22d105c5af6375ebe37bf)
[Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108573 --- Comment #6 from CVS Commits --- The releases/gcc-12 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:7bd8b65bd5d51a33f31ec39dfb435b84e36260e9 commit r12-9149-g7bd8b65bd5d51a33f31ec39dfb435b84e36260e9 Author: Jakub Jelinek Date: Wed Feb 1 12:52:52 2023 +0100 ree: Fix -fcompare-debug issues in combine_reaching_defs [PR108573] The PR78437 r7-4871 changes made combine_reaching_defs punt on WORD_REGISTER_OPERATIONS targets if a setter of smaller than word register has wider uses. This unfortunately breaks -fcompare-debug, because if such a use appears only in DEBUG_INSN(s), while all other uses aren't wider than the setter, we can REE optimize it without -g and not with -g. Such decisions shouldn't be based on debug instructions. We could try to reset them or adjust in some other way after we decide to perform the change, but at least on the testcase which used to fail on riscv64-linux the (debug_insn 8 7 9 2 (var_location:HI s (minus:HI (subreg:HI (and:DI (reg:DI 10 a0 [160]) (const_int 1 [0x1])) 0) (subreg:HI (ashiftrt:DI (reg/v:DI 9 s1 [orig:151 l ] [151]) (debug_expr:SI D#1)) 0))) "pr108573.c":12:5 -1 (nil)) clearly doesn't care about the upper bits and I have hard time imaging how could one end up with DEBUG_INSN which actually cares about those upper bits. So, the following patch just ignores uses on DEBUG_INSNs in this case, if we run into something where we'd need to do something further later on, let's deal with it when we have a testcase for it. 2023-02-01 Jakub Jelinek PR debug/108573 * ree.cc (combine_reaching_defs): Don't return false for paradoxical subregs in DEBUG_INSNs. * gcc.dg/pr108573.c: New test. (cherry picked from commit e4473d7cf871c8ddf8f22d105c5af6375ebe37bf)
[Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108573 Jakub Jelinek changed: What|Removed |Added Resolution|--- |FIXED Status|NEW |RESOLVED --- Comment #5 from Jakub Jelinek --- Fixed.
[Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108573 --- Comment #4 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:e4473d7cf871c8ddf8f22d105c5af6375ebe37bf commit r13-5625-ge4473d7cf871c8ddf8f22d105c5af6375ebe37bf Author: Jakub Jelinek Date: Wed Feb 1 12:52:52 2023 +0100 ree: Fix -fcompare-debug issues in combine_reaching_defs [PR108573] The PR78437 r7-4871 changes made combine_reaching_defs punt on WORD_REGISTER_OPERATIONS targets if a setter of smaller than word register has wider uses. This unfortunately breaks -fcompare-debug, because if such a use appears only in DEBUG_INSN(s), while all other uses aren't wider than the setter, we can REE optimize it without -g and not with -g. Such decisions shouldn't be based on debug instructions. We could try to reset them or adjust in some other way after we decide to perform the change, but at least on the testcase which used to fail on riscv64-linux the (debug_insn 8 7 9 2 (var_location:HI s (minus:HI (subreg:HI (and:DI (reg:DI 10 a0 [160]) (const_int 1 [0x1])) 0) (subreg:HI (ashiftrt:DI (reg/v:DI 9 s1 [orig:151 l ] [151]) (debug_expr:SI D#1)) 0))) "pr108573.c":12:5 -1 (nil)) clearly doesn't care about the upper bits and I have hard time imaging how could one end up with DEBUG_INSN which actually cares about those upper bits. So, the following patch just ignores uses on DEBUG_INSNs in this case, if we run into something where we'd need to do something further later on, let's deal with it when we have a testcase for it. 2023-02-01 Jakub Jelinek PR debug/108573 * ree.cc (combine_reaching_defs): Don't return false for paradoxical subregs in DEBUG_INSNs. * gcc.dg/pr108573.c: New test.
[Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108573 --- Comment #3 from Jakub Jelinek --- --- gcc/ree.cc.jj 2023-01-02 09:32:45.327953792 +0100 +++ gcc/ree.cc 2023-01-31 18:36:31.253018233 +0100 @@ -875,7 +875,8 @@ combine_reaching_defs (ext_cand *cand, c for (df_link *use = uses; use; use = use->next) if (paradoxical_subreg_p (GET_MODE (*DF_REF_LOC (use->ref)), - GET_MODE (SET_DEST (*dest_sub_rtx + GET_MODE (SET_DEST (*dest_sub_rtx))) + && !DEBUG_INSN_P (DF_REF_INSN (use->ref))) return false; } fixes this particular -fcompare-debug failure. Dunno though about get_uses, it performs some checks and returns NULL if those fail (again, ignoring if the failures are from DEBUG_INSNs or something else), plus in theory there could be a non-NULL ref_chain of only debug uses (though hopefully we prevent that). And there is another spot that would need the same change as above.
[Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108573 Jakub Jelinek changed: What|Removed |Added CC||ebotcazou at gcc dot gnu.org --- Comment #2 from Jakub Jelinek --- So, I believe this has been caused by the r7-4871-g4da41abf84cc6796aa8b PR78437 change. /* On RISC machines we must make sure that changing the mode of SRC_REG as destination register will not affect its reaching uses, which may read its value in a larger mode because DEF_INSN implicitly sets it in word mode. */ poly_int64 prec = GET_MODE_PRECISION (GET_MODE (SET_DEST (*dest_sub_rtx))); if (WORD_REGISTER_OPERATIONS && known_lt (prec, BITS_PER_WORD)) { struct df_link *uses = get_uses (def_insn, src_reg); if (!uses) return false; for (df_link *use = uses; use; use = use->next) if (paradoxical_subreg_p (GET_MODE (*DF_REF_LOC (use->ref)), GET_MODE (SET_DEST (*dest_sub_rtx return false; } The problem is that without -g, there are just 2 uses: (insn 10029 10027 10052 2 (set (reg:SI 10 a0 [167]) (minus:SI (reg:SI 10 a0 [160]) (reg:SI 9 s1 [165]))) "pr108573.c":12:5 12 {subsi3} (nil)) and (insn 10023 9 10027 2 (set (reg:DI 15 a5 [orig:139 _6 ] [139]) (sign_extend:DI (reg:SI 10 a0 [160]))) "pr108573.c":11:5 116 {extendsidi2} (nil)) but with -g there another one: (debug_insn 8 7 9 2 (var_location:HI s (minus:HI (subreg:HI (and:DI (reg:DI 10 a0 [160]) (const_int 1 [0x1])) 0) (subreg:HI (ashiftrt:DI (reg/v:DI 9 s1 [orig:151 l ] [151]) (debug_expr:SI D#1)) 0))) "pr108573.c":12:5 -1 (nil)) Now, because it uses DImode for a0 rather than SImode like the others, without -g we don't return false but with -g we do. Code generation decisions shouldn't be based on the DEBUG_INSN uses. So, at least in this decision we should ignore debug uses, we can then do something with the DEBUG_INSNs, reset them, adjust, whatever (I think at least the above one clearly doesn't care about the upper bits).
[Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108573 Jakub Jelinek changed: What|Removed |Added Ever confirmed|0 |1 Status|UNCONFIRMED |NEW CC||jakub at gcc dot gnu.org Last reconfirmed||2023-01-31 --- Comment #1 from Jakub Jelinek --- This diverges during REE: Trying to eliminate extension: -(insn 10023 10022 10027 2 (set (reg:DI 15 a5 [orig:139 _6 ] [139]) +(insn 10023 9 10027 2 (set (reg:DI 15 a5 [orig:139 _6 ] [139]) (sign_extend:DI (reg:SI 10 a0 [160]))) "pr108573.c":11:5 116 {extendsidi2} (nil)) -Tentatively merged extension with definition (copy needed): -(insn 10022 10018 10023 2 (set (reg:DI 15 a5) -(sign_extend:DI (umod:SI (reg:SI 10 a0 [157]) -(reg:SI 14 a4 [orig:162 g ] [162] "pr108573.c":11:5 -1 - (nil)) -deferring rescan insn with uid = 10022. -All merges were successful. -Eliminated the extension. -deferring rescan insn with uid = 10055. -deferring deletion of insn with uid = 10023. -Elimination opportunities = 2 realized = 1 +Elimination opportunities = 2 realized = 0 starting the processing of deferred insns -rescanning insn with uid = 10022. -rescanning insn with uid = 10055. ending the processing of deferred insns
[Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108573 Richard Biener changed: What|Removed |Added Target Milestone|--- |13.0