This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix the LOOP_BRANCH prediction
Thanks, Honza,
Then shall I check in the following patch to trunk (after testing)?
Dehao
Index: gcc/testsuite/gcc.dg/predict-7.c
===================================================================
--- gcc/testsuite/gcc.dg/predict-7.c (revision 0)
+++ gcc/testsuite/gcc.dg/predict-7.c (revision 0)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-profile_estimate" } */
+
+extern int global;
+
+int bar (int);
+
+void foo (int base)
+{
+ int i;
+ while (global < 10)
+ for (i = base; i < 10; i++)
+ bar (i);
+}
+
+/* { dg-final { scan-tree-dump-times "loop branch heuristics" 0
"profile_estimate"} } */
+/* { dg-final { cleanup-tree-dump "profile_estimate" } } */
Index: gcc/predict.c
===================================================================
--- gcc/predict.c (revision 189835)
+++ gcc/predict.c (working copy)
@@ -2177,7 +2177,7 @@
{
unsigned nb_loops;
- loop_optimizer_init (0);
+ loop_optimizer_init (LOOPS_NORMAL);
if (dump_file && (dump_flags & TDF_DETAILS))
flow_loops_dump (dump_file, NULL, 0);
On Tue, Jul 31, 2012 at 8:43 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> On Tue, Jul 31, 2012 at 6:56 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> >> >
>> >> > Yeah, this may also work. The reason it is not done is that
>> >> > 1) it seemed expensive to force CFG changes just to compute profile decade ago
>> >> > 2) cfgcleanup afterwards will anyway remove the headers again.
>> >> > So I originally hoped to do the right thing without normalization.
>> >>
>> >> Ok ... then you should pass AVOID_CFG_MODIFICATIONS instead. And be
>> >> prepared for odd situations like this ;)
>> >
>> > Well, I guess we could do the extra work to avoid strange side cases like this.
>> > Does normalization fix the testcase, too?
>>
>> Normalization indeed fixed this issue too. So what shall we do about
>> this patch? Shall we simply change to use normalization instead?
>
> Yes, I think it is not _that_ expensive and we do some relatively tricky CFG
> analysis there these days that should also get bit better.
> (the code was written at a time CFG was new citizen to GCC and changes in CFG
> was hard and considered harmful :)
>
> Honza
>>
>> Thanks,
>> Dehao
>>
>> >
>> > Honza
>> >>
>> >> > Honza