Re: [PATCH] common implementation of iterative div/mod

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Segher Boessenkool
Date: Thursday, May 8, 2008 - 1:52 pm

> We have a few instances of the open-coded iterative div/mod loop, used

It's not a "dummy" asm, it actually does something: it tells the
compiler that it has to iterate the loop exactly as written, and
not do something else.  I.e., exactly the behaviour we want here.


What a terrible function name.


...and now the "meat" of this function isn't inline anymore.  If we
cared about not doing a divide here, you'll have to explain why
taking this trivial loop out of line is a good idea.


You removed the unlikely() here.  Why?


You changed "+r" to "+rm" here.  Why?  Also, "rm" is an x86-ism,
and this is generic code (it does work here, but why is it better
than "r"?)


Does this need to be exported?


Can I suggest an alternative approach?  Define a macro (with a
good, descriptive name!) for just the asm("" : "+r"(x)), and use
that.  Much smaller patch, much clearer code, and doesn't result
in different (and worse) code generation, so it's a much safer
change.


Segher

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: undefined reference to __udivdi3 (gcc-4.3), Robert Hancock, (Sun May 4, 10:35 am)
Re: undefined reference to __udivdi3 (gcc-4.3), Segher Boessenkool, (Sun May 4, 3:19 pm)
Re: undefined reference to __udivdi3 (gcc-4.3), Jeremy Fitzhardinge, (Wed May 7, 2:29 am)
[PATCH] common implementation of iterative div/mod, Jeremy Fitzhardinge, (Thu May 8, 8:16 am)
Re: [PATCH] common implementation of iterative div/mod, Andrew Morton, (Thu May 8, 1:26 pm)
Re: [PATCH] common implementation of iterative div/mod, Segher Boessenkool, (Thu May 8, 1:52 pm)
Re: [PATCH] common implementation of iterative div/mod, Jeremy Fitzhardinge, (Thu May 8, 2:57 pm)
Re: [PATCH] common implementation of iterative div/mod, Jeremy Fitzhardinge, (Thu May 8, 3:00 pm)
Re: [PATCH] common implementation of iterative div/mod, Christian Kujau, (Fri May 9, 4:45 am)
Re: [PATCH] common implementation of iterative div/mod, Andrew Morton, (Tue May 13, 11:46 pm)
Re: [PATCH] common implementation of iterative div/mod, Jeremy Fitzhardinge, (Wed May 14, 12:33 am)
Re: [PATCH] common implementation of iterative div/mod, Jeremy Fitzhardinge, (Wed May 14, 2:55 am)
Re: [PATCH] common implementation of iterative div/mod, Jeremy Fitzhardinge, (Wed May 14, 3:52 am)
Re: [PATCH] common implementation of iterative div/mod, Jeremy Fitzhardinge, (Wed May 14, 5:58 am)