Build fails during compiling libgcc. ../../../ORIG/trunk/libgcc/fp-bit.c: In function '__muldf3': ../../../ORIG/trunk/libgcc/fp-bit.c:944:1: error: invalid rtl sharing found in the insn } ^ (insn 804 311 318 28 (set (reg:SI 147 t) (eq:SI (and:SI (subreg:SI (reg/v:DI 205 [ high ]) 0) (const_int 1 [0x1])) (const_int 0 [0]))) "../../../ORIG/trunk/libgcc/fp-bit.c":881 -1 (nil)) ../../../ORIG/trunk/libgcc/fp-bit.c:944:1: error: shared rtx (subreg:SI (reg/v:DI 205 [ high ]) 0) ../../../ORIG/trunk/libgcc/fp-bit.c:944:1: internal compiler error: internal consistency failure 0x8386b17 verify_rtx_sharing ../../ORIG/trunk/gcc/emit-rtl.c:2743 0x8386a28 verify_rtx_sharing ../../ORIG/trunk/gcc/emit-rtl.c:2758 0x8386a28 verify_rtx_sharing ../../ORIG/trunk/gcc/emit-rtl.c:2758 0x8386a28 verify_rtx_sharing ../../ORIG/trunk/gcc/emit-rtl.c:2758 0x8386feb verify_insn_sharing ../../ORIG/trunk/gcc/emit-rtl.c:2829 0x838b256 verify_rtl_sharing() ../../ORIG/trunk/gcc/emit-rtl.c:2852 0x8606233 execute_function_todo ../../ORIG/trunk/gcc/passes.c:1982 0x8606a9b do_per_function ../../ORIG/trunk/gcc/passes.c:1649 0x8606c1d execute_todo ../../ORIG/trunk/gcc/passes.c:2015 It looks that re-enabled RTL sharing verification reveals some rtl sharing issue of this target.
Here is a trial patch diff --git a/config/sh/sh.md b/config/sh/sh.md index c6956a0..c83bf08 100644 --- a/config/sh/sh.md +++ b/config/sh/sh.md @@ -858,7 +858,8 @@ operands of the tstsi_t insn, which is generally the case. */ if (dump_file) fprintf (dump_file, "cmpeqsi_t: replacing with tstsi_t\n"); - emit_insn (gen_tstsi_t (XEXP (op.set_src, 0), XEXP (op.set_src, 1))); + emit_insn (gen_tstsi_t (copy_rtx (XEXP (op.set_src, 0)), + XEXP (op.set_src, 1))); DONE; } Oleg, could you take a look at the issue? Although the patch fixes the ICE, I'm not sure if it's OK and enough.
Looks not enough. Even with the patch, I got a similar ICE for lto case in testsuite: FAIL: gcc.dg/atomic/stdatomic-op-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (internal compiler error) gcc.log says /exp/ldroot/dodes/ORIG/trunk/gcc/testsuite/gcc.dg/atomic/stdatomic-op-1.c: In function 'main': /exp/ldroot/dodes/ORIG/trunk/gcc/testsuite/gcc.dg/atomic/stdatomic-op-1.c:341:1: error: invalid rtl sharing found in the insn (insn 1527 292 294 23 (set (reg:SI 147 t) (eq:SI (subreg:SI (reg:QI 559) 0) (const_int 0 [0]))) "/exp/ldroot/dodes/ORIG/trunk/gcc/testsuite/gcc.dg/atomic/stdatomic-op-1.c":94 -1 (nil)) /exp/ldroot/dodes/ORIG/trunk/gcc/testsuite/gcc.dg/atomic/stdatomic-op-1.c:341:1: error: shared rtx (subreg:SI (reg:QI 559) 0) /exp/ldroot/dodes/ORIG/trunk/gcc/testsuite/gcc.dg/atomic/stdatomic-op-1.c:341:1: internal compiler error: internal consistency failure 0x829cca7 verify_rtx_sharing ../../ORIG/trunk/gcc/emit-rtl.c:2743 and it went away with the patch below. diff --git a/config/sh/sh.md b/config/sh/sh.md index c6956a0..667a9a5 100644 --- a/config/sh/sh.md +++ b/config/sh/sh.md @@ -607,7 +607,7 @@ { if (dump_file) fprintf (dump_file, "tstsi_t: converting to cmpeqsi_t\n"); - emit_insn (gen_cmpeqsi_t (eop0.use_as_extended_reg (curr_insn), + emit_insn (gen_cmpeqsi_t (copy_rtx(eop0.use_as_extended_reg (curr_insn)), const0_rtx)); DONE; }
Likely latent on release branches.
Now I can't reproduce the ICEs for the revision 243217. They failed for the revision 243091. I'm not sure whether the issue is false positive or not. I'd like to keep this PR for a while.
(In reply to Kazumoto Kojima from comment #1) > Here is a trial patch > > diff --git a/config/sh/sh.md b/config/sh/sh.md > index c6956a0..c83bf08 100644 > --- a/config/sh/sh.md > +++ b/config/sh/sh.md > @@ -858,7 +858,8 @@ > operands of the tstsi_t insn, which is generally the case. */ > if (dump_file) > fprintf (dump_file, "cmpeqsi_t: replacing with tstsi_t\n"); > - emit_insn (gen_tstsi_t (XEXP (op.set_src, 0), XEXP (op.set_src, 1))); > + emit_insn (gen_tstsi_t (copy_rtx (XEXP (op.set_src, 0)), > + XEXP (op.set_src, 1))); > DONE; > } > > Oleg, could you take a look at the issue? Although the patch fixes > the ICE, I'm not sure if it's OK and enough. Hm ... if this is a latent bug, I would like to understand why it's wrong to reference a reg rtx in the insn input operands. I've been doing that in several places in similar ways...
I've tried a bi-sect on git tree. The ICE went away with commit c95f3fa2db12f22bbb2158d18c95f6714b4292b8 Author: krebbel <krebbel@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Fri Dec 2 08:32:40 2016 +0000 Do not simplify "(and (reg) (const bit)" to if_then_else. which corresponds to 2016-12-02 Dominik Vogt <vogt@linux.vnet.ibm.com> * combine.c (combine_simplify_rtx): Suppress replacement of "(and (reg) (const_int bit))" with "if_then_else". on svn. The ICE pops up again with reverting it on HAED. I don't get what was going on without it, though.
Maybe it's this thread? https://gcc.gnu.org/ml/gcc-patches/2016-12/msg00334.html
There's a typo in the patch. Should be reverted in a minute. Sorry for the trouble.
The faulty patch has been reverted in r243256.
Ah, don't mind. Your patch accidentally hides this PR. Now the SH build failure comes back on trunk :-)
Created attachment 40271 [details] reduce testcase With -O1, sh4-linux compiler makes insns (insn 67 150 165 5 (set (reg:SI 239) (and:SI (subreg:SI (reg/v:DI 163 [ high ]) 0) (const_int 1 [0x1]))) "test.c":34 88 {*andsi_compact} (nil)) (insn 165 67 74 5 (set (reg:SI 147 t) (eq:SI (and:SI (subreg:SI (reg/v:DI 163 [ high ]) 0) (const_int 1 [0x1])) (const_int 0 [0]))) "test.c":34 -1 (nil)) and two (subreg:SI (reg/v:DI 163 [ high ]) 0) are shared. emit-rtl.c:verify_rtl_sharing calls verify_insn_sharing for these insns and verify_insn_sharing marks rtxes with verify_rtx_sharing. SUBREG rtx is always marked as used with verify_rtx_sharing. Then the second subreg is reported as erroneous because it's already marked as used. I think that this is a false positive. It seems to me that SUBREG should be handled specially. diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 4650540..4fa4773 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -2714,6 +2714,9 @@ verify_rtx_sharing (rtx orig, rtx insn) case SCRATCH: /* SCRATCH must be shared because they represent distinct values. */ return; + case SUBREG: + verify_rtx_sharing (SUBREG_REG (x), insn); + return; case CLOBBER: /* Share clobbers of hard registers (like cc0), but do not share pseudo reg clobbers or clobbers of hard registers that originated as pseudos. I could be totally wrong about that, though.
Hmm... From https://gcc.gnu.org/onlinedocs/gccint/Sharing.html#Sharing the above patch looks wrong. Perhaps the splitter in problem might have to take care of subreg case even when referencing a reg rtx in the input operands.
(In reply to Kazumoto Kojima from comment #12) > Perhaps the splitter in problem > might have to take care of subreg case even when referencing > a reg rtx in the input operands. So it looks like a new rtx object should be created when referencing a subreg. That's ... a problem. I have been ignoring this for a while, so I guess there are several places which need patching. I can reproduce the error on sh-elf. I will look at it, but I'm very busy at the moment, so it will take some time.
No problem. I can continue nightly build&test with a minimal change diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index c6956a0..edadba7 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -858,7 +858,8 @@ operands of the tstsi_t insn, which is generally the case. */ if (dump_file) fprintf (dump_file, "cmpeqsi_t: replacing with tstsi_t\n"); - emit_insn (gen_tstsi_t (XEXP (op.set_src, 0), XEXP (op.set_src, 1))); + emit_insn (gen_tstsi_t (copy_rtx (XEXP (op.set_src, 0)), + copy_rtx (XEXP (op.set_src, 1)))); DONE; } added to my local git tree so as not to miss other breakages on trunk.
*** Bug 79063 has been marked as a duplicate of this bug. ***
When a fix exists, why hasn't it been posted to gcc-patches?
(In reply to Jakub Jelinek from comment #16) > When a fix exists, why hasn't it been posted to gcc-patches? Because, like I wrote in comment #13, I would like to check if there might be a better fix for the problem. If not, we will commit the patch in comment #11 for GCC 7.
If the original insn that has the op.set_src rtx in it is not removed by the splitter (which it seems it is not), and it is just expected to be removed during DCE later, then doing copy_rtx is the right thing to do there, sharing non-shareable RTXes between multiple instructions, even when it is just for a couple of passes, is invalid.
Author: kkojima Date: Tue Jan 17 04:07:51 2017 New Revision: 244516 URL: https://gcc.gnu.org/viewcvs?rev=244516&root=gcc&view=rev Log: PR target/78633 * config/sh/sh.md (cmpeqsi_t+1): Call copy_rtx to avoid invalid RTL sharing. Modified: trunk/gcc/ChangeLog trunk/gcc/config/sh/sh.md
I've applied a quick fix. I'd like to keep this open for further checks.
GCC 7.1 has been released.
GCC 7.3 is being released, adjusting target milestone.
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
GCC 8.4.0 has been released, adjusting target milestone.
GCC 8 branch is being closed.
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
GCC 9 branch is being closed
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
GCC 10 branch is being closed.
GCC 11 branch is being closed.