tests/gem_pwrite_snooped: Fix #pragma GCC weirdness
PATCH 1/1 tests/gem_pwrite_snooped: Fix #pragma GCC weirdness
From: Ville Syrjälä <[email protected]>
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 <[email protected]>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92227
--- tests/gem_pwrite_snooped.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/gem_pwrite_snooped.c +2 -1
@@ -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++; }
Signature · 6 lines
2.4.9 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 38 lines · On Fri, Oct 16, 2015 at 12:44:05PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
gem_pwrite_snoopedwas broken when the #pragma GCC stuff was added in b04691b tests/gem_pwrite_snooped: disable const cast warningApparently 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 retqThis 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
Quoted 3 lines
Cc: Thomas Wood <[email protected]>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92227Signed-off-by Ville Syrjälä <[email protected]>
Bah, hangs head in shame. You'll see why.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx