]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Improve preservation of FLAGS_REG mode in i386.md's peephole2s.
authorRoger Sayle <roger@nextmovesoftware.com>
Sat, 9 Jul 2022 08:07:18 +0000 (09:07 +0100)
committerRoger Sayle <roger@nextmovesoftware.com>
Sat, 9 Jul 2022 08:07:18 +0000 (09:07 +0100)
The patch tweaks several peephole2s in i386.md that propagate the flags
register, but take its mode from the SET_SRC rather than preserve the
mode of the original SET_DEST.  This encounters problems when the
SET_SRC is a VOIDmode CONST_INT.  Fixed by using match_operand with a
flags_reg_operand predicate.

2022-07-09  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386.md (define_peephole2): Use match_operand of
flags_reg_operand to capture and preserve the mode of FLAGS_REG.
(define_peephole2): Likewise.
(define_peephole2): Likewise...

gcc/config/i386/i386.md

index bdde577ddb50cc0732d7fe3588b16b39a3af9c2c..3b02d0cd567b0e966ce3e06435d893c83849d8dc 100644 (file)
 ;; Convert setcc + movzbl to xor + setcc if operands don't overlap.
 
 (define_peephole2
-  [(set (reg FLAGS_REG) (match_operand 0))
+  [(set (match_operand 4 "flags_reg_operand") (match_operand 0))
    (set (match_operand:QI 1 "register_operand")
        (match_operator:QI 2 "ix86_comparison_operator"
          [(reg FLAGS_REG) (const_int 0)]))
    (set (strict_low_part (match_dup 5))
        (match_dup 2))]
 {
-  operands[4] = gen_rtx_REG (GET_MODE (operands[0]), FLAGS_REG);
   operands[5] = gen_lowpart (QImode, operands[3]);
   ix86_expand_clear (operands[3]);
 })
 
 (define_peephole2
-  [(parallel [(set (reg FLAGS_REG) (match_operand 0))
+  [(parallel [(set (match_operand 5 "flags_reg_operand") (match_operand 0))
              (match_operand 4)])
    (set (match_operand:QI 1 "register_operand")
        (match_operator:QI 2 "ix86_comparison_operator"
    (set (strict_low_part (match_dup 6))
        (match_dup 2))]
 {
-  operands[5] = gen_rtx_REG (GET_MODE (operands[0]), FLAGS_REG);
   operands[6] = gen_lowpart (QImode, operands[3]);
   ix86_expand_clear (operands[3]);
 })
 
 (define_peephole2
-  [(set (reg FLAGS_REG) (match_operand 0))
-   (parallel [(set (reg FLAGS_REG) (match_operand 1))
+  [(set (match_operand 6 "flags_reg_operand") (match_operand 0))
+   (parallel [(set (match_operand 7 "flags_reg_operand") (match_operand 1))
              (match_operand 5)])
    (set (match_operand:QI 2 "register_operand")
        (match_operator:QI 3 "ix86_comparison_operator"
    (set (strict_low_part (match_dup 8))
        (match_dup 3))]
 {
-  operands[6] = gen_rtx_REG (GET_MODE (operands[0]), FLAGS_REG);
-  operands[7] = gen_rtx_REG (GET_MODE (operands[1]), FLAGS_REG);
   operands[8] = gen_lowpart (QImode, operands[4]);
   ix86_expand_clear (operands[4]);
 })
 ;; Similar, but match zero extend with andsi3.
 
 (define_peephole2
-  [(set (reg FLAGS_REG) (match_operand 0))
+  [(set (match_operand 4 "flags_reg_operand") (match_operand 0))
    (set (match_operand:QI 1 "register_operand")
        (match_operator:QI 2 "ix86_comparison_operator"
          [(reg FLAGS_REG) (const_int 0)]))
    (set (strict_low_part (match_dup 5))
        (match_dup 2))]
 {
-  operands[4] = gen_rtx_REG (GET_MODE (operands[0]), FLAGS_REG);
   operands[5] = gen_lowpart (QImode, operands[3]);
   ix86_expand_clear (operands[3]);
 })
 
 (define_peephole2
-  [(parallel [(set (reg FLAGS_REG) (match_operand 0))
+  [(parallel [(set (match_operand 5 "flags_reg_operand") (match_operand 0))
              (match_operand 4)])
    (set (match_operand:QI 1 "register_operand")
        (match_operator:QI 2 "ix86_comparison_operator"
    (set (strict_low_part (match_dup 6))
        (match_dup 2))]
 {
-  operands[5] = gen_rtx_REG (GET_MODE (operands[0]), FLAGS_REG);
   operands[6] = gen_lowpart (QImode, operands[3]);
   ix86_expand_clear (operands[3]);
 })
 
 (define_peephole2
-  [(set (reg FLAGS_REG) (match_operand 0))
-   (parallel [(set (reg FLAGS_REG) (match_operand 1))
+  [(set (match_operand 6 "flags_reg_operand") (match_operand 0))
+   (parallel [(set (match_operand 7 "flags_reg_operand") (match_operand 1))
              (match_operand 5)])
    (set (match_operand:QI 2 "register_operand")
        (match_operator:QI 3 "ix86_comparison_operator"
    (set (strict_low_part (match_dup 8))
        (match_dup 3))]
 {
-  operands[6] = gen_rtx_REG (GET_MODE (operands[0]), FLAGS_REG);
-  operands[7] = gen_rtx_REG (GET_MODE (operands[1]), FLAGS_REG);
   operands[8] = gen_lowpart (QImode, operands[4]);
   ix86_expand_clear (operands[4]);
 })