public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug tree-optimization/94782] New: Simple multiplication-related arithmetic not optimized to direct multiplication @ 2020-04-27 2:08 gabravier at gmail dot com 2020-04-27 7:07 ` [Bug tree-optimization/94782] " rguenth at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: gabravier at gmail dot com @ 2020-04-27 2:08 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94782 Bug ID: 94782 Summary: Simple multiplication-related arithmetic not optimized to direct multiplication Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: gabravier at gmail dot com Target Milestone: --- int f(int a, int b) { return (int)((a - 1U) * b) + b; } Can be optimized to `a * b`. LLVM does this transformation, GCC does not. Comparison here : https://godbolt.org/z/LFJwFJ ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/94782] Simple multiplication-related arithmetic not optimized to direct multiplication 2020-04-27 2:08 [Bug tree-optimization/94782] New: Simple multiplication-related arithmetic not optimized to direct multiplication gabravier at gmail dot com @ 2020-04-27 7:07 ` rguenth at gcc dot gnu.org 2023-02-17 18:16 ` gabravier at gmail dot com ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: rguenth at gcc dot gnu.org @ 2020-04-27 7:07 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94782 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed| |2020-04-27 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Since the inner (a - 1U) * b is unsigned but a * b would be signed due to undefined signed overflow we cannot optimize to that. But we could indeed. optimize to (unsigned)a * (unsigned)b. fold-const.c contains related transforms that could be amended. reassoc could as well but would need enhancement for signed arithmetic. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/94782] Simple multiplication-related arithmetic not optimized to direct multiplication 2020-04-27 2:08 [Bug tree-optimization/94782] New: Simple multiplication-related arithmetic not optimized to direct multiplication gabravier at gmail dot com 2020-04-27 7:07 ` [Bug tree-optimization/94782] " rguenth at gcc dot gnu.org @ 2023-02-17 18:16 ` gabravier at gmail dot com 2023-02-17 18:24 ` pinskia at gcc dot gnu.org 2023-02-17 18:28 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: gabravier at gmail dot com @ 2023-02-17 18:16 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94782 --- Comment #2 from Gabriel Ravier <gabravier at gmail dot com> --- Appears to be fixed on trunk. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/94782] Simple multiplication-related arithmetic not optimized to direct multiplication 2020-04-27 2:08 [Bug tree-optimization/94782] New: Simple multiplication-related arithmetic not optimized to direct multiplication gabravier at gmail dot com 2020-04-27 7:07 ` [Bug tree-optimization/94782] " rguenth at gcc dot gnu.org 2023-02-17 18:16 ` gabravier at gmail dot com @ 2023-02-17 18:24 ` pinskia at gcc dot gnu.org 2023-02-17 18:28 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-02-17 18:24 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94782 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |TREE --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- It is fixed on the RTL level but not the gimple level. Combine does it for x86_64: Trying 7, 8 -> 9: 7: {r91:SI=r93:SI-0x1;clobber flags:CC;} REG_DEAD r93:SI REG_UNUSED flags:CC 8: {r92:SI=r91:SI*r94:SI;clobber flags:CC;} REG_UNUSED flags:CC REG_DEAD r91:SI 9: r90:SI=r92:SI+r94:SI REG_DEAD r94:SI REG_DEAD r92:SI Successfully matched this instruction: (set (reg:SI 90) (mult:SI (reg:SI 93) (reg:SI 94))) allowing combination of insns 7, 8 and 9 original costs 4 + 12 + 4 = 20 replacement cost 12 But it fails to do it on aarch64: Trying 7 -> 14: 7: r101:SI=r103:SI-0x1 REG_DEAD r103:SI 14: x0:SI=r101:SI*r104:SI+r104:SI REG_DEAD r101:SI REG_DEAD r104:SI ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/94782] Simple multiplication-related arithmetic not optimized to direct multiplication 2020-04-27 2:08 [Bug tree-optimization/94782] New: Simple multiplication-related arithmetic not optimized to direct multiplication gabravier at gmail dot com ` (2 preceding siblings ...) 2023-02-17 18:24 ` pinskia at gcc dot gnu.org @ 2023-02-17 18:28 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-02-17 18:28 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94782 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- The RTL level for x86_64 was fixed with r11-6456-g4615cde5d7ef281d4b554df411f82ad707f0a54d (aka PR 98334). ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-02-17 18:28 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-04-27 2:08 [Bug tree-optimization/94782] New: Simple multiplication-related arithmetic not optimized to direct multiplication gabravier at gmail dot com 2020-04-27 7:07 ` [Bug tree-optimization/94782] " rguenth at gcc dot gnu.org 2023-02-17 18:16 ` gabravier at gmail dot com 2023-02-17 18:24 ` pinskia at gcc dot gnu.org 2023-02-17 18:28 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).