GCC Bugzilla has been upgraded from version 4.4.9 to 5.0rc3. If you see any problem, please report it to bug 64968.
Bug 35542 - [4.3 Regression] fwprop only propagates one operand
Summary: [4.3 Regression] fwprop only propagates one operand
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.3.0
: P4 normal
Target Milestone: 4.3.2
Assignee: Paolo Bonzini
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2008-03-11 20:31 UTC by Andy Hutchinson
Modified: 2008-10-14 21:02 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.4.0 4.3.2
Known to fail: 4.3.0
Last reconfirmed: 2008-04-02 09:57:10


Attachments
Patch to search modified instruction for register. (364 bytes, patch)
2008-03-11 20:34 UTC, Andy Hutchinson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Hutchinson 2008-03-11 20:31:46 UTC
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.
Comment 1 Andy Hutchinson 2008-03-11 20:34:35 UTC
Created attachment 15300 [details]
Patch to search modified instruction for register.
Comment 2 Paolo Bonzini 2008-04-02 09:57:01 UTC
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

Comment 3 Paolo Bonzini 2008-04-02 09:57:10 UTC
committed to trunk, will backport to 4.3 in due time (causes regressions for AVR)
Comment 4 Eric Weddington 2008-04-02 15:21:36 UTC
(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!
Comment 5 Paolo Bonzini 2008-04-02 15:25:46 UTC
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.
Comment 6 Andy Hutchinson 2008-04-02 15:44:24 UTC
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.

Comment 7 Alexandre Oliva 2008-04-29 08:19:22 UTC
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

Comment 8 Paolo Bonzini 2008-08-01 09:54:21 UTC
backported
Comment 9 Paolo Bonzini 2008-08-01 09:55:25 UTC
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