[Info-vax] Anyone still around ? :-)
osuvman50 at gmail.com
osuvman50 at gmail.com
Thu Oct 10 00:33:42 EDT 2019
On Wednesday, October 9, 2019 at 6:41:25 PM UTC-4, hb wrote:
> What kind of optimization do you expect?
>
> #define CARDS_IN_DECK 52
> extern int permutation, choice;
> void foo (int i) {
> choice = permutation % (CARDS_IN_DECK-i);
> permutation = permutation / (CARDS_IN_DECK-i);
> }
> $
> $ gcc -m64 -S -O3 foo.c
>...
My observed lack of optimization was with the HP/VSI C compilers, not gcc. I'd
expect it, at minimum, to recognize the common division operation and do one
rather than two. The gcc result is what I'd expect for architectures with
integer divide, which Alpha and IA-64 don't have. FWIW, CARDS_IN_DECK was 12, so
the range of the permutation variable fits within an int.
DECC doesn't inline the div function, so using it is a negative improvement.
More information about the Info-vax
mailing list