public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/96305] not detecting widen multiple after a widen multiply with shift Date: Mon, 27 Sep 2021 07:39:58 +0000 [thread overview] Message-ID: <bug-96305-4-FSPYmZ9I2D@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-96305-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96305 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Unnecessary signed x |not detecting widen |unsigned multiplication |multiple after a widen |with squares of signed |multiply with shift |variables | Target|arm-*-* |arm-*-*, aarch64-*-* Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2021-09-27 Component|target |tree-optimization --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This is a gimple level issue really. We are able to figure out one widen multiple with shift but not the second one: _10 = a_2(D) w* a_2(D); _11 = _10 >> 32; _3 = (long long int) b_4(D); _6 = _3 * _11; _7 = _6 >> 32; _8 = (int) _7; You can also see the issue on aarch64 too. If we do this: inline int hmull(int a, int b) { return ((long long)a * b) >> 32; } int compute(int a, int b) { int t = hmull(a,a); asm("":"+r"(t)); return hmull(t, b); } ------- CUT ---- On aarch64 we get: smull x0, w0, w0 asr x2, x0, 32 smull x0, w1, w2 lsr x0, x0, 32 ret which is exactly what we want. And on arm we get: smull r3, r0, r0, r0 smull r1, r0, r1, r0 bx lr Gimple level: _11 = a_2(D) w* a_2(D); _12 = _11 >> 32; _13 = (int) _12; __asm__("" : "=r" t_4 : "0" _13); _7 = b_5(D) w* t_4; _8 = _7 >> 32; _9 = (int) _8; Notice w* there :). Note the inline-asm helps even clang too.
prev parent reply other threads:[~2021-09-27 7:39 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-24 3:22 [Bug c/96305] New: Unnecessary signed x unsigned multiplication with squares or signed variables petr at nejedli dot cz 2020-07-24 3:35 ` [Bug target/96305] " pinskia at gcc dot gnu.org 2020-07-24 8:46 ` [Bug target/96305] Unnecessary signed x unsigned multiplication with squares of " ktkachov at gcc dot gnu.org 2021-09-27 7:39 ` pinskia at gcc dot gnu.org [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-96305-4-FSPYmZ9I2D@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).