Re: [PATCH 0/24] make atomic_read() behave consistently across all architectures

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Denys Vlasenko
Date: Friday, August 24, 2007 - 5:19 am

On Saturday 18 August 2007 05:13, Linus Torvalds wrote:

It doesn't mean that (volatile int*) cast is bad, it means that current gcc
is bad (or "not good enough"). IOW: instead of avoiding volatile cast,
it's better to fix the compiler.


Linus, in all honesty gcc has many more cases of suboptimal code,
case of "volatile" is just one of many.

Off the top of my head:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28417

unsigned v;
void f(unsigned A) { v = ((unsigned long long)A) * 365384439 >> (27+32); }

gcc-4.1.1 -S -Os -fomit-frame-pointer t.c

f:
        movl    $365384439, %eax
        mull    4(%esp)
        movl    %edx, %eax <===== ?
        shrl    $27, %eax
        movl    %eax, v
        ret

Why is it moving %edx to %eax?

gcc-4.2.1 -S -Os -fomit-frame-pointer t.c

f:
        movl    $365384439, %eax
        mull    4(%esp)
        movl    %edx, %eax <===== ?
        xorl    %edx, %edx <===== ??!
        shrl    $27, %eax
        movl    %eax, v
        ret

Progress... Now we also zero out %edx afterwards for no apparent reason.
--
vda
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Christoph Lameter, (Tue Aug 14, 4:14 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 11:31 am)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Paul E. McKenney, (Wed Aug 15, 11:57 am)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 1:47 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 1:52 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 2:05 pm)
[No subject], Satyam Sharma, (Wed Aug 15, 5:36 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 6:23 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 6:26 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 6:30 pm)
Re: , Segher Boessenkool, (Wed Aug 15, 6:38 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Thu Aug 16, 12:32 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Thu Aug 16, 12:33 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Paul E. McKenney, (Thu Aug 16, 10:18 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Geert Uytterhoeven, (Thu Aug 16, 11:42 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Fri Aug 17, 10:37 am)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Fri Aug 17, 3:29 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Fri Aug 17, 3:49 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Fri Aug 17, 4:55 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Christoph Lameter, (Fri Aug 17, 6:24 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Mon Aug 20, 3:04 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Mon Aug 20, 4:02 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Tue Aug 21, 7:39 am)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Tue Aug 21, 7:48 am)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Denys Vlasenko, (Fri Aug 24, 5:19 am)
Re: [PATCH] i386: Fix a couple busy loops in mach_wakecpu. ..., Christoph Lameter, (Fri Aug 24, 10:06 am)