public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/91681] Missed optimization for 128 bit arithmetic operations Date: Mon, 25 Jul 2022 16:37:18 +0000 [thread overview] Message-ID: <bug-91681-4-dqIP1jNg92@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-91681-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91681 --- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>: https://gcc.gnu.org/g:16aafa3194d4851a07cc204f56a5f0618f77e5d7 commit r13-1826-g16aafa3194d4851a07cc204f56a5f0618f77e5d7 Author: Roger Sayle <roger@nextmovesoftware.com> Date: Mon Jul 25 17:33:48 2022 +0100 PR target/91681: zero_extendditi2 pattern for more optimizations on x86. Technically, PR target/91681 has already been resolved; we now recognize the highpart multiplication at the tree-level, we no longer use the stack, and we currently generate the same number of instructions as LLVM. However, it is still possible to do better, the current x86_64 code to generate a double word addition of a zero extended operand, looks like: xorl %r11d, %r11d addq %r10, %rax adcq %r11, %rdx when it's possible (as LLVM does) to use an immediate constant: addq %r10, %rax adcq $0, %rdx This is implemented by introducing a zero_extendditi2 pattern, for zero extension from DImode to TImode on TARGET_64BIT that is split after reload. With zero extension now visible to combine, we add two new define_insn_and_split that add/subtract a zero extended operand in double word mode. These apply to both 32-bit and 64-bit code generation, to produce adc $0 and sbb $0. One consequence of this is that these new patterns interfere with the optimization that recognizes DW:DI = (HI:SI<<32)+LO:SI as a pair of register moves, or more accurately the combine splitter no longer triggers as we're now converting two instructions into two instructions (not three instructions into two instructions). This is easily repaired (and extended to handle TImode) by changing from a pair of define_split (that handle operand commutativity) to a set of four define_insn_and_split (again to handle operand commutativity). 2022-07-25 Roger Sayle <roger@nextmovesoftware.com> Uroš Bizjak <ubizjak@gmail.com> gcc/ChangeLog PR target/91681 * config/i386/i386-expand.cc (split_double_concat): A new helper function for setting a double word value from two word values. * config/i386/i386-protos.h (split_double_concat): Prototype here. * config/i386/i386.md (zero_extendditi2): New define_insn_and_split. (*add<dwi>3_doubleword_zext): New define_insn_and_split. (*sub<dwi>3_doubleword_zext): New define_insn_and_split. (*concat<mode><dwi>3_1): New define_insn_and_split replacing previous define_split for implementing DST = (HI<<32)|LO as pair of move instructions, setting lopart and hipart. (*concat<mode><dwi>3_2): Likewise. (*concat<mode><dwi>3_3): Likewise, where HI is zero_extended. (*concat<mode><dwi>3_4): Likewise, where HI is zero_extended. gcc/testsuite/ChangeLog PR target/91681 * g++.target/i386/pr91681.C: New test case (from the PR). * gcc.target/i386/pr91681-1.c: New int128 test case. * gcc.target/i386/pr91681-2.c: Likewise. * gcc.target/i386/pr91681-3.c: Likewise, but for ia32.
next prev parent reply other threads:[~2022-07-25 16:37 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-91681-4@http.gcc.gnu.org/bugzilla/> 2021-12-27 7:29 ` pinskia at gcc dot gnu.org 2022-07-25 16:37 ` cvs-commit at gcc dot gnu.org [this message] 2023-07-07 20:00 ` roger at nextmovesoftware dot com 2023-07-12 13:14 ` cvs-commit at gcc dot gnu.org 2023-07-12 13:46 ` cvs-commit at gcc dot gnu.org 2024-01-21 23:31 ` roger at nextmovesoftware dot com
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-91681-4-dqIP1jNg92@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).