This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/41244] "&data[i] - data" isn't converted to "i"
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Sep 2009 14:12:37 -0000
- Subject: [Bug tree-optimization/41244] "&data[i] - data" isn't converted to "i"
- References: <bug-41244-14164@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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