From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 736 invoked by alias); 17 Dec 2007 08:38:24 -0000 Received: (qmail 666 invoked by uid 48); 17 Dec 2007 08:38:13 -0000 Date: Mon, 17 Dec 2007 08:38:00 -0000 Message-ID: <20071217083813.665.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug rtl-optimization/34503] Issues with constant/copy propagation implementation in gcse.c In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "steven at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-12/txt/msg01590.txt.bz2 ------- Comment #4 from steven at gcc dot gnu dot org 2007-12-17 08:38 ------- The global cprop pass prefers constants over copies. Thus, when a copy is found but a REG_EQUAL note for a constant is found on the same instruction, only the constant is recorded. This results in missed copy-propagation opportunities. A simple example probably shows best what I mean: a = ... if (...) { a = 5; b = a; (REG_EQUAL 5} } else { b = a; } c = b; GCC will record "b = 5" on one arm of the if-then-else, and "b = a" on the other. Because each expression kills the other, "b = a" is lost and GCC would fail to propagate "a" to give "c = a;". [ The above example may seem trivial and non-realistic -- but with CSE disabled, pre tree-ssa compilers actually do fail to optimize this! ] To fix this, constants and copies have to be tracked simultaneously. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34503