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

2015-10-16 Thread ville . syrjala
From: Ville Syrjälä 

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:
02f0 :
 2f0:   48 85 f6test   %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:
02f0 :
 2f0:   48 85 f6test   %rsi,%rsi
 2f3:   74 25   je 31a 
 2f5:   48 01 feadd%rdi,%rsi
 2f8:   80 3f ffcmpb   $0xff,(%rdi)
 2fb:   48 8d 57 01 lea0x1(%rdi),%rdx
 2ff:   74 11   je 312 
 301:   eb 1a   jmp31d 
 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   jne31d 
 312:   48 39 f2cmp%rsi,%rdx
 315:   48 89 d7mov%rdx,%rdi
 318:   75 ee   jne308 
 31a:   31 c0   xor%eax,%eax
 31c:   c3  retq
 31d:   48 89 f8mov%rdi,%rax
 320:   c3  retq

Cc: Thomas Wood 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92227
Signed-off-by: Ville Syrjälä 
---
 tests/gem_pwrite_snooped.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/gem_pwrite_snooped.c b/tests/gem_pwrite_snooped.c
index 5783e3b..61b5404 100644
--- a/tests/gem_pwrite_snooped.c
+++ b/tests/gem_pwrite_snooped.c
@@ -82,11 +82,12 @@ static void *memchr_inv(const void *s, int c, size_t n)
unsigned char uc = c;
 
while (n--) {
-   if (*us != uc)
+   if (*us != uc) {
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wcast-qual"
return (void *) us;
 #pragma GCC diagnostic pop
+   }
us++;
}
 
-- 
2.4.9

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


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

2015-10-16 Thread Chris Wilson
On Fri, Oct 16, 2015 at 12:44:05PM +0300, ville.syrj...@linux.intel.com wrote:
> From: Ville Syrjälä 
> 
> 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:
> 02f0 :
>  2f0:   48 85 f6test   %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:
> 02f0 :
>  2f0:   48 85 f6test   %rsi,%rsi
>  2f3:   74 25   je 31a 
>  2f5:   48 01 feadd%rdi,%rsi
>  2f8:   80 3f ffcmpb   $0xff,(%rdi)
>  2fb:   48 8d 57 01 lea0x1(%rdi),%rdx
>  2ff:   74 11   je 312 
>  301:   eb 1a   jmp31d 
>  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   jne31d 
>  312:   48 39 f2cmp%rsi,%rdx
>  315:   48 89 d7mov%rdx,%rdi
>  318:   75 ee   jne308 
>  31a:   31 c0   xor%eax,%eax
>  31c:   c3  retq
>  31d:   48 89 f8mov%rdi,%rax
>  320:   c3  retq
> 
> Cc: Thomas Wood 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92227
> Signed-off-by: Ville Syrjälä 

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

-- 
Chris Wilson, Intel Open Source Technology Centre
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx