From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1179 invoked by alias); 30 Jan 2010 12:01:55 -0000 Received: (qmail 32116 invoked by uid 48); 30 Jan 2010 12:01:37 -0000 Date: Sat, 30 Jan 2010 12:01:00 -0000 Message-ID: <20100130120137.32111.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug tree-optimization/42720] Problematic condition simplification logic at unswitch-loops pass In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rakdver 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: 2010-01/txt/msg03416.txt.bz2 ------- Comment #8 from rakdver at gcc dot gnu dot org 2010-01-30 12:01 ------- (In reply to comment #7) > Oh, and Zdenek might have an idea about the condition simplification in > unswitching. I agree that some of the checks in tree_unswitch_single_loop are badly placed -- it does not make sense to check them repeatedly in the recursion. I'd suggest to move them to tree_ssa_unswitch_loops, i.e., Index: tree-ssa-loop-unswitch.c =================================================================== *** tree-ssa-loop-unswitch.c (revision 155960) --- tree-ssa-loop-unswitch.c (working copy) *************** tree_ssa_unswitch_loops (void) *** 88,93 **** --- 88,113 ---- /* Go through inner loops (only original ones). */ FOR_EACH_LOOP (li, loop, LI_ONLY_INNERMOST) { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, ";; Considering loop %d\n", loop->num); + + /* Do not unswitch in cold regions. */ + if (optimize_loop_for_size_p (loop)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, ";; Not unswitching cold loops\n"); + continue; + } + + /* The loop should not be too large, to limit code growth. */ + if (tree_num_loop_insns (loop, &eni_size_weights) + > (unsigned) PARAM_VALUE (PARAM_MAX_UNSWITCH_INSNS)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, ";; Not unswitching, loop too big\n"); + continue; + } + changed |= tree_unswitch_single_loop (loop, 0); } *************** tree_unswitch_single_loop (struct loop * *** 189,219 **** return false; } - /* Only unswitch innermost loops. */ - if (loop->inner) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, ";; Not unswitching, not innermost loop\n"); - return false; - } - - /* Do not unswitch in cold regions. */ - if (optimize_loop_for_size_p (loop)) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, ";; Not unswitching cold loops\n"); - return false; - } - - /* The loop should not be too large, to limit code growth. */ - if (tree_num_loop_insns (loop, &eni_size_weights) - > (unsigned) PARAM_VALUE (PARAM_MAX_UNSWITCH_INSNS)) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, ";; Not unswitching, loop too big\n"); - return false; - } - i = 0; bbs = get_loop_body (loop); --- 209,214 ---- -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42720