[Intel-gfx] [PATCH i-g-t] tests/gem_pwrite_snooped: Fix #pragma GCC weirdness

Chris Wilson chris at chris-wilson.co.uk
Fri Oct 16 03:08:27 PDT 2015


On Fri, Oct 16, 2015 at 12:44:05PM +0300, ville.syrjala at linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> gem_pwrite_snooped was broken when the #pragma GCC stuff was added in
> b04691b tests/gem_pwrite_snooped: disable const cast warning
> 
> Apparently gcc treats '#pragma GCC' as a C statement. With the current
> code memchr_inv() pretty much disappears entirely because gcc thinks
> there's an unconditional return in the loop body. Or at least that's my
> assumption. Put braces around the if body to fix it.
> 
> This is the original asm:
> 00000000000002f0 <memchr_inv.isra.0>:
>  2f0:   48 85 f6                test   %rsi,%rsi
>  2f3:   b8 00 00 00 00          mov    $0x0,%eax
>  2f8:   48 0f 45 c7             cmovne %rdi,%rax
>  2fc:   c3                      retq
> 
> This is with the fix:
> 00000000000002f0 <memchr_inv.constprop.1>:
>  2f0:   48 85 f6                test   %rsi,%rsi
>  2f3:   74 25                   je     31a <memchr_inv.constprop.1+0x2a>
>  2f5:   48 01 fe                add    %rdi,%rsi
>  2f8:   80 3f ff                cmpb   $0xff,(%rdi)
>  2fb:   48 8d 57 01             lea    0x1(%rdi),%rdx
>  2ff:   74 11                   je     312 <memchr_inv.constprop.1+0x22>
>  301:   eb 1a                   jmp    31d <memchr_inv.constprop.1+0x2d>
>  303:   0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)
>  308:   48 83 c2 01             add    $0x1,%rdx
>  30c:   80 7a ff ff             cmpb   $0xff,-0x1(%rdx)
>  310:   75 0b                   jne    31d <memchr_inv.constprop.1+0x2d>
>  312:   48 39 f2                cmp    %rsi,%rdx
>  315:   48 89 d7                mov    %rdx,%rdi
>  318:   75 ee                   jne    308 <memchr_inv.constprop.1+0x18>
>  31a:   31 c0                   xor    %eax,%eax
>  31c:   c3                      retq
>  31d:   48 89 f8                mov    %rdi,%rax
>  320:   c3                      retq
> 
> Cc: Thomas Wood <thomas.wood at intel.com>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92227
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

Bah, hangs head in shame. You'll see why.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list