From: Roger Sayle Date: Sat, 9 Jul 2022 08:07:18 +0000 (+0100) Subject: Improve preservation of FLAGS_REG mode in i386.md's peephole2s. X-Git-Tag: basepoints/gcc-14~5623 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b434c94bf7a5d4bb9ca8f0b5442ca85b43f32a9a;p=thirdparty%2Fgcc.git Improve preservation of FLAGS_REG mode in i386.md's peephole2s. 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 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... --- diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index bdde577ddb5..3b02d0cd567 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -15220,7 +15220,7 @@ ;; 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)])) @@ -15234,13 +15234,12 @@ (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" @@ -15258,14 +15257,13 @@ (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" @@ -15286,8 +15284,6 @@ (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]); }) @@ -15295,7 +15291,7 @@ ;; 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)])) @@ -15309,13 +15305,12 @@ (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" @@ -15334,14 +15329,13 @@ (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" @@ -15363,8 +15357,6 @@ (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]); })