public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "luoxhu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/102239] powerpc suboptimal boolean test of contiguous bits
Date: Wed, 01 Dec 2021 07:46:45 +0000	[thread overview]
Message-ID: <bug-102239-4-WSbQCGZrxd@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102239-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #11 from luoxhu at gcc dot gnu.org ---


+(define_insn_and_split "*anddi3_insn_dot"
+ [(set (pc)
+    (if_then_else (eq (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
+                             (match_operand:DI 2 "const_int_operand" "n,n"))
+                     (const_int 0))
+                 (label_ref (match_operand 3 ""))
+                 (pc)))
+  (clobber (match_scratch:DI 0 "=r,r"))]
+  "rs6000_is_valid_2insn_and (operands[2], DImode)
+   && !(rs6000_is_valid_and_mask (operands[2], DImode)
+       || logical_const_operand (operands[2], DImode))"
+  "#"
+  "&& reload_completed"
+  [(pc)]
+{
+   int nb, ne;
+   if (rs6000_is_valid_mask (operands[2], &nb, &ne, DImode) && nb >= ne)
+     {
+       unsigned HOST_WIDE_INT val = INTVAL (operands[2]);
+       int shift = 63 - nb;
+       rtx tmp = gen_rtx_ASHIFT (DImode, operands[1], GEN_INT (shift));
+       tmp = gen_rtx_AND (DImode, tmp, GEN_INT (val << shift));
+       rtx cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
+       rs6000_emit_dot_insn (operands[0], tmp, 1, cr0);
+       rtx loc_ref = gen_rtx_LABEL_REF (VOIDmode, operands[3]);
+       rtx cond = gen_rtx_EQ (CCEQmode, cr0, const0_rtx);
+       rtx ite = gen_rtx_IF_THEN_ELSE (VOIDmode, cond, loc_ref, pc_rtx);
+       emit_jump_insn (gen_rtx_SET (pc_rtx, ite));
+       DONE;
+     }
+   else
+     FAIL;
+}
+  [(set_attr "type" "shift")
+   (set_attr "dot" "yes")
+   (set_attr "length" "8,12")])
+


This pattern could combine the two instructions from

     9: {r123:CC=cmp(r124:DI&0x600000000,0);clobber scratch;}
           REG_DEAD r124:DI
     10: pc={(r123:CC==0)?L15:pc}
          REG_DEAD r123:CC

to:

     10: {pc={(r124:DI&0x600000000==0)?L15:pc};clobber scratch;}

then split2 will split it to one rotate dot instruction, is this OK?


(insn 32 9 33 2 (parallel [
            (set (reg:CC 100 0)
                (compare:CC (and:DI (ashift:DI (reg:DI 3 3 [124])
                            (const_int 29 [0x1d]))
                        (const_int -4611686018427387904 [0xc000000000000000]))
                    (const_int 0 [0])))
            (clobber (reg:DI 3 3 [125]))
        ]) "pr102239.c":4:6 239 {*rotldi3_mask_dot}
     (nil))
(jump_insn 33 32 11 2 (set (pc)
        (if_then_else (eq:CCEQ (reg:CC 100 0)
                (const_int 0 [0]))
            (label_ref 15)
            (pc))) "pr102239.c":4:6 869 {*cbranch}
     (int_list:REG_BR_PROB 536870916 (nil))
 -> 15)

  parent reply	other threads:[~2021-12-01  7:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08 11:55 [Bug c/102239] New: " npiggin at gmail dot com
2021-09-09 19:40 ` [Bug target/102239] " segher at gcc dot gnu.org
2021-11-24  7:17 ` luoxhu at gcc dot gnu.org
2021-11-24 23:22 ` segher at gcc dot gnu.org
2021-11-26  8:50 ` luoxhu at gcc dot gnu.org
2021-11-26 15:53 ` segher at gcc dot gnu.org
2021-11-29  3:31 ` luoxhu at gcc dot gnu.org
2021-11-29  6:36 ` luoxhu at gcc dot gnu.org
2021-11-29 10:05 ` segher at gcc dot gnu.org
2021-11-30  5:28 ` luoxhu at gcc dot gnu.org
2021-11-30 22:59 ` segher at gcc dot gnu.org
2021-12-01  7:46 ` luoxhu at gcc dot gnu.org [this message]
2022-01-11  9:23 ` cvs-commit at gcc dot gnu.org
2022-01-12  0:27 ` luoxhu 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-102239-4-WSbQCGZrxd@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).