Re: const_int * (int / const_int) by shift adds?

Robert.Harley@inria.fr (Robert Harley)
23 Nov 1997 19:41:25 -0500

          From comp.compilers

Related articles
const_int * (int / const_int) by shift adds? cef@geodesic.com (Charles Fiterman) (1997-11-20)
Re: const_int * (int / const_int) by shift adds? Robert.Harley@inria.fr (1997-11-23)
| List of all articles for this month |

From: Robert.Harley@inria.fr (Robert Harley)
Newsgroups: comp.compilers
Date: 23 Nov 1997 19:41:25 -0500
Organization: I.N.R.I.A Rocquencourt
Keywords: optimize, GCC

Charles Fiterman <cef@geodesic.com> writes:
>I need pointers to super compiler info. A super compiler is a
>compiler that produces truly optimal code for very simple constructs
>like 5 * (i / 5).


Ummm, have you tried gcc? It often produces good code for this kind
of thing, thanks to Torbjo"rn Granlund and Peter Montgomery, IIRC.
On Alpha Linux:


------------------------------------------------------------------------------
corton.inria.fr-tmp/1143 > cat > test.c
unsigned bla(unsigned x) { return x/5U*5U; }
corton.inria.fr-tmp/1144 > gcc -O4 test.c -o test.s -S
corton.inria.fr-tmp/1145 > cat test.s
[...]
                s4subq $16,$16,$0
                s4addq $0,$16,$0
                s4subq $0,$16,$0
                sll $0,8,$1
                addq $0,$1,$0
                sll $0,16,$1
                addq $0,$1,$0
                s4addq $0,$16,$0
                srl $0,34,$0
                s4addl $0,$0,$0
[...]
------------------------------------------------------------------------------


Bye,
    Rob.
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.