[Bug tree-optimization/113105] Missing optimzation: fold `div(v, a) * b + rem(v, a)` to `div(v, a) * (b - a) + v`

2024-05-29 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113105 --- Comment #6 from Andrew Pinski --- *** Bug 115287 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/113105] Missing optimzation: fold `div(v, a) * b + rem(v, a)` to `div(v, a) * (b - a) + v`

2023-12-23 Thread xxs_chy at outlook dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113105 --- Comment #5 from XChy --- (In reply to Jakub Jelinek from comment #4) > So, e.g. on x86_64, > unsigned int > f1 (unsigned val) > { > return val / 10 * 16 + val % 10; > } > > unsigned int > f2 (unsigned val) > { > return val / 10 * 6 +

[Bug tree-optimization/113105] Missing optimzation: fold `div(v, a) * b + rem(v, a)` to `div(v, a) * (b - a) + v`

2023-12-21 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113105 --- Comment #4 from Jakub Jelinek --- So, e.g. on x86_64, unsigned int f1 (unsigned val) { return val / 10 * 16 + val % 10; } unsigned int f2 (unsigned val) { return val / 10 * 6 + val; } unsigned int f3 (unsigned val, unsigned a,

[Bug tree-optimization/113105] Missing optimzation: fold `div(v, a) * b + rem(v, a)` to `div(v, a) * (b - a) + v`

2023-12-21 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113105 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment

[Bug tree-optimization/113105] Missing optimzation: fold `div(v, a) * b + rem(v, a)` to `div(v, a) * (b - a) + v`

2023-12-21 Thread xxs_chy at outlook dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113105 --- Comment #2 from XChy --- (In reply to Jakub Jelinek from comment #1) > When it is signed v / a * b + v % a, I think it can introduce UB which > wasn't there originally. > E.g. for v = 0, a = INT_MIN and b = 3. So, if it isn't done just for

[Bug tree-optimization/113105] Missing optimzation: fold `div(v, a) * b + rem(v, a)` to `div(v, a) * (b - a) + v`

2023-12-21 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113105 --- Comment #1 from Jakub Jelinek --- When it is signed v / a * b + v % a, I think it can introduce UB which wasn't there originally. E.g. for v = 0, a = INT_MIN and b = 3. So, if it isn't done just for unsigned types, parts of it need to be

[Bug tree-optimization/113105] Missing optimzation: fold `div(v, a) * b + rem(v, a)` to `div(v, a) * (b - a) + v`

2023-12-21 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113105 Andrew Pinski changed: What|Removed |Added Keywords||missed-optimization