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

25 Apr
2005
25 Apr
'05
10:35 a.m.
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
7317
Age (days ago)
7317
Last active (days ago)
0 comments
1 participants
participants (1)
-
Fillod Stephane