public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "syq at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/111376] missed optimization of one bit test on MIPS32r1
Date: Wed, 05 Jun 2024 16:56:23 +0000	[thread overview]
Message-ID: <bug-111376-4-Hhw75ksXts@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111376-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111376

--- Comment #5 from YunQiang Su <syq at gcc dot gnu.org> ---
I copy the RTL pattern from RISC-V, and it seems work

```
--- a/gcc/config/mips/mips.md
+++ b/gcc/config/mips/mips.md
@@ -6253,6 +6253,40 @@ (define_insn "*branch_bit<bbv><mode>_inverted"
 }
   [(set_attr "type"         "branch")
    (set_attr "branch_likely" "no")])
+
+(define_insn_and_split "*branch_on_bit<mode>"
+  [(set (pc)
+       (if_then_else
+           (match_operator 0 "equality_operator"
+               [(zero_extract:GPR (match_operand:GPR 2 "register_operand" "d")
+                                (const_int 1)
+                                (match_operand:GPR 3 "const_int_operand"))
+                                (const_int 0)])
+           (label_ref (match_operand 1))
+           (pc)))]
+  "!ISA_HAS_BBIT && !ISA_HAS_EXT_INS && !TARGET_MIPS16"
+  "#"
+  "!reload_completed"
+  [(set (match_dup 4)
+       (ashift:GPR (match_dup 2) (match_dup 3)))
+   (set (pc)
+       (if_then_else
+           (match_op_dup 0 [(match_dup 4) (const_int 0)])
+           (label_ref (match_operand 1))
+           (pc)))]
+{
+  int shift = GET_MODE_BITSIZE (<MODE>mode) - 1 - INTVAL (operands[3]);
+  operands[3] = GEN_INT (shift);
+  operands[4] = gen_reg_rtx (<MODE>mode);
+
+  if (GET_CODE (operands[0]) == EQ)
+    operands[0] = gen_rtx_GE (<MODE>mode, operands[4], const0_rtx);
+  else
+    operands[0] = gen_rtx_LT (<MODE>mode, operands[4], const0_rtx);
+}
+[(set_attr "type" "branch")])
+
+
```

  parent reply	other threads:[~2024-06-05 16:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 18:24 [Bug rtl-optimization/111376] New: " lis8215 at gmail dot com
2024-06-04  6:55 ` [Bug target/111376] " syq at gcc dot gnu.org
2024-06-04  7:00 ` syq at gcc dot gnu.org
2024-06-04  7:06 ` lis8215 at gmail dot com
2024-06-05 11:02 ` syq at gcc dot gnu.org
2024-06-05 16:56 ` syq at gcc dot gnu.org [this message]
2024-06-06  9:45 ` lis8215 at gmail dot com
2024-06-06 22:16 ` syq at gcc dot gnu.org
2024-06-07  8:25 ` lis8215 at gmail dot com
2024-06-13  4:50 ` syq at gcc dot gnu.org
2024-06-15  3:22 ` syq at gcc dot gnu.org
2024-06-15  3:24 ` syq at gcc dot gnu.org
2024-06-15  5:24 ` lis8215 at gmail dot com
2024-06-15  6:47 ` syq at gcc dot gnu.org
2024-06-15  7:18 ` syq at gcc dot gnu.org
2024-06-15  8:13 ` lis8215 at gmail dot com
2024-06-15  8:35 ` lis8215 at gmail dot com
2024-06-18  8:06 ` syq at gcc dot gnu.org
2024-06-19 14:18 ` syq 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-111376-4-Hhw75ksXts@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: link
Be 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).