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]
Other format: [Raw text]

[Bug tree-optimization/41244] "&data[i] - data" isn't converted to "i"



------- Comment #2 from rguenth at gcc dot gnu dot org  2009-09-03 14:12 -------
Because the index arithmetic is done unsigned.

  return (int) ((unsigned int) i * 212) /[ex] 212;

We lost the information that i * 212 cannot overflow.

Simpler testcase:

extern int data[];

int find(int i)
{
  return &data[i] - data;
}

from which we enter c_fully_fold_internal with

((int) ((int *) &data + (unsigned int) ((unsigned int) i * 4)) - (int) &data)
/[ex] 4

addressed on the no-undefined-overflow branch.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |missed-optimization
   Last reconfirmed|0000-00-00 00:00:00         |2009-09-03 14:12:37
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41244


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