Integer constant multiplication on Alpha
Falk Hueffner
falk.hueffner@student.uni-tuebingen.de
Thu Dec 20 07:58:00 GMT 2001
Hi,
I noticed gcc optimizes multiplications with integers quite good,
which is nice, but I have a few questions :)
* Where in the code does this happen? I looked quite hard, but
couldn't find it.
* Why isn't this disabled on -Os?
* The code seems slightly subobtimal sometimes:
int foo(int x) {
return 6*x;
}
yields
s4subq $16,$16,$0
addq $0,$0,$0
addl $0,$31,$0
ret $31,($26),1
with gcc 2.95.4 (Debian prerelease). What does that addl $0,$31,$0 do?
It looks like a sign extension, but the same could be achieved by just
using addl...
Also gcc 3.0 introduces a redundant mov:
mov $16,$1
s4subq $1,$1,$2
addq $2,$2,$1
addl $1,$31,$0
ret $31,($26),1
where could I look to check where this comes from?
Falk
More information about the Gcc
mailing list