A question regarding -fwrapv flag

Revital1 Eres ERES@il.ibm.com
Tue Feb 26 11:11:00 GMT 2008


Hello,

I am running the attached testcase (inspired from vect/vect-reduc-3.c
testcase) with -O3 -fwrapv on powerpc64-linux with trunk 4.4.

Here is a snippet from the testcase:

...

  unsigned short ub[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
  unsigned short uc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
  unsigned short udiff;


  udiff = 0;
  for (i = 0; i < n; i++) {,
    udiff += (ub[i] - uc[i]);,
  }

 ...

It seems that the use of -fwrapv flag causes part of the variables to};
be converted to short and I do not understand why.

Snippet from the .gimple dump file:

  i.2 = i;
  D.1654 = ub[i.2];
  i.2 = i;
  D.1655 = uc[i.2];
  D.1656 = D.1654 - D.1655;
  D.1657 = (short int) D.1656;
  udiff.3 = (short int) udiff;
  D.1659 = D.1657 + udiff.3;
  udiff = (short unsigned int) D.1659;

Thanks,
Revital

(See attached file: test-2.c)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-2.c
Type: application/octet-stream
Size: 850 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20080226/ea91d935/attachment.obj>


More information about the Gcc mailing list