From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7179 invoked by alias); 3 May 2006 18:55:11 -0000 Received: (qmail 7087 invoked by uid 48); 3 May 2006 18:54:48 -0000 Date: Wed, 03 May 2006 18:55:00 -0000 Message-ID: <20060503185448.7086.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug tree-optimization/26944] [4.1/4.2 Regression] -ftree-ch generates worse code In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "dann at godzilla dot ics dot uci dot edu" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-05/txt/msg00300.txt.bz2 List-Id: ------- Comment #5 from dann at godzilla dot ics dot uci dot edu 2006-05-03 18:54 ------- IMO Comment #4 does not look close enough at what is actually happening. IMO tree-ch is the root cause here. The code looks like this before .ch Before .ch goto (); :; D.1301_54 = Int_Loc.0_4 * 200; D.1302_55 = (int[50] *) D.1301_54; D.1303_56 = Arr_2_Par_Ref_30 + D.1302_55; (*D.1303_56)[Int_Index_1] = Int_Loc_3; Int_Index_58 = Int_Index_1 + 1; # Int_Index_1 = PHI ; :; D.1305_26 = Int_Loc_3 + 1; if (Int_Index_1 <= D.1305_26) goto ; else goto ; :; after .ch it looks like this: D.1305_41 = Int_Loc_3 + 1; if (Int_Loc_3 <= D.1305_41) goto ; else goto ; <-- this just complicates the CFG. Look below to see what are the effects of doing this in later passes. Plus just look at the comparison ... # Int_Index_37 = PHI ; :; D.1301_54 = Int_Loc.0_4 * 200; D.1302_55 = (int[50] *) D.1301_54; D.1303_56 = Arr_2_Par_Ref_30 + D.1302_55; (*D.1303_56)[Int_Index_37] = Int_Loc_3; Int_Index_58 = Int_Index_37 + 1; D.1305_26 = Int_Loc_3 + 1; if (D.1305_26 >= Int_Index_58) goto ; else goto ; :; Given the above CFG, critical edge splitting transforms this into: D.1305_41 = Int_Loc_3 + 1; if (Int_Loc_3 <= D.1305_41) goto ; else goto ; :; goto (); :; # Int_Index_37 = PHI ; :; D.1301_54 = Int_Loc.0_4 * 200; D.1302_55 = (int[50] *) D.1301_54; D.1303_56 = Arr_2_Par_Ref_30 + D.1302_55; (*D.1303_56)[Int_Index_37] = Int_Loc_3; Int_Index_58 = Int_Index_37 + 1; if (D.1305_41 >= Int_Index_58) goto ; else goto ; :; goto (); :; :; Given the above CFG PRE will dutifully fill with code a lot of the empty basic blocks: after pre D.1305_41 = Int_Loc_3 + 1; if (Int_Loc_3 <= D.1305_41) goto ; else goto ; :; pretmp.34_45 = Int_Loc.0_4 * 200; pretmp.36_57 = (int[50] *) pretmp.34_45; pretmp.38_25 = Arr_2_Par_Ref_30 + pretmp.36_57; goto (); :; pretmp.30_26 = Int_Loc.0_4 * 200; pretmp.31_19 = (int[50] *) pretmp.30_26; pretmp.32_1 = pretmp.31_19 + Arr_2_Par_Ref_30; # Int_Index_37 = PHI ; :; D.1301_54 = pretmp.30_26; D.1302_55 = pretmp.31_19; D.1303_56 = pretmp.32_1; (*D.1303_56)[Int_Index_37] = Int_Loc_3; Int_Index_58 = Int_Index_37 + 1; if (D.1305_41 >= Int_Index_58) goto ; else goto ; :; goto (); :; # prephitmp.39_23 = PHI ; # prephitmp.37_53 = PHI ; # prephitmp.35_49 = PHI ; :; Now when using -fno-tree-ch before critical edge splitting the code looks like this: goto (); :; D.1301_54 = Int_Loc.0_4 * 200; D.1302_55 = (int[50] *) D.1301_54; D.1303_56 = Arr_2_Par_Ref_30 + D.1302_55; (*D.1303_56)[Int_Index_1] = Int_Loc_3; Int_Index_58 = Int_Index_1 + 1; # Int_Index_1 = PHI ; :; D.1305_26 = Int_Loc_3 + 1; if (Int_Index_1 <= D.1305_26) goto ; else goto ; :; after crited it looks like this: (i.e. no change) goto (); :; D.1301_54 = Int_Loc.0_4 * 200; D.1302_55 = (int[50] *) D.1301_54; D.1303_56 = Arr_2_Par_Ref_30 + D.1302_55; (*D.1303_56)[Int_Index_1] = Int_Loc_3; Int_Index_58 = Int_Index_1 + 1; # Int_Index_1 = PHI ; :; D.1305_26 = Int_Loc_3 + 1; if (Int_Index_1 <= D.1305_26) goto ; else goto ; :; and after PRE goto (); :; D.1301_54 = pretmp.31_49; D.1302_55 = pretmp.32_45; D.1303_56 = pretmp.33_41; (*D.1303_56)[Int_Index_1] = Int_Loc_3; Int_Index_58 = Int_Index_1 + 1; # Int_Index_1 = PHI ; :; D.1305_26 = pretmp.30_19; if (Int_Index_1 <= D.1305_26) goto ; else goto ; :; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26944