public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/108803] [10/11/12/13 Regression] wrong code for 128bit rotate on aarch64-unknown-linux-gnu with -Og Date: Thu, 16 Feb 2023 17:50:44 +0000 [thread overview] Message-ID: <bug-108803-4-dlNU5iUorH@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108803-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108803 --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- --- gcc/optabs.cc.jj 2023-01-02 09:32:53.309838465 +0100 +++ gcc/optabs.cc 2023-02-16 18:04:54.794871019 +0100 @@ -596,6 +596,16 @@ expand_doubleword_shift_condmove (scalar { rtx outof_superword, into_superword; + if (shift_mask < BITS_PER_WORD - 1) + { + rtx tmp = immed_wide_int_const (wi::shwi (BITS_PER_WORD - 1, + GET_MODE (superword_op1)), + GET_MODE (superword_op1)); + superword_op1 + = simplify_expand_binop (op1_mode, and_optab, superword_op1, tmp, + 0, true, methods); + } + /* Put the superword version of the output into OUTOF_SUPERWORD and INTO_SUPERWORD. */ outof_superword = outof_target != 0 ? gen_reg_rtx (word_mode) : 0; @@ -617,6 +627,16 @@ expand_doubleword_shift_condmove (scalar return false; } + if (shift_mask < BITS_PER_WORD - 1) + { + rtx tmp = immed_wide_int_const (wi::shwi (BITS_PER_WORD - 1, + GET_MODE (subword_op1)), + GET_MODE (subword_op1)); + subword_op1 + = simplify_expand_binop (op1_mode, and_optab, subword_op1, tmp, + 0, true, methods); + } + /* Put the subword version directly in OUTOF_TARGET and INTO_TARGET. */ if (!expand_subword_shift (op1_mode, binoptab, outof_input, into_input, subword_op1, indeed fixes the miscompilation, but unfortunately with e.g. __attribute__((noipa)) __int128 foo (__int128 a, unsigned k) { return a << k; } __attribute__((noipa)) __int128 bar (__int128 a, unsigned k) { return a >> k; } results in one extra insn in each of the functions. While the superword_op1 case is fine because aarch64 (among other arches) has a pattern to catch shift with masked count, in the subword_op1 case that doesn't work, because expand_subword_shift actually emits 3 shifts instead of just one, one with (BIT_PER_WORD - 1) - op1 as shift count and two with op1. If the op1 &= (BITS_PER_WORD - 1) masking is done in the caller, then it can't be easily merged with the shifts. We could do that also separately in expand_subword_shift under some new bool and in that case instead of using op1 &= (BITS_PER_WORD - 1); shift1 by ((BITS_PER_WORD - 1) - op1); shift2 by op1; shift3 by op1 use tmp = (63 - op1) & (BITS_PER_WORD - 1); shift1 by tmp; op1 &= (BITS_PER_WORD - 1); shift2 by op1; shift3 by op1, but that would be larger code if the target doesn't have those shift with masking patterns that trigger on it. Perhaps have some target hook? Or try to recog the combined instruction?
next prev parent reply other threads:[~2023-02-16 17:50 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-15 14:06 [Bug target/108803] New: " zsojka at seznam dot cz 2023-02-16 8:00 ` [Bug target/108803] " rguenth at gcc dot gnu.org 2023-02-16 16:34 ` jakub at gcc dot gnu.org 2023-02-16 17:50 ` jakub at gcc dot gnu.org [this message] 2023-02-16 17:50 ` jakub at gcc dot gnu.org 2023-02-16 18:00 ` jakub at gcc dot gnu.org 2023-02-16 18:14 ` jakub at gcc dot gnu.org 2023-02-16 18:44 ` jakub at gcc dot gnu.org 2023-02-16 19:59 ` jakub at gcc dot gnu.org 2023-02-27 19:24 ` jakub at gcc dot gnu.org 2023-07-07 10:44 ` [Bug target/108803] [11/12/13/14 " rguenth at gcc dot gnu.org 2024-02-21 6:24 ` pinskia at gcc dot gnu.org
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-108803-4-dlNU5iUorH@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).