]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
i386: Generalize x >> 32-y to x >> -y conversion with multiples of 32
authorUros Bizjak <ubizjak@gmail.com>
Mon, 25 Nov 2024 19:04:38 +0000 (20:04 +0100)
committerUros Bizjak <ubizjak@gmail.com>
Mon, 25 Nov 2024 19:07:06 +0000 (20:07 +0100)
Optimize also cases where immediate value is a multiple of 32 for 32-bit
shifts (or multiple of 64 for 64-bit shifts).

gcc/ChangeLog:

* config/i386/i386.md (*ashl<mode>3_negcnt):
For SImode shifts allow multiples of 32 (or multiples
of 64 for DImode shifts) for immediate operand 3.
(*ashl<mode>3_negcnt_1): Ditto.
(*<insn><mode>3_negcnt): Ditto.
(*<insn><mode>3_negcnt_1): Ditto.

gcc/config/i386/i386.md

index 399a6a81f9ca812043fef2d635311f2c10776754..df78e4df9d8231081c988dc66a3d4199e4f5f9e1 100644 (file)
              (match_operand 2 "int248_register_operand" "c,r")) 0)))
    (clobber (reg:CC FLAGS_REG))]
   "ix86_binary_operator_ok (ASHIFT, <MODE>mode, operands)
-   && INTVAL (operands[3]) == <MODE_SIZE> * BITS_PER_UNIT
+   && (INTVAL (operands[3]) & (<MODE_SIZE> * BITS_PER_UNIT - 1)) == 0
    && ix86_pre_reload_split ()"
   "#"
   "&& 1"
            (match_operand:QI 2 "register_operand" "c,r"))))
    (clobber (reg:CC FLAGS_REG))]
   "ix86_binary_operator_ok (ASHIFT, <MODE>mode, operands)
-   && INTVAL (operands[3]) == <MODE_SIZE> * BITS_PER_UNIT
+   && (INTVAL (operands[3]) & (<MODE_SIZE> * BITS_PER_UNIT - 1)) == 0
    && ix86_pre_reload_split ()"
   "#"
   "&& 1"
              (match_operand 2 "int248_register_operand" "c,r")) 0)))
    (clobber (reg:CC FLAGS_REG))]
   "ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)
-   && INTVAL (operands[3]) == <MODE_SIZE> * BITS_PER_UNIT
+   && (INTVAL (operands[3]) & (<MODE_SIZE> * BITS_PER_UNIT - 1)) == 0
    && ix86_pre_reload_split ()"
   "#"
   "&& 1"
            (match_operand:QI 2 "register_operand" "c,r"))))
    (clobber (reg:CC FLAGS_REG))]
   "ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)
-   && INTVAL (operands[3]) == <MODE_SIZE> * BITS_PER_UNIT
+   && (INTVAL (operands[3]) & (<MODE_SIZE> * BITS_PER_UNIT - 1)) == 0
    && ix86_pre_reload_split ()"
   "#"
   "&& 1"