lkml.org 
[lkml]   [2016]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] x86: Optimize TIF checking in __switch_to_xtra.
On Fri, 9 Dec 2016, Thomas Gleixner wrote:
> On Tue, 6 Dec 2016, Kyle Huey wrote:
> > I propose the following patch, which results in GCC generating this code:
> >
> > mov (%rsi),%rax
> > xor (%rdi),%rax
> > mov %rdi,%rbx
> > mov %rsi,%r12
> > test $0x2000000,%eax
> > mov %rax,%rdx
> > jne 3f
> > 1: test $0x10000,%edx
> > je 2f
> > /* do some more work */
> > 2: /* the rest of the function */
> > ret
> > 3: /* do work */
> > mov (%r12),%rdx
> > xor (%rbx),%rdx
> > jmp 1b
> >
> > When we are not doing the work controlled by these flags this is significantly
> > better. We only have to load the flags from memory once, and we do a single
> > XOR that we can test multiple times instead of repeatedly isolating bits.
>
> You rely on the compiler doing the right thing. And it's non obvious from
> the code that this gets optimized as above.

On i386 this creates worse code due to register pressure it seems.

\
 
 \ /
  Last update: 2016-12-09 17:28    [W:0.080 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site