This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gcc const int expressions and negative constants


Geoff Keating wrote:-

> > That should read (const_int -1 [0xffffffff]) ?
> 
> Yes.  

Hi Geoff,

I've come back to looking at this problem again.  To recap, here's the
code:-

int main(void)
{
  unsigned char sign;
  unsigned char integer[2] = {255 };

  sign = integer[0];

  printf ( "sign == 255: %d\n", sign == 255);

  return 0;
}

You mentioned that the RTL for the "sign == 255" comparison should be
a QImode comparison comparing sign to -1.  I've stepped through the
RTL generation from tree exps (expand_expr -> emit_store_flag ->
emit_cmp_and_jump_insn etc.), and nowhere is the 255 changed from a
VOIDmode 255 to VOIDmode -1.  The comparison is done in unsigned
QImode, so this does not seem unreasonable.  Any more clues <g>?

The following 2 lines from emit_cmp_and_jump_insn_1 look like the
place where is might be supposed to happen.  As I'm not really sure
what I'm looking for, this is quite hard.

  x = prepare_operand (icode, x, 0, mode, wider_mode, unsignedp);
  y = prepare_operand (icode, y, 1, mode, wider_mode, unsignedp);

Neil.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]