]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
i386: Extend recognition of high-reg rvalues [PR121306]
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 5 Aug 2025 13:42:34 +0000 (14:42 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 5 Aug 2025 13:42:34 +0000 (14:42 +0100)
The i386 high-register patterns used things like:

    (match_operator:SWI248 2 "extract_operator"
      [(match_operand 0 "int248_register_operand" "Q")
       (const_int 8)
       (const_int 8)])

to match an extraction of a high register such as AH from AX/EAX/RAX.

This construct is used in contexts where only the low 8 bits of the
value matter.  This is either done explicitly using a (subreg:QI ... 0)
or implicitly by assigning to an 8-bit zero_extract destination.

extract_operator therefore matches both sign_extract and zero_extract,
since the signedness of the extension beyond 8 bits is irrelevant.

But the fact that only the low 8 bits of the value are significant
means that a shift right by 8 is as good as an extraction.  Shifts
right would already be used for things like:

  struct s {
    long a:8;
    long b:8;
    long c:48;
  };

  struct s f(struct s x, long y, long z) {
    x.b = (y & z) >> 8;
    return x;
  }

but are used more after g:965564eafb721f8000013a3112f1bba8d8fae32b.

This patch therefore replaces extract_operator with a new predicate
called extract_high_operator that matches both extractions and shifts.
The predicate checks the extraction field and shift amount itself,
so that patterns only need to match the first operand.

Splitters used match_op_dup to preserve the choice of extraction.
But the fact that the extractions (and now shifts) are equivalent
means that we can just as easily canonicalise on one of them.
(In theory, canonicalisation would also promote CSE, although
that's unlikely in practice.)  The patch goes for zero_extract,
for consistency with destinations.

gcc/
PR target/121306
* config/i386/predicates.md (extract_operator): Replace with...
(extract_high_operator): ...this new predicate.
* config/i386/i386.md (*cmpqi_ext<mode>_1, *cmpqi_ext<mode>_2)
(*cmpqi_ext<mode>_3, *cmpqi_ext<mode>_4, *movstrictqi_ext<mode>_1)
(*extzv<mode>, *insvqi_2, *extendqi<SWI24:mode>_ext_1)
(*addqi_ext<mode>_1_slp, *addqi_ext<mode>_1_slp, *addqi_ext<mode>_0)
(*addqi_ext2<mode>_0, *addqi_ext<mode>_1, *<insn>qi_ext<mode>_2)
(*subqi_ext<mode>_1_slp, *subqi_ext<mode>_2_slp, *subqi_ext<mode>_0)
(*subqi_ext2<mode>_0, *subqi_ext<mode>_1, *testqi_ext<mode>_1)
(*testqi_ext<mode>_2, *<code>qi_ext<mode>_1_slp)
(*<code>qi_ext<mode>_2_slp. *<code>qi_ext<mode>_0)
(*<code>qi_ext2<mode>_0, *<code>qi_ext<mode>_1)
(*<code>qi_ext<mode>_1_cc, *<code>qi_ext<mode>_1_cc)
(*<code>qi_ext<mode>_2, *<code>qi_ext<mode>_3, *negqi_ext<mode>_1)
(*one_cmplqi_ext<mode>_1, *ashlqi_ext<mode>_1, *<insn>qi_ext<mode>_1)
(define_peephole2): Replace uses of extract_operator with
extract_high_operator, matching only the first operand.
Use zero_extract rather than match_op_dup when splitting.

gcc/config/i386/i386.md
gcc/config/i386/predicates.md

index a9d1948e441091407c4c43e727632d7d3985e43e..2b0dd66c68b60d9cd32013a6150ce76e9a0a58c9 100644 (file)
        (compare
          (match_operand:QI 0 "nonimmediate_operand" "QBn")
          (subreg:QI
-           (match_operator:SWI248 2 "extract_operator"
-             [(match_operand 1 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)))]
+           (match_operator:SWI248 2 "extract_high_operator"
+             [(match_operand 1 "int248_register_operand" "Q")]) 0)))]
   "ix86_match_ccmode (insn, CCmode)"
   "cmp{b}\t{%h1, %0|%0, %h1}"
   [(set_attr "addr" "gpr8")
   [(set (reg FLAGS_REG)
        (compare
          (subreg:QI
-           (match_operator:SWI248 2 "extract_operator"
-             [(match_operand 0 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)
+           (match_operator:SWI248 2 "extract_high_operator"
+             [(match_operand 0 "int248_register_operand" "Q")]) 0)
          (match_operand:QI 1 "const0_operand")))]
   "ix86_match_ccmode (insn, CCNOmode)"
   "test{b}\t%h0, %h0"
   [(set (reg FLAGS_REG)
        (compare
          (subreg:QI
-           (match_operator:SWI248 2 "extract_operator"
-             [(match_operand 0 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)
+           (match_operator:SWI248 2 "extract_high_operator"
+             [(match_operand 0 "int248_register_operand" "Q")]) 0)
          (match_operand:QI 1 "general_operand" "QnBn")))]
   "ix86_match_ccmode (insn, CCmode)"
   "cmp{b}\t{%1, %h0|%h0, %1}"
   [(set (reg FLAGS_REG)
        (compare
          (subreg:QI
-           (match_operator:SWI248 2 "extract_operator"
-             [(match_operand 0 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)
+           (match_operator:SWI248 2 "extract_high_operator"
+             [(match_operand 0 "int248_register_operand" "Q")]) 0)
          (subreg:QI
-           (match_operator:SWI248 3 "extract_operator"
-             [(match_operand 1 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)))]
+           (match_operator:SWI248 3 "extract_high_operator"
+             [(match_operand 1 "int248_register_operand" "Q")]) 0)))]
   "ix86_match_ccmode (insn, CCmode)"
   "cmp{b}\t{%h1, %h0|%h0, %h1}"
   [(set_attr "type" "icmp")
   [(set (strict_low_part
          (match_operand:QI 0 "register_operand" "+Q"))
          (subreg:QI
-           (match_operator:SWI248 2 "extract_operator"
-             [(match_operand 1 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0))]
+           (match_operator:SWI248 2 "extract_high_operator"
+             [(match_operand 1 "int248_register_operand" "Q")]) 0))]
   "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
   "mov{b}\t{%h1, %0|%0, %h1}"
   [(set_attr "type" "imov")
 (define_insn "*extzvqi"
   [(set (match_operand:QI 0 "nonimmediate_operand" "=QBn,?R")
        (subreg:QI
-         (match_operator:SWI248 2 "extract_operator"
-           [(match_operand 1 "int248_register_operand" "Q,Q")
-            (const_int 8)
-            (const_int 8)]) 0))]
+         (match_operator:SWI248 2 "extract_high_operator"
+           [(match_operand 1 "int248_register_operand" "Q,Q")]) 0))]
   ""
 {
   switch (get_attr_type (insn))
          (match_operand 0 "int248_register_operand" "+Q")
          (const_int 8)
          (const_int 8))
-       (match_operator:SWI248 2 "extract_operator"
-         [(match_operand 1 "int248_register_operand" "Q")
-          (const_int 8)
-          (const_int 8)]))]
+       (match_operator:SWI248 2 "extract_high_operator"
+         [(match_operand 1 "int248_register_operand" "Q")]))]
   ""
   "mov{b}\t{%h1, %h0|%h0, %h1}"
   [(set_attr "type" "imov")
   [(set (match_operand:SWI24 0 "register_operand" "=R")
        (sign_extend:SWI24
          (subreg:QI
-           (match_operator:SWI248 2 "extract_operator"
-             [(match_operand 1 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)))]
+           (match_operator:SWI248 2 "extract_high_operator"
+             [(match_operand 1 "int248_register_operand" "Q")]) 0)))]
   ""
   "movs{b<SWI24:imodesuffix>|x}\t{%h1, %0|%0, %h1}"
    [(set_attr "type" "imovx")
   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+Q,&Q"))
        (plus:QI
          (subreg:QI
-           (match_operator:SWI248 3 "extract_operator"
-             [(match_operand 2 "int248_register_operand" "Q,Q")
-              (const_int 8)
-              (const_int 8)]) 0)
+           (match_operator:SWI248 3 "extract_high_operator"
+             [(match_operand 2 "int248_register_operand" "Q,Q")]) 0)
          (match_operand:QI 1 "nonimmediate_operand" "0,!qm")))
    (clobber (reg:CC FLAGS_REG))]
   "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
      [(set (strict_low_part (match_dup 0))
           (plus:QI
             (subreg:QI
-              (match_op_dup 3
-                [(match_dup 2) (const_int 8) (const_int 8)]) 0)
+              (zero_extract:SWI248
+                (match_dup 2) (const_int 8) (const_int 8)) 0)
             (match_dup 0)))
       (clobber (reg:CC FLAGS_REG))])]
   ""
   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+&Q"))
        (plus:QI
          (subreg:QI
-           (match_operator:SWI248 3 "extract_operator"
-             [(match_operand 1 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)
+           (match_operator:SWI248 3 "extract_high_operator"
+             [(match_operand 1 "int248_register_operand" "Q")]) 0)
          (subreg:QI
-           (match_operator:SWI248 4 "extract_operator"
-             [(match_operand 2 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)))
+           (match_operator:SWI248 4 "extract_high_operator"
+             [(match_operand 2 "int248_register_operand" "Q")]) 0)))
    (clobber (reg:CC FLAGS_REG))]
   "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
   "#"
   "&& reload_completed"
   [(set (strict_low_part (match_dup 0))
        (subreg:QI
-         (match_op_dup 4
-           [(match_dup 2) (const_int 8) (const_int 8)]) 0))
+         (zero_extract:SWI248
+           (match_dup 2) (const_int 8) (const_int 8)) 0))
    (parallel
      [(set (strict_low_part (match_dup 0))
           (plus:QI
             (subreg:QI
-              (match_op_dup 3
-                [(match_dup 1) (const_int 8) (const_int 8)]) 0)
+              (zero_extract:SWI248
+                (match_dup 1) (const_int 8) (const_int 8)) 0)
             (match_dup 0)))
       (clobber (reg:CC FLAGS_REG))])]
   ""
   [(set (match_operand:QI 0 "nonimmediate_operand" "=QBn")
        (plus:QI
          (subreg:QI
-           (match_operator:SWI248 3 "extract_operator"
-             [(match_operand 2 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)
+           (match_operator:SWI248 3 "extract_high_operator"
+             [(match_operand 2 "int248_register_operand" "Q")]) 0)
          (match_operand:QI 1 "nonimmediate_operand" "0")))
    (clobber (reg:CC FLAGS_REG))]
   ""
   [(set (match_operand:QI 0 "register_operand" "=&Q")
        (plus:QI
          (subreg:QI
-           (match_operator:SWI248 3 "extract_operator"
-             [(match_operand 1 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)
+           (match_operator:SWI248 3 "extract_high_operator"
+             [(match_operand 1 "int248_register_operand" "Q")]) 0)
          (subreg:QI
-           (match_operator:SWI248 4 "extract_operator"
-             [(match_operand 2 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)))
+           (match_operator:SWI248 4 "extract_high_operator"
+             [(match_operand 2 "int248_register_operand" "Q")]) 0)))
    (clobber (reg:CC FLAGS_REG))]
   ""
   "#"
   "&& reload_completed"
   [(set (match_dup 0)
        (subreg:QI
-         (match_op_dup 4
-           [(match_dup 2) (const_int 8) (const_int 8)]) 0))
+         (zero_extract:SWI248
+           (match_dup 2) (const_int 8) (const_int 8)) 0))
    (parallel
      [(set (match_dup 0)
           (plus:QI
             (subreg:QI
-              (match_op_dup 3
-                [(match_dup 1) (const_int 8) (const_int 8)]) 0)
+              (zero_extract:SWI248
+                (match_dup 1) (const_int 8) (const_int 8)) 0)
           (match_dup 0)))
       (clobber (reg:CC FLAGS_REG))])]
   ""
        (subreg:SWI248
          (plus:QI
            (subreg:QI
-             (match_operator:SWI248 3 "extract_operator"
-               [(match_operand 1 "int248_register_operand" "0,!Q")
-                (const_int 8)
-                (const_int 8)]) 0)
+             (match_operator:SWI248 3 "extract_high_operator"
+               [(match_operand 1 "int248_register_operand" "0,!Q")]) 0)
            (match_operand:QI 2 "general_operand" "QnBn,QnBn")) 0))
    (clobber (reg:CC FLAGS_REG))]
   ""
           (subreg:SWI248
             (plus:QI
               (subreg:QI
-                (match_op_dup 3
-                  [(match_dup 0) (const_int 8) (const_int 8)]) 0)
+                (zero_extract:SWI248
+                  (match_dup 0) (const_int 8) (const_int 8)) 0)
               (match_dup 2)) 0))
       (clobber (reg:CC FLAGS_REG))])]
   ""
        (subreg:SWI248
          (plusminus:QI
            (subreg:QI
-             (match_operator:SWI248 3 "extract_operator"
-               [(match_operand 1 "int248_register_operand" "<comm>0,!Q")
-                (const_int 8)
-                (const_int 8)]) 0)
+             (match_operator:SWI248 3 "extract_high_operator"
+               [(match_operand 1 "int248_register_operand" "<comm>0,!Q")]) 0)
            (subreg:QI
-             (match_operator:SWI248 4 "extract_operator"
-               [(match_operand 2 "int248_register_operand" "Q,Q")
-                (const_int 8)
-                (const_int 8)]) 0)) 0))
+             (match_operator:SWI248 4 "extract_high_operator"
+               [(match_operand 2 "int248_register_operand" "Q,Q")]) 0)) 0))
    (clobber (reg:CC FLAGS_REG))]
   ""
   "@
           (subreg:SWI248
             (plusminus:QI
               (subreg:QI
-                (match_op_dup 3
-                  [(match_dup 0) (const_int 8) (const_int 8)]) 0)
+                (zero_extract:SWI248
+                  (match_dup 0) (const_int 8) (const_int 8)) 0)
               (subreg:QI
-                (match_op_dup 4
-                  [(match_dup 2) (const_int 8) (const_int 8)]) 0)) 0))
+                (zero_extract:SWI248
+                  (match_dup 2) (const_int 8) (const_int 8)) 0)) 0))
       (clobber (reg:CC FLAGS_REG))])]
   ""
   [(set_attr "type" "alu")
        (minus:QI
          (match_operand:QI 1 "nonimmediate_operand" "0,!qm")
          (subreg:QI
-           (match_operator:SWI248 3 "extract_operator"
-             [(match_operand 2 "int248_register_operand" "Q,Q")
-              (const_int 8)
-              (const_int 8)]) 0)))
+           (match_operator:SWI248 3 "extract_high_operator"
+             [(match_operand 2 "int248_register_operand" "Q,Q")]) 0)))
    (clobber (reg:CC FLAGS_REG))]
   "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
   "@
           (minus:QI
             (match_dup 0)
             (subreg:QI
-              (match_op_dup 3
-                [(match_dup 2) (const_int 8) (const_int 8)]) 0)))
+              (zero_extract:SWI248
+                (match_dup 2) (const_int 8) (const_int 8)) 0)))
       (clobber (reg:CC FLAGS_REG))])]
   ""
   [(set_attr "type" "alu")
   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+&Q"))
        (minus:QI
          (subreg:QI
-           (match_operator:SWI248 3 "extract_operator"
-             [(match_operand 1 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)
+           (match_operator:SWI248 3 "extract_high_operator"
+             [(match_operand 1 "int248_register_operand" "Q")]) 0)
          (subreg:QI
-           (match_operator:SWI248 4 "extract_operator"
-             [(match_operand 2 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)))
+           (match_operator:SWI248 4 "extract_high_operator"
+             [(match_operand 2 "int248_register_operand" "Q")]) 0)))
    (clobber (reg:CC FLAGS_REG))]
   "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
   "#"
   "&& reload_completed"
   [(set (strict_low_part (match_dup 0))
        (subreg:QI
-         (match_op_dup 3
-           [(match_dup 1) (const_int 8) (const_int 8)]) 0))
+         (zero_extract:SWI248
+           (match_dup 1) (const_int 8) (const_int 8)) 0))
    (parallel
      [(set (strict_low_part (match_dup 0))
           (minus:QI
           (match_dup 0)
             (subreg:QI
-              (match_op_dup 4
-                [(match_dup 2) (const_int 8) (const_int 8)]) 0)))
+              (zero_extract:SWI248
+                (match_dup 2) (const_int 8) (const_int 8)) 0)))
       (clobber (reg:CC FLAGS_REG))])]
   ""
   [(set_attr "type" "alu")
        (minus:QI
          (match_operand:QI 1 "nonimmediate_operand" "0")
          (subreg:QI
-           (match_operator:SWI248 3 "extract_operator"
-             [(match_operand 2 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)))
+           (match_operator:SWI248 3 "extract_high_operator"
+             [(match_operand 2 "int248_register_operand" "Q")]) 0)))
    (clobber (reg:CC FLAGS_REG))]
   ""
   "sub{b}\t{%h2, %0|%0, %h2}"
   [(set (match_operand:QI 0 "register_operand" "=&Q")
        (minus:QI
          (subreg:QI
-           (match_operator:SWI248 3 "extract_operator"
-             [(match_operand 1 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)
+           (match_operator:SWI248 3 "extract_high_operator"
+             [(match_operand 1 "int248_register_operand" "Q")]) 0)
          (subreg:QI
-           (match_operator:SWI248 4 "extract_operator"
-             [(match_operand 2 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)))
+           (match_operator:SWI248 4 "extract_high_operator"
+             [(match_operand 2 "int248_register_operand" "Q")]) 0)))
    (clobber (reg:CC FLAGS_REG))]
   ""
   "#"
   "&& reload_completed"
   [(set (match_dup 0)
        (subreg:QI
-         (match_op_dup 3
-           [(match_dup 1) (const_int 8) (const_int 8)]) 0))
+         (zero_extract:SWI248
+           (match_dup 1) (const_int 8) (const_int 8)) 0))
    (parallel
      [(set (match_dup 0)
           (minus:QI
             (match_dup 0)
             (subreg:QI
-              (match_op_dup 4
-                [(match_dup 2) (const_int 8) (const_int 8)]) 0)))
+              (zero_extract:SWI248
+                (match_dup 2) (const_int 8) (const_int 8)) 0)))
       (clobber (reg:CC FLAGS_REG))])]
   ""
   [(set_attr "type" "alu")
        (subreg:SWI248
          (minus:QI
            (subreg:QI
-             (match_operator:SWI248 3 "extract_operator"
-               [(match_operand 1 "int248_register_operand" "0,!Q")
-                (const_int 8)
-                (const_int 8)]) 0)
+             (match_operator:SWI248 3 "extract_high_operator"
+               [(match_operand 1 "int248_register_operand" "0,!Q")]) 0)
            (match_operand:QI 2 "general_operand" "QnBn,QnBn")) 0))
    (clobber (reg:CC FLAGS_REG))]
   ""
           (subreg:SWI248
             (minus:QI
               (subreg:QI
-                (match_op_dup 3
-                  [(match_dup 0) (const_int 8) (const_int 8)]) 0)
+                (zero_extract:SWI248
+                  (match_dup 0) (const_int 8) (const_int 8)) 0)
               (match_dup 2)) 0))
       (clobber (reg:CC FLAGS_REG))])]
   ""
        (compare
          (and:QI
            (subreg:QI
-             (match_operator:SWI248 2 "extract_operator"
-               [(match_operand 0 "int248_register_operand" "Q")
-                (const_int 8)
-                (const_int 8)]) 0)
+             (match_operator:SWI248 2 "extract_high_operator"
+               [(match_operand 0 "int248_register_operand" "Q")]) 0)
            (match_operand:QI 1 "general_operand" "QnBn"))
          (const_int 0)))]
   "ix86_match_ccmode (insn, CCNOmode)"
        (compare
          (and:QI
            (subreg:QI
-             (match_operator:SWI248 2 "extract_operator"
-               [(match_operand 0 "int248_register_operand" "Q")
-                (const_int 8)
-                (const_int 8)]) 0)
+             (match_operator:SWI248 2 "extract_high_operator"
+               [(match_operand 0 "int248_register_operand" "Q")]) 0)
            (subreg:QI
-             (match_operator:SWI248 3 "extract_operator"
-               [(match_operand 1 "int248_register_operand" "Q")
-                (const_int 8)
-                (const_int 8)]) 0))
+             (match_operator:SWI248 3 "extract_high_operator"
+               [(match_operand 1 "int248_register_operand" "Q")]) 0))
          (const_int 0)))]
   "ix86_match_ccmode (insn, CCNOmode)"
   "test{b}\t{%h1, %h0|%h0, %h1}"
   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+Q,&Q"))
        (any_logic:QI
          (subreg:QI
-           (match_operator:SWI248 3 "extract_operator"
-             [(match_operand 2 "int248_register_operand" "Q,Q")
-              (const_int 8)
-              (const_int 8)]) 0)
+           (match_operator:SWI248 3 "extract_high_operator"
+             [(match_operand 2 "int248_register_operand" "Q,Q")]) 0)
          (match_operand:QI 1 "nonimmediate_operand" "0,!qm")))
    (clobber (reg:CC FLAGS_REG))]
   "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
      [(set (strict_low_part (match_dup 0))
           (any_logic:QI
             (subreg:QI
-              (match_op_dup 3
-                [(match_dup 2) (const_int 8) (const_int 8)]) 0)
+              (zero_extract:SWI248
+                (match_dup 2) (const_int 8) (const_int 8)) 0)
             (match_dup 0)))
       (clobber (reg:CC FLAGS_REG))])]
   ""
   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+&Q"))
        (any_logic:QI
          (subreg:QI
-           (match_operator:SWI248 3 "extract_operator"
-             [(match_operand 1 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)
+           (match_operator:SWI248 3 "extract_high_operator"
+             [(match_operand 1 "int248_register_operand" "Q")]) 0)
          (subreg:QI
-           (match_operator:SWI248 4 "extract_operator"
-             [(match_operand 2 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)))
+           (match_operator:SWI248 4 "extract_high_operator"
+             [(match_operand 2 "int248_register_operand" "Q")]) 0)))
    (clobber (reg:CC FLAGS_REG))]
   "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
   "#"
   "&& reload_completed"
   [(set (strict_low_part (match_dup 0))
        (subreg:QI
-         (match_op_dup 4
-           [(match_dup 2) (const_int 8) (const_int 8)]) 0))
+         (zero_extract:SWI248
+           (match_dup 2) (const_int 8) (const_int 8)) 0))
    (parallel
      [(set (strict_low_part (match_dup 0))
           (any_logic:QI
             (subreg:QI
-              (match_op_dup 3
-                [(match_dup 1) (const_int 8) (const_int 8)]) 0)
+              (zero_extract:SWI248
+                (match_dup 1) (const_int 8) (const_int 8)) 0)
             (match_dup 0)))
       (clobber (reg:CC FLAGS_REG))])]
   ""
   [(set (match_operand:QI 0 "nonimmediate_operand" "=QBn")
        (any_logic:QI
          (subreg:QI
-           (match_operator:SWI248 3 "extract_operator"
-             [(match_operand 2 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)
+           (match_operator:SWI248 3 "extract_high_operator"
+             [(match_operand 2 "int248_register_operand" "Q")]) 0)
          (match_operand:QI 1 "nonimmediate_operand" "0")))
    (clobber (reg:CC FLAGS_REG))]
   ""
   [(set (match_operand:QI 0 "register_operand" "=&Q")
        (any_logic:QI
          (subreg:QI
-           (match_operator:SWI248 3 "extract_operator"
-             [(match_operand 1 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)
+           (match_operator:SWI248 3 "extract_high_operator"
+             [(match_operand 1 "int248_register_operand" "Q")]) 0)
          (subreg:QI
-           (match_operator:SWI248 4 "extract_operator"
-             [(match_operand 2 "int248_register_operand" "Q")
-              (const_int 8)
-              (const_int 8)]) 0)))
+           (match_operator:SWI248 4 "extract_high_operator"
+             [(match_operand 2 "int248_register_operand" "Q")]) 0)))
    (clobber (reg:CC FLAGS_REG))]
   ""
   "#"
   "&& reload_completed"
   [(set (match_dup 0)
        (subreg:QI
-         (match_op_dup 4
-           [(match_dup 2) (const_int 8) (const_int 8)]) 0))
+         (zero_extract:SWI248
+           (match_dup 2) (const_int 8) (const_int 8)) 0))
    (parallel
      [(set (match_dup 0)
           (any_logic:QI
             (subreg:QI
-              (match_op_dup 3
-                [(match_dup 1) (const_int 8) (const_int 8)]) 0)
+              (zero_extract:SWI248
+                (match_dup 1) (const_int 8) (const_int 8)) 0)
           (match_dup 0)))
       (clobber (reg:CC FLAGS_REG))])]
   ""
        (subreg:SWI248
          (any_logic:QI
            (subreg:QI
-             (match_operator:SWI248 3 "extract_operator"
-               [(match_operand 1 "int248_register_operand" "0,!Q")
-                (const_int 8)
-                (const_int 8)]) 0)
+             (match_operator:SWI248 3 "extract_high_operator"
+               [(match_operand 1 "int248_register_operand" "0,!Q")]) 0)
            (match_operand:QI 2 "general_operand" "QnBn,QnBn")) 0))
    (clobber (reg:CC FLAGS_REG))]
   ""
           (subreg:SWI248
             (any_logic:QI
               (subreg:QI
-                (match_op_dup 3
-                  [(match_dup 0) (const_int 8) (const_int 8)]) 0)
+                (zero_extract:SWI248
+                  (match_dup 0) (const_int 8) (const_int 8)) 0)
               (match_dup 2)) 0))
       (clobber (reg:CC FLAGS_REG))])]
   ""
        (match_operator 5 "compare_operator"
          [(any_logic:QI
             (subreg:QI
-              (match_operator:SWI248 3 "extract_operator"
-                [(match_operand 1 "int248_register_operand" "0,!Q")
-                 (const_int 8)
-                 (const_int 8)]) 0)
+              (match_operator:SWI248 3 "extract_high_operator"
+                [(match_operand 1 "int248_register_operand" "0,!Q")]) 0)
             (match_operand:QI 2 "general_operand" "QnBn,QnBn"))
          (const_int 0)]))
    (set (zero_extract:SWI248
        (subreg:SWI248
          (any_logic:QI
            (subreg:QI
-             (match_op_dup 3
-               [(match_dup 0) (const_int 8) (const_int 8)]) 0)
+             (zero_extract:SWI248
+               (match_dup 0) (const_int 8) (const_int 8)) 0)
            (match_dup 2)) 0))]
   "ix86_match_ccmode (insn, CCNOmode)"
   "@
      [(set (match_dup 4)
           (match_op_dup 5
             [(any_logic:QI
-               (subreg:QI
-                 (match_op_dup 3
-                   [(match_dup 0) (const_int 8) (const_int 8)]) 0)
+               (subreg:QI
+                 (zero_extract:SWI248
+                   (match_dup 0) (const_int 8) (const_int 8)) 0)
                (match_dup 2))
              (const_int 0)]))
       (set (zero_extract:SWI248
           (subreg:SWI248
             (any_logic:QI
               (subreg:QI
-                (match_op_dup 3
-                  [(match_dup 1) (const_int 8) (const_int 8)]) 0)
+                (zero_extract:SWI248
+                  (match_dup 1) (const_int 8) (const_int 8)) 0)
               (match_dup 2)) 0))])]
   ""
   [(set_attr "addr" "gpr8")
        (subreg:SWI248
          (any_logic:QI
            (subreg:QI
-             (match_operator:SWI248 3 "extract_operator"
-               [(match_operand 1 "int248_register_operand" "%0,!Q")
-                (const_int 8)
-                (const_int 8)]) 0)
+             (match_operator:SWI248 3 "extract_high_operator"
+               [(match_operand 1 "int248_register_operand" "%0,!Q")]) 0)
            (subreg:QI
-             (match_operator:SWI248 4 "extract_operator"
-               [(match_operand 2 "int248_register_operand" "Q,Q")
-                (const_int 8)
-                (const_int 8)]) 0)) 0))
+             (match_operator:SWI248 4 "extract_high_operator"
+               [(match_operand 2 "int248_register_operand" "Q,Q")]) 0)) 0))
    (clobber (reg:CC FLAGS_REG))]
   ""
   "@
           (subreg:SWI248
             (any_logic:QI
               (subreg:QI
-                (match_op_dup 3
-                  [(match_dup 0) (const_int 8) (const_int 8)]) 0)
+                (zero_extract:SWI248
+                  (match_dup 0) (const_int 8) (const_int 8)) 0)
               (subreg:QI
-                (match_op_dup 4
-                  [(match_dup 2) (const_int 8) (const_int 8)]) 0)) 0))
+                (zero_extract:SWI248
+                  (match_dup 2) (const_int 8) (const_int 8)) 0)) 0))
       (clobber (reg:CC FLAGS_REG))])]
   ""
   [(set_attr "type" "alu")
          (match_operand 0 "int248_register_operand" "+Q,&Q")
          (const_int 8)
          (const_int 8))
