From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10774 invoked by alias); 17 Mar 2010 00:19:12 -0000 Received: (qmail 10711 invoked by uid 48); 17 Mar 2010 00:18:57 -0000 Date: Wed, 17 Mar 2010 00:19:00 -0000 Message-ID: <20100317001857.10710.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug tree-optimization/42906] [4.5 Regression] Empty loop not removed In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "changpeng dot fang at amd dot com" 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: 2010-03/txt/msg01538.txt.bz2 ------- Comment #17 from changpeng dot fang at amd dot com 2010-03-17 00:18 ------- (In reply to comment #8) > And > > int foo (int b, int j) > { > if (b) > { > int i; > for (i = 0; i<1000; ++i) > ; > j = b; > } > return j; > } > With "j=b", "b" is not folded as a phi argument: : # i_2 = PHI <0(3), i_6(4)> if (i_2 <= 999) goto ; else goto ; : j_7 = b_3(D); : # j_1 = PHI However, if "j=0", it is: : j_7 = 0; : # j_1 = PHI j_8 = j_1; return j_8; Then copy propagation will remove "j_7 = 0" (and thus ) because it has no user. So, one possible solution is "do not remove trival dead code" in copy_propagation pass. Any dce pass will remove such code. Of course, if we follow Steven's suggestion not use constants as phi arguments, "j_7=0" will not be removed by constant propagation, and we are all fine. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42906