Hi, As per discussion in http://gcc.gnu.org/ml/gcc/2012-12/msg00056.html, the attached patch updates loop unroll passes to use new dump infrastructure.
This patch filters relevant dump messages into the following three categories - optimized: an optimization was successfully applied - missed: an optimization was missed due to the described reason - note: other relevant/detailed info during optimization. For example, loop unrolling computes the loop bounds and size. Two sample outputs from one of the gcc tests (gcc.dg/unroll_1.c) are below. Sample 1 -------------- info about optimized loops via "-fopt-info-loop-optimized" ------- $ gcc gcc.dg/unroll_1.c -fno-diagnostics-show-caret -O2 -S -fdump-rtl-loop2_unroll -funroll-loops -fopt-info-loop-optimized Unrolled loop 1 completely (duplicated 2 times). Exit condition of peeled iterations was eliminated. Last iteration exit edge was proved true. Unrolled loop 1 completely (duplicated 2 times). Exit condition of peeled iterations was eliminated. Last iteration exit edge was proved true. -------------------------------- Sample 2: --- All available loop optimization info, i.e., optimized+missed+note via "-fopt-info-loop" --- $ gcc gcc.dg/unroll_1.c -fno-diagnostics-show-caret -O2 -S -fdump-rtl-loop2_unroll -funroll-loops -fopt-info-loop Loop 1 iterates 2 times. Loop 1 iterates at most 2 times. Estimating sizes for loop 1 BB: 4, after_exit: 0 size: 2 if (i_1 <= 1) Exit condition will be eliminated in peeled copies. BB: 3, after_exit: 1 size: 1 _5 = b[i_1]; size: 1 _6 = _5 + 1; size: 1 a[i_1] = _6; size: 1 i_8 = i_1 + 1; Induction variable computation will be folded away. size: 6-3, last_iteration: 2-0 Loop size: 6 Estimated size after unrolling: 5 Unrolled loop 1 completely (duplicated 2 times). Exit condition of peeled iterations was eliminated. Last iteration exit edge was proved true. Forced exit to be taken: if (1 == 0) Loop 1 iterates 2 times. Loop 1 iterates at most 2 times. Estimating sizes for loop 1 BB: 4, after_exit: 0 size: 2 if (i_1 <= 1) Exit condition will be eliminated in peeled copies. BB: 3, after_exit: 1 size: 1 _4 = b[i_1]; size: 1 _5 = _4 + 1; size: 1 a[i_1] = _5; size: 1 i_7 = i_1 + 1; Induction variable computation will be folded away. size: 6-3, last_iteration: 2-0 Loop size: 6 Estimated size after unrolling: 5 Unrolled loop 1 completely (duplicated 2 times). Exit condition of peeled iterations was eliminated. Last iteration exit edge was proved true. Forced exit to be taken: if (1 == 0) -------------------------------- I would like to mention that this information is perhaps too verbose and the the source location of optimized loops is not displayed. I can add source line info (and fix up corresponding tests) if needed. But right now I wanted to maintain current dump format faithfully. Perhaps the format can be tweaked for better readability. Note that all information dumped in response to -fopt-info is also present in regular dump file(s) when corresponding dumps are enabled. Thus in above examples, the loop optimization info is also present in *.loop2_unroll dump file since the command line specified a dump file via "-fdump-rtl-loop2_unroll" in addition to -fopt-info. (As a side note, while doing the conversion, I found that the MSG_* dump flags are unwieldy when used in conjunction with other flags. Perhaps these flags should be renamed/shortened. I propose the following MSG_MISSED_OPTIMIZATION ==> MSG_MISSED MSG_OPTIMIZED_LOCATIONS ==> MSG_OPTIMIZED But that is pure renaming and can be done separately.) I have bootstrapped and tested this patch on x86_64 and found no new failures. Okay for trunk? Thanks, Sharad
unroll.opt_info.patch
Description: Binary data