public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] Compiler question: integer division?
@ 2005-04-22 16:54 Steven Scholz
  2005-04-22 17:10 ` Jerry Van Baren
  2005-04-25 15:13 ` [U-Boot-Users] " Sergei Sharonov
  0 siblings, 2 replies; 10+ messages in thread
From: Steven Scholz @ 2005-04-22 16:54 UTC (permalink / raw)
  To: u-boot

Hi there,

I just wondered if the code

	return (dtt_read(sensor, DTT_READ_TEMP) / 256);

would be result in a "shift by 8" or and interger division?

Thanks,

Steven

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [U-Boot-Users] Compiler question: integer division?
@ 2005-04-25  8:35 Fillod Stephane
  0 siblings, 0 replies; 10+ messages in thread
From: Fillod Stephane @ 2005-04-25  8:35 UTC (permalink / raw)
  To: u-boot

Steven Scholz wrote:
>How about
>
>	a = b / 5;
>  ?
>
>Will that result in
>
>	a = (b >> 2) - b;
>
>, i.e. still no division but only shift operations?

Short answer:

	${CROSS_COMPILE}gcc a.c -O2 -c -g -o a.o
	${CROSS_COMPILE}objdump -S a.o

In other words, YMMV (arch, flags, gcc version, etc.).
Some arch pipelines may be faster at division (with divisor on 8 bits),
than shift and subtract which must serialize.

Feel free to ask/contribute to the GCC project :-)

-- 
Stephane

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-04-25 15:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-22 16:54 [U-Boot-Users] Compiler question: integer division? Steven Scholz
2005-04-22 17:10 ` Jerry Van Baren
2005-04-22 17:17   ` Steven Scholz
2005-04-25  8:27     ` Steven Scholz
2005-04-25  9:04       ` AW: " Reinhard Meyer
2005-04-25  9:35       ` Wolfgang Denk
2005-04-25 10:30         ` Steven Scholz
2005-04-25 14:31       ` Udi Finkelstein
2005-04-25 15:13 ` [U-Boot-Users] " Sergei Sharonov
  -- strict thread matches above, loose matches on Subject: below --
2005-04-25  8:35 [U-Boot-Users] " Fillod Stephane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox