option to control code straightening
Tim Prince
TimothyPrince@sbcglobal.net
Mon Jul 13 13:44:00 GMT 2009
Ian Lance Taylor wrote:
> Tim Prince <TimothyPrince@sbcglobal.net> writes:
>
>
>> Is there an option in gcc 4.4 or 4.5 to avoid code straightening in
>> loops with conditionals or select? Intel Core i7 Loop Stream Detector
>> seems to give up when the code path has more than minimum number of
>> branches.
>>
>
> Code straightening is normally a purely beneficial optimization. That
> said, gcc 4.5 is much better than 4.4 at avoiding having more than four
> jumps in a 16 byte span, which I think is what is required to avoid
> branch mispredictions on Intel/AMD processors.
>
> You may be able to avoid some code straightening using
> -fno-thread-jumps.
>
> If this does not help, then I recommend that you file a bug report with
> a standalone example showing a case where mainline gcc generates
> suboptimal code. See http://gcc.gnu.org/bugs.html . Thanks.
>
> Ian
>
This does make the difference for one of the cases I was looking at, a
switch where the same branch is taken repeatedly. I agree, the code
straightening is better consistently for the older Intel CPUs, where the
Loop Stream Detector isn't as effective.
Thanks.
More information about the Gcc-help
mailing list