This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: optimization problem in flow



>From: Jeffrey A Law <law@cygnus.com>:
>  In message <200002232004.OAA20040@d0sgibnl1.fnal.gov>you write:
>  > I just ran into a problem with the gcc optimizer producing incorrect
>  > code.  This is with the cvs version of gcc (2.96 20000222 (experimental)),
>  > on an i686-pc-linux-gnu platform (RH 6.1).
>  >  ...
>  > So the store gets erroneously deleted in the second flow pass.
>  > I tried stepping through the code in flow.c to see what was going
>  > on.  What i found was that when propagate_block() calls mark_used_regs()
>  > for the `minus' insn, the stack slot -16(ebp) is not removed
>  > from mem_set_list.  To test whether this should happen,
>  > mark_used_regs() calls anti_dependence() with two identical
>  > arguments (the mem expression from the minus rtx).  The reason,
>  > in turn, that anti_dependence returns false is that the rtx has the
>  > unchanging flag set.
>Thanks for the great but report.  My first question is why is RTX_UNCHANGING_P
>set for the MEM.  That seems clearly wrong to me and is probably the real
>bug.
> [...]
>I think you should track down why RTX_UNCHANGING_P is set.

Thanks for the reply.

I looked to see where RTX_UNCHANGING_P gets turned on, and it is during the
regmove pass, where the sequence (from 09.combine)

(insn 25 20 27 (set (reg:SI 32)
        (const_int 32 [0x20])) 37 {*movsi_1} (nil)
    (expr_list:REG_EQUAL (const_int 32 [0x20])
        (nil)))

(note 27 25 29 "" NOTE_INSN_DELETED)

(insn 29 27 34 (parallel[ 
            (set (reg/v/u:SI 30)
                (minus:SI (reg:SI 32)
                    (reg/v:SI 26)))
            (clobber (reg:CC 17 flags))
        ] ) 198 {*subsi_1} (insn_list 25 (nil))
    (expr_list:REG_UNUSED (reg:CC 17 flags)
        (expr_list:REG_DEAD (reg:SI 32)
            (nil))))


is turned into (from 10.regmove):

(insn 25 20 27 (set (reg/v/u:SI 30)
        (const_int 32 [0x20])) 37 {*movsi_1} (nil)
    (expr_list:REG_EQUAL (const_int 32 [0x20])
        (nil)))

(note 27 25 29 "" NOTE_INSN_DELETED)

(insn 29 27 34 (parallel[ 
            (set (reg/v/u:SI 30)
                (minus:SI (reg/v/u:SI 30)
                    (reg/v:SI 26)))
            (clobber (reg:CC 17 flags))
        ] ) 198 {*subsi_1} (insn_list 25 (nil))
    (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))


As an experiment, i tried disallowing the replacement in regmove_optimize
if the destination had the unchanging flag set:

2000-02-27  scott snyder  <snyder@fnal.gov>

	* regmove.c (regmove_optimize): Don't do replacement if the
	destination is marked as unchanging.

--- regmove.c-orig	Sun Feb 27 19:36:34 2000
+++ regmove.c	Sun Feb 27 19:36:36 2000
@@ -1270,6 +1270,9 @@
 	      if (operands_match_p (src, dst))
 		continue;
 
+              if (RTX_UNCHANGING_P (dst))
+                continue;
+
 	      if (match.commutative[op_no] >= 0)
 		{
 		  rtx comm = recog_data.operand[match.commutative[op_no]];


With this change, the original problem i had is gone from the test case
i had.  I've also checked that there are no changes in the number
of testsuite failures.  I haven't been able to do further testing due
to other problems present in the head cvs version over the weekend...

thanks,
sss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]