[U-Boot-Users] Compiler question: integer division?

Fillod Stephane stephane.fillod at thomson.net
Mon Apr 25 10:35:24 CEST 2005


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





More information about the U-Boot mailing list