This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: CSE bug when narrowing constants
On 11/29/08 14:45:49, Eric Botcazou wrote:
> > Agreed. The routine that creates the errant REG_EQUAL note is
> > lookup_as_function().
>
> Really? Doesn't it only retrieve a pre-existing REG_EQUAL note?
It retrieves an equivalent rtx constant, if it exists. Before the patch,
the constant that was returned is a word mode (DImode) constant
with the value 0x100000000 (33 bits), which won't fit into an SImode
value, and therefore isn't equivalent. The fix is to call gen_lowpart()
in the case where the word mode constant is narrowed to a smaller mode.
In the example, the lower 32 bits of the constant will be used,
which is 0, and is the correct equivalent constant. cse_insn() calls
lookup_as_function() ultimately through fold_rtx(), IIRC, and is the
routine that writes the REG_EQUAL note.