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

ville.syrjala at linux.intel.com ville.syrjala at linux.intel.com
Fri Oct 16 02:44:05 PDT 2015


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>
---
 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



More information about the Intel-gfx mailing list