-       (match_operator:SWI248 3 "extract_operator"
+       (match_operator:SWI248 3 "extract_high_operator"
          [(any_logic
             (match_operand 1 "int248_register_operand" "%0,!Q")
-            (match_operand 2 "int248_register_operand" "Q,Q"))
-          (const_int 8)
-          (const_int 8)]))
+            (match_operand 2 "int248_register_operand" "Q,Q"))]))
    (clobber (reg:CC FLAGS_REG))]
   "GET_MODE (operands[1]) == GET_MODE (operands[2])"
   "@
    (parallel
      [(set (zero_extract:SWI248
             (match_dup 0) (const_int 8) (const_int 8))
-          (match_op_dup 3
-            [(any_logic (match_dup 4) (match_dup 2))
-             (const_int 8) (const_int 8)]))
+          (zero_extract:SWI248
+            (any_logic (match_dup 4) (match_dup 2))
+            (const_int 8) (const_int 8)))
       (clobber (reg:CC FLAGS_REG))])]
   "operands[4] = gen_lowpart (GET_MODE (operands[1]), operands[0]);"
   [(set_attr "type" "alu")
        (subreg:SWI248
          (neg:QI
            (subreg:QI
-             (match_operator:SWI248 2 "extract_operator"
-               [(match_operand 1 "int248_register_operand" "0,!Q")
-                (const_int 8)
-                (const_int 8)]) 0)) 0))
+             (match_operator:SWI248 2 "extract_high_operator"
+               [(match_operand 1 "int248_register_operand" "0,!Q")]) 0)) 0))
    (clobber (reg:CC FLAGS_REG))]
   ""
   "@
           (subreg:SWI248
             (neg:QI
               (subreg:QI
-                (match_op_dup 2
-                  [(match_dup 0) (const_int 8) (const_int 8)]) 0)) 0))
+                (zero_extract:SWI248
+                  (match_dup 0) (const_int 8) (const_int 8)) 0)) 0))
       (clobber (reg:CC FLAGS_REG))])]
   ""
   [(set_attr "type" "negnot")
          (const_int 8)
          (const_int 8))
        (not:SWI248
-         (match_operator:SWI248 2 "extract_operator"
-           [(match_operand 1 "int248_register_operand" "0,!Q")
-         (const_int 8)
-         (const_int 8)])))]
+         (match_operator:SWI248 2 "extract_high_operator"
+           [(match_operand 1 "int248_register_operand" "0,!Q")])))]
   ""
   "@
    not{b}\t%h0
    (set (zero_extract:SWI248
          (match_dup 0) (const_int 8) (const_int 8))
        (not:SWI248
-         (match_op_dup 2 [(match_dup 0) (const_int 8) (const_int 8)])))]
+         (zero_extract:SWI248 (match_dup 0) (const_int 8) (const_int 8))))]
   ""
   [(set_attr "type" "negnot")
    (set_attr "mode" "QI")])
        (subreg:SWI248
          (ashift:QI
            (subreg:QI
-             (match_operator:SWI248 3 "extract_operator"
-               [(match_operand 1 "int248_register_operand" "0,!Q")
-                (const_int 8)
-                (const_int 8)]) 0)
+             (match_operator:SWI248 3 "extract_high_operator"
+               [(match_operand 1 "int248_register_operand" "0,!Q")]) 0)
            (match_operand:QI 2 "nonmemory_operand" "cI,cI")) 0))
    (clobber (reg:CC FLAGS_REG))]
   ""
           (subreg:SWI248
             (ashift:QI
               (subreg:QI
-                (match_op_dup 3
-                  [(match_dup 0) (const_int 8) (const_int 8)]) 0)
+                (zero_extract:SWI248
+                  (match_dup 0) (const_int 8) (const_int 8)) 0)
               (match_dup 2)) 0))
       (clobber (reg:CC FLAGS_REG))])]
   ""
        (subreg:SWI248
          (any_shiftrt:QI
            (subreg:QI
-             (match_operator:SWI248 3 "extract_operator"
-               [(match_operand 1 "int248_register_operand" "0,!Q")
-                (const_int 8)
-                (const_int 8)]) 0)
+             (match_operator:SWI248 3 "extract_high_operator"
+               [(match_operand 1 "int248_register_operand" "0,!Q")]) 0)
            (match_operand:QI 2 "nonmemory_operand" "cI,cI")) 0))
    (clobber (reg:CC FLAGS_REG))]
   ""
           (subreg:SWI248
             (any_shiftrt:QI
               (subreg:QI
-                (match_op_dup 3
-                  [(match_dup 0) (const_int 8) (const_int 8)]) 0)
+                (zero_extract:SWI248
+                  (match_dup 0) (const_int 8) (const_int 8)) 0)
               (match_dup 2)) 0))
       (clobber (reg:CC FLAGS_REG))])]
   ""
        (match_operator 1 "compare_operator"
          [(and:QI
             (subreg:QI
-              (match_operator:SWI248 4 "extract_operator"
-                [(match_operand 2 "int248_register_operand")
-                 (const_int 8)
-                 (const_int 8)]) 0)
+              (match_operator:SWI248 4 "extract_high_operator"
+                [(match_operand 2 "int248_register_operand")]) 0)
             (match_operand 3 "const_int_operand"))
           (const_int 0)]))]
   "! TARGET_PARTIAL_REG_STALL
           (match_op_dup 1
             [(and:QI
                (subreg:QI
-                 (match_op_dup 4 [(match_dup 2)
-                                  (const_int 8)
-                                  (const_int 8)]) 0)
+                 (zero_extract:SWI248 (match_dup 2)
+                                      (const_int 8)
+                                      (const_int 8)) 0)
                (match_dup 3))
              (const_int 0)]))
       (set (zero_extract:SWI248 (match_dup 2)
           (subreg:SWI248
             (and:QI
               (subreg:QI
-                (match_op_dup 4 [(match_dup 2)
-                                 (const_int 8)
-                                 (const_int 8)]) 0)
+                (zero_extract:SWI248 (match_dup 2)
+                                     (const_int 8)
+                                     (const_int 8)) 0)
               (match_dup 3)) 0))])])
 
 ;; Don't do logical operations with memory inputs.
index b2d2eecc64f62e8f979fa366f478a2f9efb585cc..0f310902e7b410edf9f5773dd61952cb9928f23f 100644 (file)
 (define_predicate "compare_operator"
   (match_code "compare"))
 
-(define_predicate "extract_operator"
-  (match_code "zero_extract,sign_extract"))
+(define_predicate "extract_high_operator"
+  (match_code "zero_extract,sign_extract,ashiftrt,lshiftrt")
+{
+  return (const8_operand (XEXP (op, 1), VOIDmode)
+         && (BINARY_P (op) || const8_operand (XEXP (op, 2), VOIDmode)));
+})
 
 ;; Return true if OP is a memory operand, aligned to
 ;; less than its natural alignment.