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

2023-06-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41244 --- Comment #12 from Andrew Pinski --- So basically the biggest issue is we do the sign extend and then do the multiply in an unsigned type; this causes all negative values causing a wrapping which is not correct really but we don't know any bett

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

2023-06-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41244 Andrew Pinski changed: What|Removed |Added Status|ASSIGNED|NEW --- Comment #11 from Andrew Pinski

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

2023-06-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41244 --- Comment #10 from Andrew Pinski --- Created attachment 55303 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55303&action=edit Better patch This is a better patch, operand_equal_p already does the integer cst check too.

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

2023-06-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41244 --- Comment #9 from Andrew Pinski --- Created attachment 55302 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55302&action=edit Patch which I will be testing This extends the pattern that already handles `(t * 2) / 2) -> t`. The one thing

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

2023-06-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41244 --- Comment #8 from Andrew Pinski --- _14 = _13 * 32; _15 = (long int) _14; _2 = _15 /[ex] 32; I think this will work (simplify (exact_div (nop_convert (mult @0 INTEGER_CST@1)) INTEGER_CST@2) (if (!TYPE_UNSIGNED (@0) && wi::t

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

2021-10-09 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41244 Andrew Pinski changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned a

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

2021-09-14 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41244 --- Comment #6 from Andrew Pinski --- Here are some better testcases as the power of 2 case can be handled on the rtl level as it is just a shift. extern struct s{ int a, b, c, d, e, f, g, h; } data[]; int find(int i, int j) { struct s *a =

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

2017-07-01 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41244 --- Comment #5 from Marc Glisse --- If we write &data[i] - &data[0] instead of &data[i] - data, we hit the special case in fold_binary_loc /* Fold &a[i] - &a[j] to i-j. */ which leads to fold_addr_of_array_ref_difference.

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

2016-09-04 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41244 --- Comment #4 from Marc Glisse --- (In reply to Andrew Pinski from comment #3) > On the trunk (on aarch64) we get: Yes, on I32P64 platforms we still have a chance to prove that the multiplication doesn't overflow. > long int _4; > long int

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

2016-09-03 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41244 Andrew Pinski changed: What|Removed |Added Last reconfirmed|2009-09-03 14:12:37 |2016-9-3 --- Comment #3 from Andrew Pins

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

2009-09-03 Thread rguenth 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) { re

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

2009-09-03 Thread zsojka at seznam dot cz
--- Comment #1 from zsojka at seznam dot cz 2009-09-03 13:50 --- Created an attachment (id=18475) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18475&action=view) preprocessed source -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41244