This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Modes on CONST_INTs
Bernd Schmidt <bernds@redhat.com> writes:
> It seems that every now and then, we run into bugs involving a lack of mode
> information on CONST_INTs. So far everyone I've asked has agreed that we
> really should have a mode for constants, but no one ever bothered because the
> change is going to be huge.
>
> Even if the change is going to be huge, I don't see how it can be any more
> painful than the recurring problems we have because of the lack of mode
> information. So, I'm looking for viable ways to gradually transform the
> compiler towards using modes on constants.
>
> Here's what I have in mind so far:
> 1. Create a new macro GENMINT (MODE, INTVAL). This macro will at first
> ignore the MODE argument.
> Replace all uses of GEN_INT with GENMINT. Once done, remove the old
> GEN_INT and rename GENMINT to GEN_INT. (I'm open to suggestions for
> a better name than GENMINT, but it should have 7 characters to avoid
> reformatting madness).
This sounds like a good idea. We too often end up in places in the
compiler where we know we need to do PLUS on (const_int A) and
(const_int B) but have somehow lost the mode we need to do it in.
Don't forget you also need to put modes on CONST_DOUBLEs.
I believe that most uses of GEN_INT in the middle-end are actually
wrong, and should be using immed_double_const anyway.
> 2. In a similar way, replace uses of const0_rtx etc. with CONST0_RTX(MODE).
> We'll also need a few new macros, e.g. CONSTM1_RTX(MODE) etc.
>
> Then we'll probably have to fix some code that recognizes constants by
> the fact that their mode is VOIDmode and other problems likely to show up.
There's much code that distinguishes an integer CONST_DOUBLE from a FP
CONST_DOUBLE by looking to see whether it's VOIDmode; each instance is
easily fixed, but there are lots of them.
> I haven't quite figured out yet what mode should be used for variable shift
> counts.
Presumably the same mode that would be used if the shift count was a
register.
--
- Geoffrey Keating <geoffk@geoffk.org>