fwprop.c currently has a bug where a successful propagation to one operand of an instruction will prevent propagation to any remaining operands. The cause is due to the use of loc_mentioned_in_p() to check that a reference, provided by earlier DF scan, still exist in an instruction. The test is intended to check that an earlier propagation and simplification has not removed D/U references. However, loc_mentioned_in_p(), compares addresses of rtx to determine equivalence. If an instruction has already been modified and simplified, this will longer apply - even if the def/use is still valid. This problem was already noted in Nov, but no bug report seems to have been filed. http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00170.html I will attach patch, that uses reg_mentioned_p() as a substitute. The only differences I noted where: a) reg_mentioned_p() does not match physical sub registers of longer hard registers. This seems to have no consequence since fwprop entirely rejects hard_registers in latter code. Perhaps for clarity, hard registers could be ignored earlier. b) registers in asm_operands are found. Which seems beneficial if they are pseudos and again ignored if they are hard registers. I am only able to test this with AVR port. In that it was 100% successful with no regressions of torture/execute testsuite.
Created attachment 15300 [details] Patch to search modified instruction for register.
Subject: Bug 35542 Author: bonzini Date: Wed Apr 2 09:56:17 2008 New Revision: 133829 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133829 Log: 2008-04-02 Andy Hutchinson <hutchinsonamdy@aim.com> PR rtl-optimization/35542 * fwprop.c (forward_propagate_and_simplify): Replace loc_reg_mentioned_in_p with reg_mentioned_p. Modified: trunk/gcc/ChangeLog trunk/gcc/fwprop.c
committed to trunk, will backport to 4.3 in due time (causes regressions for AVR)
(In reply to comment #3) > committed to trunk, will backport to 4.3 in due time (causes regressions for > AVR) > Could you list what fails? Thanks!
I meant that this is a patch that is scheduled for backporting to 4.3, because it fixes regressions on AVR. The text between parentheses should have been "bug causes regressions for AVR". Sorry.
Subject: Re: [4.3 Regression] fwprop only propagates one operand Eric, it's difficult to give you a specfic example as the propagation is very sensitive to generated code. I found this looking at other AVR bugs and discovered it was not working. (I'll look up that example latter for you). It not an obvious thing as other (good) changes due to DF merge, re-arrange code enough to obscure the omission. But the result is an extra move or redundant instruction here and there. (its also not at all specfic to AVR) Andy -----Original Message----- From: eric dot weddington at atmel dot com <gcc-bugzilla@gcc.gnu.org> To: hutchinsonandy@aim.com Sent: Wed, 2 Apr 2008 10:21 am Subject: [Bug rtl-optimization/35542] [4.3 Regression] fwprop only propagates one operand ------- Comment #4 from eric dot weddington at atmel dot com 2008-04-02 15:21 ------- (In reply to comment #3) > committed to trunk, will backport to 4.3 in due time (causes regressions for > AVR) > Could you list what fails? Thanks! -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35542 ------- You are receiving this mail because: ------- You reported the bug, or are watching the reporter.
Subject: Bug 35542 Author: aoliva Date: Tue Apr 29 08:18:36 2008 New Revision: 134782 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134782 Log: * fwprop.c (forward_propagate_and_simplify): Replace entire var location rtx. Revert part of 2007-11-08 obviated by: 2008-04-02 Andy Hutchinson <hutchinsonamdy@aim.com> PR rtl-optimization/35542 * fwprop.c (forward_propagate_and_simplify): Replace loc_reg_mentioned_in_p with reg_mentioned_p. Modified: branches/var-tracking-assignments-branch/gcc/ChangeLog.vta branches/var-tracking-assignments-branch/gcc/fwprop.c
backported
Subject: Bug 35542 Author: bonzini Date: Fri Aug 1 09:54:04 2008 New Revision: 138505 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=138505 Log: 2008-08-01 Paolo Bonzini <bonzini@gnu.org> Backport from mainline: 2008-04-02 Andy Hutchinson <hutchinsonamdy@aim.com> PR rtl-optimization/35542 * fwprop.c (forward_propagate_and_simplify): Replace loc_reg_mentioned_in_p with reg_mentioned_p. Modified: branches/gcc-4_3-branch/gcc/ChangeLog branches/gcc-4_3-branch/gcc/fwprop.c