arithmetic HI+PSI

Ian Lance Taylor iant@google.com
Sat Oct 15 03:32:00 GMT 2011


Aurelien Buhrig <aurelien.buhrig.gcc@gmail.com> writes:

> When I add a pointer (PSImode) with an int (HImode) (ex: sp-=cnt) ,
> gcc expands the signed int by zero_extend'ing  the int and then adding
> both PSI values (instead of sign extending).
> How should I fix this ?
> POINTERS_EXTEND_UNSIGNED is 0.
>
> And what is the difference between ptr_mode and Pmode ?

ptr_mode is the integer mode that corresponds to POINTER_SIZE.
POINTER_SIZE is the size of a pointer as stored in a register or in
memory.  Pmode is the mode to use for a pointer.  Pmode may be larger
than ptr_mode on unusual machines.

As far as I know the int will be converted to SIZE_TYPE before being
added to the pointer.  Converting a signed int to SIZE_TYPE should sign
extend if SIZE_TYPE is larger than int.  I don't know why you are not
seeing that.

Ian



More information about the Gcc-help mailing list