This was fun to track down
Jim Wilson
wilson@cygnus.com
Wed Sep 24 12:58:00 GMT 1997
> 2. If convert_modes is really right, the proper fix to expand_divmod
> would be to avoid calling it when op1 is constant.
I don't think you can just avoid the call -- you can't just
operate on constants without any regard to their size.
Gcc has two different kinds of conversion routines.
There are routines that convert RTL to RTL, and which will never emit insns.
This includes gen_lowpart and operand_subword.
There are routines that emit the insns that are required if any to convert
one RTL to another RTL. This includes convert_modes.
These two different kinds of conversion routines are often confused.
The former is equivalent to converting a int to a float via a union, and
the later is equivalent to converting a int to a float via a cast.
I see no reason why expand_divmod needs to call convert_modes in this case.
If we are passed in a constant value, then we should keep the value as a
constant, so that we have a chance of emitting optimized code for the divide.
There is no need to emit insns to perform an actual conversion on the value.
All we need to do is convert the RTL itself, and I don't even think that is
necessary, since a CONST_INT is valid regardless of the mode.
Hence, it looks like expmed.c should be calling gen_lowpart (or something
similar) instead of convert_modes if op1 is a constant. This will give
better code than the current patch by retaining the constant.
Jim
More information about the Gcc
mailing list