+FAIL: gfortran.dg/g77/19990826-3.f -O (internal compiler error) +FAIL: gfortran.dg/g77/19990826-3.f -O (test for excess errors) This showed up between revision 128118 and 128143. /home/apinski/src/local/gcc/gcc/testsuite/gfortran.dg/g77/19990826-3.f:319: error: invalid rtl sharing found in the insn /home/apinski/src/local/gcc/gcc/testsuite/gfortran.dg/g77/19990826-3.f:319: error: shared rtx (mem/c/i:SI (plus:DI (reg/f:DI 113 sfp) (const_int 244 [0xf4])) [0 S4 A32])
I have reduced the test to: C* PCAPOP SUBROUTINE PCAPOP() DIMENSION NVA(6) C ! P1=FLOAT(NB)/FLOAT(M1) 10 IP1=P1 IF(IP1.GE.NVA(K)) GOTO 7 IF(IP2.EQ.0) GOTO 3 7 IF(K.EQ.6) GOTO 11 GOTO 10 11 IP1=0 3 CONTINUE END It gives slightly different failures at -O1: 19990826-3_red.f: In function 'pcapop': 19990826-3_red.f:12: error: invalid rtl sharing found in the insn (insn 42 41 43 2 19990826-3_red.f:7 (set (reg:SI 136) (mem/c/i:SI (plus:SI (reg/f:SI 113 sfp) (const_int 60 [0x3c])) [0 S4 A32])) 328 {*movsi_internal1} (expr_list:REG_EQUAL (fix:SI (reg:DF 134)) (nil))) 19990826-3_red.f:12: error: shared rtx (mem/c/i:SI (plus:SI (reg/f:SI 113 sfp) (const_int 60 [0x3c])) [0 S4 A32]) 19990826-3_red.f:12: internal compiler error: internal consistency failure Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. -O2: 19990826-3_red.f: In function 'pcapop': 19990826-3_red.f:12: error: invalid rtl sharing found in the insn (insn 44 43 45 2 (set (reg:SI 136) (mem/c/i:SI (plus:SI (reg/f:SI 113 sfp) (const_int 60 [0x3c])) [3 S4 A32])) 328 {*movsi_internal1} (expr_list:REG_EQUAL (fix:SI (reg:DF 134)) (nil))) 19990826-3_red.f:12: error: shared rtx (mem/c/i:SI (plus:SI (reg/f:SI 113 sfp) (const_int 60 [0x3c])) [3 S4 A32]) 19990826-3_red.f:12: internal compiler error: internal consistency failure Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. and -Os: 19990826-3_red.f: In function 'pcapop': 19990826-3_red.f:12: error: invalid rtl sharing found in the insn (insn 43 42 44 2 19990826-3_red.f:7 (set (reg:SI 136) (mem/c/i:SI (plus:SI (reg/f:SI 113 sfp) (const_int 60 [0x3c])) [3 S4 A32])) 328 {*movsi_internal1} (expr_list:REG_EQUAL (fix:SI (reg:DF 134)) (nil))) 19990826-3_red.f:12: error: shared rtx (mem/c/i:SI (plus:SI (reg/f:SI 113 sfp) (const_int 60 [0x3c])) [3 S4 A32]) 19990826-3_red.f:12: internal compiler error: internal consistency failure Please submit a full bug report, with preprocessed source if appropriate. but compiles at -O0 and -O3. Now the strange thing is that if I uncomment the line: ! P1=FLOAT(NB)/FLOAT(M1) it fails only at -O1 and -Os: [karma] f90/bug% gfc -c -O0 19990826-3_red.f [karma] f90/bug% gfc -c -Os 19990826-3_red.f 19990826-3_red.f: In function 'pcapop': 19990826-3_red.f:12: error: invalid rtl sharing found in the insn (insn 60 59 61 2 19990826-3_red.f:7 (set (reg:SI 156) (mem/c/i:SI (plus:SI (reg/f:SI 113 sfp) (const_int 76 [0x4c])) [3 S4 A32])) 328 {*movsi_internal1} (expr_list:REG_EQUAL (fix:SI (reg:DF 154)) (nil))) 19990826-3_red.f:12: error: shared rtx (mem/c/i:SI (plus:SI (reg/f:SI 113 sfp) (const_int 76 [0x4c])) [3 S4 A32]) 19990826-3_red.f:12: internal compiler error: internal consistency failure Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. [karma] f90/bug% gfc -c -O3 19990826-3_red.f [karma] f90/bug% gfc -c -O2 19990826-3_red.f [karma] f90/bug% gfc -c -O1 19990826-3_red.f 19990826-3_red.f: In function 'pcapop': 19990826-3_red.f:12: error: invalid rtl sharing found in the insn (insn 59 58 60 2 19990826-3_red.f:7 (set (reg:SI 156) (mem/c/i:SI (plus:SI (reg/f:SI 113 sfp) (const_int 76 [0x4c])) [0 S4 A32])) 328 {*movsi_internal1} (expr_list:REG_EQUAL (fix:SI (reg:DF 154)) (nil))) 19990826-3_red.f:12: error: shared rtx (mem/c/i:SI (plus:SI (reg/f:SI 113 sfp) (const_int 76 [0x4c])) [0 S4 A32]) 19990826-3_red.f:12: internal compiler error: internal consistency failure Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. I did not succeeded to further simplify the spaghetti code while keeping the failure(s).
The line SUBROUTINE PCAPOP() is not necessary to get the failure.
What happens in this testcase is (mis)behaviour of invariant code motion. On instruction: (set (mem/c/i:SI (plus:DI (reg/f:DI 113 sfp) (const_int 80 [0x50])) [3 S4 A32]) (fix:SI (reg:DF 135))) the invariant code is trying to replace the write->load pair, however the truncsfdf2 expander is expanding fix from reg to reg will offload the value to memory again, so we are replacing load by: (insn 44 0 45 (parallel [ (set (mem/c/i:SI (plus:DI (reg/f:DI 113 sfp) (const_int 84 [0x54])) [3 S4 A32]) (fix:SI (reg:DF 135))) (clobber (reg:DI 138)) ]) -1 (nil)) (insn 45 44 46 (set (reg:SI 137) (mem/c/i:SI (plus:DI (reg/f:DI 113 sfp) (const_int 84 [0x54])) [3 S4 A32])) -1 (expr_list:REG_EQUAL (fix:SI (reg:DF 135)) (nil))) (insn 46 45 0 (set (reg:SI 136) (reg:SI 137)) -1 (nil)) This is not very sane transformation at all IMO. Zdenek, perhaps we can disable the transform, when force_operand produces a memory load or some similar lame trick? Anyway, the sharing problem is cured by: Index: loop-invariant.c =================================================================== *** loop-invariant.c (revision 128492) --- loop-invariant.c (working copy) *************** move_invariant_reg (struct loop *loop, u *** 1243,1248 **** --- 1243,1249 ---- if (op != reg) emit_move_insn (reg, op); seq = get_insns (); + unshare_all_rtl_in_chain (seq); end_sequence (); if (!seq_insns_valid_p (seq)) I will commit as obvious if testing passes. Still I would hope we can also avoid loop from doing this transform at all. Honza
Subject: Re: [4.3 Regression] gfortran.dg/g77/19990826-3.f fails at -O1 > What happens in this testcase is (mis)behaviour of invariant code motion. > On instruction: > (set (mem/c/i:SI (plus:DI (reg/f:DI 113 sfp) > (const_int 80 [0x50])) [3 S4 A32]) > (fix:SI (reg:DF 135))) > > the invariant code is trying to replace the write->load pair, however the > truncsfdf2 expander is expanding fix from reg to reg will offload the value to > memory again, so we are replacing load by: > > (insn 44 0 45 (parallel [ > (set (mem/c/i:SI (plus:DI (reg/f:DI 113 sfp) > (const_int 84 [0x54])) [3 S4 A32]) > (fix:SI (reg:DF 135))) > (clobber (reg:DI 138)) > ]) -1 (nil)) > > (insn 45 44 46 (set (reg:SI 137) > (mem/c/i:SI (plus:DI (reg/f:DI 113 sfp) > (const_int 84 [0x54])) [3 S4 A32])) -1 (expr_list:REG_EQUAL > (fix:SI (reg:DF 135)) > (nil))) > > (insn 46 45 0 (set (reg:SI 136) > (reg:SI 137)) -1 (nil)) > > This is not very sane transformation at all IMO. Actually, it may make some sense -- the newly generated memory store & load are outside of the loop; so the code inside the loop is simplified, and in some cases we might even avoid memory accesses inside the loop. Nevertheless, force_operand in move_invariant_reg causes other problems as well, so I guess I will remove this code.
On powerpc-apple-darwin9, the patch Zdenek is checking in... http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01380.html suppresses the build problems in Java... http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33406 on powerpc-apple-darwin9. Zdenek thought your patch was the true fix to the Java build problem and its suppression with his patch was a side-effect. Honza, you might want to get you changes in before Zdenek checks in just in case it suppresses this PR as well (making it impossible to test).
To clarify, what I meant to say in the above comment was that I am concerned if Zdenek's patch may convert this PR into a latent bug.
Subject: Bug 33348 Author: hubicka Date: Mon Sep 17 15:12:10 2007 New Revision: 128547 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128547 Log: PR middle-end/33348 PR target/33406 * loop-invariant.c (move_invariant_reg): Unshare sequence. Modified: trunk/gcc/ChangeLog trunk/gcc/loop-invariant.c
Fixed