This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, PR 40866] decrease the cost of an IV candidate by 1 when the IV is used in a test against zero


Hi,

> The patch below fixes PR 40866 : [4.3/4.4/4.5 Regression] No counter  
> reversal for simple loops anymore.
>
> Problem:
> The loop optimizer canonicalizes the loop to a downward counting loop  
> which may save one instruction if
> the bound test is against zero. However, ivopts do not know that  
> comparing with zero is more efficient
> than comparing with any other expressions and thus eliminate the  
> reversed IV based on the current cost
> model.
>
> Solution:
> In this patch, we changed the ivopts cost model to decrease the cost of  
> an IV candidate by 1 when the IV is
> a test against zero. This idea was initially proposed by Zdenek Dvorak  
> as shown in the comment #3 of the bug
> report.
>
> Bootstrapped and tested on x86-64-linux. OK for trunk?

OK.

Zdenek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]